summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2005-06-10 10:46:40 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2005-06-10 10:46:40 (GMT)
commitbf7255fffb5dda1b9541892cc40412bb6bbd4409 (patch)
tree75fe46c5ccac984d591aba2ba1132303f880ba3c /Tools
parent52a14c3cdc551d1eb45d2c2de13dd96f41635c86 (diff)
downloadcpython-bf7255fffb5dda1b9541892cc40412bb6bbd4409.zip
cpython-bf7255fffb5dda1b9541892cc40412bb6bbd4409.tar.gz
cpython-bf7255fffb5dda1b9541892cc40412bb6bbd4409.tar.bz2
Minor tweaks, to allow some (out-of-tree, until successful) tinkering
with C++.
Diffstat (limited to 'Tools')
-rw-r--r--Tools/bgen/bgen/bgenGenerator.py10
-rw-r--r--Tools/bgen/bgen/bgenObjectDefinition.py16
2 files changed, 15 insertions, 11 deletions
diff --git a/Tools/bgen/bgen/bgenGenerator.py b/Tools/bgen/bgen/bgenGenerator.py
index e1f240c..471c5fa 100644
--- a/Tools/bgen/bgen/bgenGenerator.py
+++ b/Tools/bgen/bgen/bgenGenerator.py
@@ -18,6 +18,7 @@ class BaseFunctionGenerator:
def __init__(self, name, condition=None):
if DEBUG: print "<--", name
self.name = name
+ self.callname = name
self.prefix = name
self.objecttype = "PyObject" # Type of _self argument to function
self.condition = condition
@@ -202,7 +203,7 @@ class FunctionGenerator(BaseFunctionGenerator):
def callit(self):
args = ""
if self.rv:
- s = "%s = %s(" % (self.rv.name, self.name)
+ s = "%s = %s(" % (self.rv.name, self.callname)
else:
s = "%s(" % self.name
sep = ",\n" + ' '*len(s)
@@ -214,9 +215,9 @@ class FunctionGenerator(BaseFunctionGenerator):
args = args + s
if self.rv:
Output("%s = %s(%s);",
- self.rv.name, self.name, args)
+ self.rv.name, self.callname, args)
else:
- Output("%s(%s);", self.name, args)
+ Output("%s(%s);", self.callname, args)
def checkit(self):
for arg in self.argumentList:
@@ -255,8 +256,7 @@ class MethodGenerator(FunctionGenerator):
self.itself = Variable(t0, "_self->ob_itself", SelfMode)
self.argumentList.append(self.itself)
FunctionGenerator.parseArgumentList(self, args)
-
-
+
def _test():
void = None
eggs = FunctionGenerator(void, "eggs",
diff --git a/Tools/bgen/bgen/bgenObjectDefinition.py b/Tools/bgen/bgen/bgenObjectDefinition.py
index 72e2678..ffdd544 100644
--- a/Tools/bgen/bgen/bgenObjectDefinition.py
+++ b/Tools/bgen/bgen/bgenObjectDefinition.py
@@ -44,12 +44,8 @@ class ObjectDefinition(GeneratorGroup):
OutHeader2("Object type " + self.name)
- sf = self.static and "static "
- Output("%sPyTypeObject %s;", sf, self.typename)
- Output()
- Output("#define %s_Check(x) ((x)->ob_type == &%s || PyObject_TypeCheck((x), &%s))",
- self.prefix, self.typename, self.typename)
- Output()
+ self.outputCheck()
+
Output("typedef struct %s {", self.objecttype)
IndentLevel()
Output("PyObject_HEAD")
@@ -84,6 +80,14 @@ class ObjectDefinition(GeneratorGroup):
OutHeader2("End object type " + self.name)
+ def outputCheck(self):
+ sf = self.static and "static "
+ Output("%sPyTypeObject %s;", sf, self.typename)
+ Output()
+ Output("#define %s_Check(x) ((x)->ob_type == &%s || PyObject_TypeCheck((x), &%s))",
+ self.prefix, self.typename, self.typename)
+ Output()
+
def outputMethodChain(self):
Output("%sPyMethodChain %s_chain = { %s_methods, %s };",
self.static, self.prefix, self.prefix, self.basechain)