summaryrefslogtreecommitdiffstats
path: root/Tools/bgen
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2001-12-09 23:25:00 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2001-12-09 23:25:00 (GMT)
commit5801a2d8e3769a64fc0eac0111c4310d72651d98 (patch)
treeeead87be0bfb31029d5cc05106a6597e21018f60 /Tools/bgen
parentb2fb202bc24dc3125f07838ae9cbf5830e71c9d5 (diff)
downloadcpython-5801a2d8e3769a64fc0eac0111c4310d72651d98.zip
cpython-5801a2d8e3769a64fc0eac0111c4310d72651d98.tar.gz
cpython-5801a2d8e3769a64fc0eac0111c4310d72651d98.tar.bz2
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.
Diffstat (limited to 'Tools/bgen')
-rw-r--r--Tools/bgen/bgen/bgenModule.py1
-rw-r--r--Tools/bgen/bgen/bgenObjectDefinition.py9
2 files changed, 9 insertions, 1 deletions
diff --git a/Tools/bgen/bgen/bgenModule.py b/Tools/bgen/bgen/bgenModule.py
index 5f94b904..ea1ea23 100644
--- a/Tools/bgen/bgen/bgenModule.py
+++ b/Tools/bgen/bgen/bgenModule.py
@@ -19,6 +19,7 @@ class Module(GeneratorGroup):
def addobject(self, od):
self.generators.append(od)
self.typeobjects.append(od)
+ od.setmodulename(self.name)
def generate(self):
OutHeader1("Module " + self.name)
diff --git a/Tools/bgen/bgen/bgenObjectDefinition.py b/Tools/bgen/bgen/bgenObjectDefinition.py
index 1d5cb22..71cf21d 100644
--- a/Tools/bgen/bgen/bgenObjectDefinition.py
+++ b/Tools/bgen/bgen/bgenObjectDefinition.py
@@ -22,6 +22,7 @@ class ObjectDefinition(GeneratorGroup):
self.typename = name + '_Type'
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.modulename = None
def add(self, g, dupcheck=0):
g.setselftype(self.objecttype, self.itselftype)
@@ -30,6 +31,9 @@ class ObjectDefinition(GeneratorGroup):
def reference(self):
# In case we are referenced from a module
pass
+
+ def setmodulename(self, name):
+ self.modulename = name
def generate(self):
# XXX This should use long strings and %(varname)s substitution!
@@ -166,7 +170,10 @@ class ObjectDefinition(GeneratorGroup):
IndentLevel()
Output("PyObject_HEAD_INIT(NULL)")
Output("0, /*ob_size*/")
- Output("\"%s\", /*tp_name*/", self.name)
+ if self.modulename:
+ Output("\"%s.%s\", /*tp_name*/", self.modulename, self.name)
+ else:
+ Output("\"%s\", /*tp_name*/", self.name)
Output("sizeof(%s), /*tp_basicsize*/", self.objecttype)
Output("0, /*tp_itemsize*/")
Output("/* methods */")