Commit 5801a2d8 authored by Jack Jansen's avatar Jack Jansen

The module generator now tells its object generators about the module name...

The module generator now tells its object generators about the module name (through the new setmodulename() method). If the module name has been set the object generators output it as part of the tp_name field for the object type.
parent b2fb202b
...@@ -19,6 +19,7 @@ class Module(GeneratorGroup): ...@@ -19,6 +19,7 @@ class Module(GeneratorGroup):
def addobject(self, od): def addobject(self, od):
self.generators.append(od) self.generators.append(od)
self.typeobjects.append(od) self.typeobjects.append(od)
od.setmodulename(self.name)
def generate(self): def generate(self):
OutHeader1("Module " + self.name) OutHeader1("Module " + self.name)
......
...@@ -22,6 +22,7 @@ class ObjectDefinition(GeneratorGroup): ...@@ -22,6 +22,7 @@ class ObjectDefinition(GeneratorGroup):
self.typename = name + '_Type' self.typename = name + '_Type'
self.argref = "" # set to "*" if arg to <type>_New should be pointer self.argref = "" # set to "*" if arg to <type>_New should be pointer
self.static = "static " # set to "" to make <type>_New and <type>_Convert public self.static = "static " # set to "" to make <type>_New and <type>_Convert public
self.modulename = None
def add(self, g, dupcheck=0): def add(self, g, dupcheck=0):
g.setselftype(self.objecttype, self.itselftype) g.setselftype(self.objecttype, self.itselftype)
...@@ -31,6 +32,9 @@ class ObjectDefinition(GeneratorGroup): ...@@ -31,6 +32,9 @@ class ObjectDefinition(GeneratorGroup):
# In case we are referenced from a module # In case we are referenced from a module
pass pass
def setmodulename(self, name):
self.modulename = name
def generate(self): def generate(self):
# XXX This should use long strings and %(varname)s substitution! # XXX This should use long strings and %(varname)s substitution!
...@@ -166,6 +170,9 @@ class ObjectDefinition(GeneratorGroup): ...@@ -166,6 +170,9 @@ class ObjectDefinition(GeneratorGroup):
IndentLevel() IndentLevel()
Output("PyObject_HEAD_INIT(NULL)") Output("PyObject_HEAD_INIT(NULL)")
Output("0, /*ob_size*/") Output("0, /*ob_size*/")
if self.modulename:
Output("\"%s.%s\", /*tp_name*/", self.modulename, self.name)
else:
Output("\"%s\", /*tp_name*/", self.name) Output("\"%s\", /*tp_name*/", self.name)
Output("sizeof(%s), /*tp_basicsize*/", self.objecttype) Output("sizeof(%s), /*tp_basicsize*/", self.objecttype)
Output("0, /*tp_itemsize*/") Output("0, /*tp_itemsize*/")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment