diff options
author | Guido van Rossum <guido@python.org> | 1997-09-22 16:13:19 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-09-22 16:13:19 (GMT) |
commit | 03be7f525e38306910fc2e5de28ff03cb74bb1b7 (patch) | |
tree | cd7c3bda9c70724fbc2ebd2a529a37223d2c98a1 /Tools/bgen | |
parent | a755e68df647bd3dc27749998d19cc47649a8b4f (diff) | |
download | cpython-03be7f525e38306910fc2e5de28ff03cb74bb1b7.zip cpython-03be7f525e38306910fc2e5de28ff03cb74bb1b7.tar.gz cpython-03be7f525e38306910fc2e5de28ff03cb74bb1b7.tar.bz2 |
Changes by jack so the generated modules export their types
to Python.
Diffstat (limited to 'Tools/bgen')
-rw-r--r-- | Tools/bgen/bgen/bgenModule.py | 4 | ||||
-rw-r--r-- | Tools/bgen/bgen/bgenObjectDefinition.py | 11 | ||||
-rw-r--r-- | Tools/bgen/bgen/bgenlocations.py | 5 |
3 files changed, 18 insertions, 2 deletions
diff --git a/Tools/bgen/bgen/bgenModule.py b/Tools/bgen/bgen/bgenModule.py index f339016..2baa398 100644 --- a/Tools/bgen/bgen/bgenModule.py +++ b/Tools/bgen/bgen/bgenModule.py @@ -14,9 +14,11 @@ class Module(GeneratorGroup): self.initstuff = initstuff self.finalstuff = finalstuff self.variablestuff = variablestuff + self.typeobjects = [] def addobject(self, od): self.generators.append(od) + self.typeobjects.append(od) def generate(self): OutHeader1("Module " + self.name) @@ -66,6 +68,8 @@ class Module(GeneratorGroup): Output("""Py_FatalError("can't initialize %s.Error");""", self.name) DedentLevel() + for tp in self.typeobjects: + tp.outputTypeObjectInitializer() if self.variablestuff: Output("%s", self.variablestuff) Output() diff --git a/Tools/bgen/bgen/bgenObjectDefinition.py b/Tools/bgen/bgen/bgenObjectDefinition.py index dd1ad32..a6abf4e 100644 --- a/Tools/bgen/bgen/bgenObjectDefinition.py +++ b/Tools/bgen/bgen/bgenObjectDefinition.py @@ -170,6 +170,17 @@ class ObjectDefinition(GeneratorGroup): Output("(setattrfunc) %s_setattr, /*tp_setattr*/", self.prefix) DedentLevel() Output("};") + + def outputTypeObjectInitializer(self): + Output("""%s.ob_type = &PyType_Type;""", self.typename); + Output("""Py_INCREF(&%s);""", self.typename); + Output("""if (PyDict_SetItemString(d, "%sType", (PyObject *)&%s) != 0)""", + self.name, self.typename); + IndentLevel() + Output("""Py_FatalError("can't initialize %sType");""", + self.name) + DedentLevel() + class GlobalObjectDefinition(ObjectDefinition): diff --git a/Tools/bgen/bgen/bgenlocations.py b/Tools/bgen/bgen/bgenlocations.py index 3ec9c05..1b6b31d 100644 --- a/Tools/bgen/bgen/bgenlocations.py +++ b/Tools/bgen/bgen/bgenlocations.py @@ -3,10 +3,11 @@ # # Where to find the Universal Header include files: -INCLUDEDIR="Sap:CW8 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:" +MWERKSDIR="Moes:Metrowerks:Metrowerks CodeWarrior:" +INCLUDEDIR=MWERKSDIR + "MacOS Support:Headers:Universal Headers:" # Where to put the python definitions file: -TOOLBOXDIR="Moes:Development:Jack:Python 1.3:Mac:Lib:toolbox:" +TOOLBOXDIR="Moes:Development:Jack:Python:Mac:Lib:toolbox:" # Creator for C files: CREATOR="CWIE" |