[Python-checkins] python/dist/src/Tools/bgen/bgen bgenVariable.py, 1.4, 1.5 scantools.py, 1.36, 1.37

jackjansen@users.sourceforge.net jackjansen at users.sourceforge.net
Tue Jun 21 22:54:53 CEST 2005


Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25268
Modified Files:
	bgenVariable.py scantools.py 
Log Message:
Added support for optional modifiers to functions/methods (such as C++ const,
static for methods, inline, etc).
Index: bgenVariable.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenVariable.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- bgenVariable.py	16 Jun 2005 21:26:24 -0000	1.4
+++ bgenVariable.py	21 Jun 2005 20:54:51 -0000	1.5
@@ -14,6 +14,7 @@
 ReturnMode = 8+OutMode # this is the function return value
 ErrorMode = 16+OutMode # this is an error status -- turn it into an exception
 RefMode = 32
+ConstMode = 64
 
 class Variable:
 
@@ -47,7 +48,8 @@
 def getDeclaration(self):
 """Return the unadorned declaration of the variable,
 suitable for use in a formal parameter list."""
- return self.type.getDeclaration(self.name)
+ refmode = (self.flags & RefMode)
+ return self.type.getDeclaration(self.name, reference=refmode)
 
 def getargsFormat(self):
 """Call the type's getargsFormatmethod."""
Index: scantools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/scantools.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- scantools.py	14 Jun 2005 21:32:51 -0000	1.36
+++ scantools.py	21 Jun 2005 20:54:51 -0000	1.37
@@ -479,6 +479,7 @@
 self.report("(but type matched)")
 return
 type, name, args = match.group('type', 'name', 'args')
+ modifiers = self.getmodifiers(match)
 type = self.pythonizename(type)
 name = self.pythonizename(name)
 if name in self.alreadydone:
@@ -499,8 +500,14 @@
 self.report("*** %s %s unmanageable", type, name)
 return
 self.alreadydone.append(name)
- self.generate(type, name, arglist)
+ if modifiers:
+ self.generate(type, name, arglist, modifiers)
+ else:
+ self.generate(type, name, arglist)
 
+ def getmodifiers(self, match):
+ return []
+ 
 def pythonizename(self, name):
 name = re.sub("\*", " ptr", name)
 name = name.strip()
@@ -592,12 +599,16 @@
 ##self.report("new: %r", new)
 return new
 
- def generate(self, type, name, arglist):
- self.typeused(type, 'return')
- classname, listname = self.destination(type, name, arglist)
+ def generate(self, tp, name, arglist, modifiers=[]):
+ 
+ self.typeused(tp, 'return')
+ if modifiers:
+ classname, listname = self.destination(tp, name, arglist, modifiers)
+ else:
+ classname, listname = self.destination(tp, name, arglist)
 if not classname or not listname: return
 if not self.specfile: return
- self.specfile.write("f = %s(%s, %r,\n" % (classname, type, name))
+ self.specfile.write("f = %s(%s, %r,\n" % (classname, tp, name))
 for atype, aname, amode in arglist:
 self.typeused(atype, amode)
 self.specfile.write(" (%s, %r, %s),\n" %


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /