mirror of
https://github.com/python/cpython
synced 2024-09-05 08:17:45 +00:00
Changes by jack so the generated modules export their types
to Python.
This commit is contained in:
parent
a755e68df6
commit
03be7f525e
|
@ -14,9 +14,11 @@ def __init__(self, name, prefix = None,
|
|||
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 @@ def createModuleVariables(self):
|
|||
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()
|
||||
|
|
|
@ -170,6 +170,17 @@ def outputTypeObject(self):
|
|||
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):
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue