diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2005-06-29 14:17:05 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2005-06-29 14:17:05 (GMT) |
commit | d4128f397dbfe400e34d399d6b4595240b3de546 (patch) | |
tree | 6c36e74a13f6078d82f5f49801c5211f42ca84b2 /Tools/bgen | |
parent | b6216dd2e7451093239cd04a985be4130714823e (diff) | |
download | cpython-d4128f397dbfe400e34d399d6b4595240b3de546.zip cpython-d4128f397dbfe400e34d399d6b4595240b3de546.tar.gz cpython-d4128f397dbfe400e34d399d6b4595240b3de546.tar.bz2 |
Added optional suppport for storage modifiers (virtual/static/inline/etc)
and conditional generation of objects and methods.
Diffstat (limited to 'Tools/bgen')
-rw-r--r-- | Tools/bgen/bgen/bgenGenerator.py | 15 | ||||
-rw-r--r-- | Tools/bgen/bgen/bgenObjectDefinition.py | 3 | ||||
-rw-r--r-- | Tools/bgen/bgen/scantools.py | 4 |
3 files changed, 20 insertions, 2 deletions
diff --git a/Tools/bgen/bgen/bgenGenerator.py b/Tools/bgen/bgen/bgenGenerator.py index e92097e..03e8b45 100644 --- a/Tools/bgen/bgen/bgenGenerator.py +++ b/Tools/bgen/bgen/bgenGenerator.py @@ -15,18 +15,27 @@ INOUT = IN_OUT = "in-out" class BaseFunctionGenerator: - def __init__(self, name, condition=None): + def __init__(self, name, condition=None, callname=None, modifiers=None): if DEBUG: print "<--", name self.name = name - self.callname = name + if callname: + self.callname = callname + else: + self.callname = name self.prefix = name self.objecttype = "PyObject" # Type of _self argument to function self.condition = condition + self.modifiers = modifiers def setprefix(self, prefix): self.prefix = prefix + def checkgenerate(self): + return True + def generate(self): + if not self.checkgenerate(): + return if DEBUG: print "-->", self.name if self.condition: Output() @@ -51,6 +60,8 @@ class BaseFunctionGenerator: OutRbrace() def reference(self, name = None): + if not self.checkgenerate(): + return if name is None: name = self.name docstring = self.docstring() diff --git a/Tools/bgen/bgen/bgenObjectDefinition.py b/Tools/bgen/bgen/bgenObjectDefinition.py index a77e337..64075de 100644 --- a/Tools/bgen/bgen/bgenObjectDefinition.py +++ b/Tools/bgen/bgen/bgenObjectDefinition.py @@ -219,6 +219,9 @@ class ObjectDefinition(GeneratorGroup): Output("if (PyType_Ready(&%s) < 0) return;", self.typename) Output("""Py_INCREF(&%s);""", self.typename) Output("PyModule_AddObject(m, \"%s\", (PyObject *)&%s);", self.name, self.typename); + self.outputTypeObjectInitializerCompat() + + def outputTypeObjectInitializerCompat(self): Output("/* Backward-compatible name */") Output("""Py_INCREF(&%s);""", self.typename); Output("PyModule_AddObject(m, \"%sType\", (PyObject *)&%s);", self.name, self.typename); diff --git a/Tools/bgen/bgen/scantools.py b/Tools/bgen/bgen/scantools.py index 1ebf70d..777a7dc 100644 --- a/Tools/bgen/bgen/scantools.py +++ b/Tools/bgen/bgen/scantools.py @@ -620,11 +620,15 @@ if missing: raise "Missing Types" (atype, aname, amode)) if self.greydictnames.has_key(name): self.specfile.write(" condition=%r,\n"%(self.greydictnames[name],)) + self.generatemodifiers(classname, name, modifiers) self.specfile.write(")\n") self.specfile.write("%s.append(f)\n\n" % listname) def destination(self, type, name, arglist): return "FunctionGenerator", "functions" + + def generatemodifiers(self, classname, name, modifiers): + pass def blacklisted(self, type, name): if type in self.blacklisttypes: |