Skip to content

Commit

Permalink
More factorization.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackjansen committed Jun 16, 2005
1 parent 8966d3d commit 2ab0ae6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Tools/bgen/bgen/bgenType.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ def declare(self, name, reference=False):
Example: int.declare('spam') prints "int spam;"
"""
Output("%s;", self.getDeclaration(name, reference))

def getDeclaration(self, name, reference=False):
"""Return a string declaring a variable or argument, without
any syntactic adornment"""
if reference:
Output("%s& %s;", self.typeName, name)
return "%s& %s" % (self.typeName, name)
else:
Output("%s %s;", self.typeName, name)

return "%s %s" % (self.typeName, name)
def getargs(self):
return self.getargsFormat(), self.getargsArgs()

Expand Down Expand Up @@ -72,6 +77,7 @@ def passReference(self, name):
Default is to call passInput().
"""
return self.passInput(name)

def errorCheck(self, name):
"""Check for an error returned in the variable.
Expand Down
5 changes: 5 additions & 0 deletions Tools/bgen/bgen/bgenVariable.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def declare(self):
self.type.declare(self.name, reference=True)
elif self.flags != SelfMode:
self.type.declare(self.name)

def getDeclaration(self):
"""Return the unadorned declaration of the variable,
suitable for use in a formal parameter list."""
return self.type.getDeclaration(self.name)

def getargsFormat(self):
"""Call the type's getargsFormatmethod."""
Expand Down

0 comments on commit 2ab0ae6

Please sign in to comment.