summaryrefslogtreecommitdiffstats
path: root/Tools/bgen
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/bgen')
-rw-r--r--Tools/bgen/bgen/bgenVariable.py4
-rw-r--r--Tools/bgen/bgen/scantools.py21
2 files changed, 19 insertions, 6 deletions
diff --git a/Tools/bgen/bgen/bgenVariable.py b/Tools/bgen/bgen/bgenVariable.py
index a71d0f5..01cab56 100644
--- a/Tools/bgen/bgen/bgenVariable.py
+++ b/Tools/bgen/bgen/bgenVariable.py
@@ -14,6 +14,7 @@ SelfMode = 4+InMode # this is 'self' -- don't declare it
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 @@ class Variable:
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."""
diff --git a/Tools/bgen/bgen/scantools.py b/Tools/bgen/bgen/scantools.py
index 7d2488e..2423e43 100644
--- a/Tools/bgen/bgen/scantools.py
+++ b/Tools/bgen/bgen/scantools.py
@@ -479,6 +479,7 @@ if missing: raise "Missing Types"
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 @@ if missing: raise "Missing Types"
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 @@ if missing: raise "Missing Types"
##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" %