mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
More factorization.
This commit is contained in:
parent
8966d3de70
commit
2ab0ae6a54
2 changed files with 15 additions and 4 deletions
|
@ -24,11 +24,16 @@ class Type:
|
|||
|
||||
Example: int.declare('spam') prints "int spam;"
|
||||
"""
|
||||
if reference:
|
||||
Output("%s& %s;", self.typeName, name)
|
||||
else:
|
||||
Output("%s %s;", self.typeName, name)
|
||||
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:
|
||||
return "%s& %s" % (self.typeName, name)
|
||||
else:
|
||||
return "%s %s" % (self.typeName, name)
|
||||
|
||||
def getargs(self):
|
||||
return self.getargsFormat(), self.getargsArgs()
|
||||
|
||||
|
@ -72,6 +77,7 @@ class Type:
|
|||
Default is to call passInput().
|
||||
"""
|
||||
return self.passInput(name)
|
||||
|
||||
def errorCheck(self, name):
|
||||
"""Check for an error returned in the variable.
|
||||
|
||||
|
|
|
@ -43,6 +43,11 @@ class Variable:
|
|||
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."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue