Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf7255f

Browse files
committed
Minor tweaks, to allow some (out-of-tree, until successful) tinkering
with C++.
1 parent 52a14c3 commit bf7255f

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

Tools/bgen/bgen/bgenGenerator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class BaseFunctionGenerator:
1818
def __init__(self, name, condition=None):
1919
if DEBUG: print "<--", name
2020
self.name = name
21+
self.callname = name
2122
self.prefix = name
2223
self.objecttype = "PyObject" # Type of _self argument to function
2324
self.condition = condition
@@ -202,7 +203,7 @@ def precheck(self):
202203
def callit(self):
203204
args = ""
204205
if self.rv:
205-
s = "%s = %s(" % (self.rv.name, self.name)
206+
s = "%s = %s(" % (self.rv.name, self.callname)
206207
else:
207208
s = "%s(" % self.name
208209
sep = ",\n" + ' '*len(s)
@@ -214,9 +215,9 @@ def callit(self):
214215
args = args + s
215216
if self.rv:
216217
Output("%s = %s(%s);",
217-
self.rv.name, self.name, args)
218+
self.rv.name, self.callname, args)
218219
else:
219-
Output("%s(%s);", self.name, args)
220+
Output("%s(%s);", self.callname, args)
220221

221222
def checkit(self):
222223
for arg in self.argumentList:
@@ -255,8 +256,7 @@ def parseArgumentList(self, args):
255256
self.itself = Variable(t0, "_self->ob_itself", SelfMode)
256257
self.argumentList.append(self.itself)
257258
FunctionGenerator.parseArgumentList(self, args)
258-
259-
259+
260260
def _test():
261261
void = None
262262
eggs = FunctionGenerator(void, "eggs",

Tools/bgen/bgen/bgenObjectDefinition.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,8 @@ def generate(self):
4444

4545
OutHeader2("Object type " + self.name)
4646

47-
sf = self.static and "static "
48-
Output("%sPyTypeObject %s;", sf, self.typename)
49-
Output()
50-
Output("#define %s_Check(x) ((x)->ob_type == &%s || PyObject_TypeCheck((x), &%s))",
51-
self.prefix, self.typename, self.typename)
52-
Output()
47+
self.outputCheck()
48+
5349
Output("typedef struct %s {", self.objecttype)
5450
IndentLevel()
5551
Output("PyObject_HEAD")
@@ -84,6 +80,14 @@ def generate(self):
8480

8581
OutHeader2("End object type " + self.name)
8682

83+
def outputCheck(self):
84+
sf = self.static and "static "
85+
Output("%sPyTypeObject %s;", sf, self.typename)
86+
Output()
87+
Output("#define %s_Check(x) ((x)->ob_type == &%s || PyObject_TypeCheck((x), &%s))",
88+
self.prefix, self.typename, self.typename)
89+
Output()
90+
8791
def outputMethodChain(self):
8892
Output("%sPyMethodChain %s_chain = { %s_methods, %s };",
8993
self.static, self.prefix, self.prefix, self.basechain)

0 commit comments

Comments
 (0)