Skip to content

Commit

Permalink
Minor tweaks, to allow some (out-of-tree, until successful) tinkering
Browse files Browse the repository at this point in the history
with C++.
  • Loading branch information
jackjansen committed Jun 10, 2005
1 parent 52a14c3 commit bf7255f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
10 changes: 5 additions & 5 deletions Tools/bgen/bgen/bgenGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -202,7 +203,7 @@ def precheck(self):
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)
Expand All @@ -214,9 +215,9 @@ def callit(self):
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:
Expand Down Expand Up @@ -255,8 +256,7 @@ def parseArgumentList(self, args):
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",
Expand Down
16 changes: 10 additions & 6 deletions Tools/bgen/bgen/bgenObjectDefinition.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@ def generate(self):

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")
Expand Down Expand Up @@ -84,6 +80,14 @@ def generate(self):

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)
Expand Down

0 comments on commit bf7255f

Please sign in to comment.