Commit bf7255ff authored by Jack Jansen's avatar Jack Jansen

Minor tweaks, to allow some (out-of-tree, until successful) tinkering

with C++.
parent 52a14c3c
...@@ -18,6 +18,7 @@ class BaseFunctionGenerator: ...@@ -18,6 +18,7 @@ class BaseFunctionGenerator:
def __init__(self, name, condition=None): def __init__(self, name, condition=None):
if DEBUG: print "<--", name if DEBUG: print "<--", name
self.name = name self.name = name
self.callname = name
self.prefix = name self.prefix = name
self.objecttype = "PyObject" # Type of _self argument to function self.objecttype = "PyObject" # Type of _self argument to function
self.condition = condition self.condition = condition
...@@ -202,7 +203,7 @@ class FunctionGenerator(BaseFunctionGenerator): ...@@ -202,7 +203,7 @@ class FunctionGenerator(BaseFunctionGenerator):
def callit(self): def callit(self):
args = "" args = ""
if self.rv: if self.rv:
s = "%s = %s(" % (self.rv.name, self.name) s = "%s = %s(" % (self.rv.name, self.callname)
else: else:
s = "%s(" % self.name s = "%s(" % self.name
sep = ",\n" + ' '*len(s) sep = ",\n" + ' '*len(s)
...@@ -214,9 +215,9 @@ class FunctionGenerator(BaseFunctionGenerator): ...@@ -214,9 +215,9 @@ class FunctionGenerator(BaseFunctionGenerator):
args = args + s args = args + s
if self.rv: if self.rv:
Output("%s = %s(%s);", Output("%s = %s(%s);",
self.rv.name, self.name, args) self.rv.name, self.callname, args)
else: else:
Output("%s(%s);", self.name, args) Output("%s(%s);", self.callname, args)
def checkit(self): def checkit(self):
for arg in self.argumentList: for arg in self.argumentList:
...@@ -256,7 +257,6 @@ class MethodGenerator(FunctionGenerator): ...@@ -256,7 +257,6 @@ class MethodGenerator(FunctionGenerator):
self.argumentList.append(self.itself) self.argumentList.append(self.itself)
FunctionGenerator.parseArgumentList(self, args) FunctionGenerator.parseArgumentList(self, args)
def _test(): def _test():
void = None void = None
eggs = FunctionGenerator(void, "eggs", eggs = FunctionGenerator(void, "eggs",
......
...@@ -44,12 +44,8 @@ class ObjectDefinition(GeneratorGroup): ...@@ -44,12 +44,8 @@ class ObjectDefinition(GeneratorGroup):
OutHeader2("Object type " + self.name) OutHeader2("Object type " + self.name)
sf = self.static and "static " self.outputCheck()
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()
Output("typedef struct %s {", self.objecttype) Output("typedef struct %s {", self.objecttype)
IndentLevel() IndentLevel()
Output("PyObject_HEAD") Output("PyObject_HEAD")
...@@ -84,6 +80,14 @@ class ObjectDefinition(GeneratorGroup): ...@@ -84,6 +80,14 @@ class ObjectDefinition(GeneratorGroup):
OutHeader2("End object type " + self.name) 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): def outputMethodChain(self):
Output("%sPyMethodChain %s_chain = { %s_methods, %s };", Output("%sPyMethodChain %s_chain = { %s_methods, %s };",
self.static, self.prefix, self.prefix, self.basechain) self.static, self.prefix, self.prefix, self.basechain)
......
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