diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2005-06-16 21:26:24 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2005-06-16 21:26:24 (GMT) |
commit | 2ab0ae6a5431205aeda1142342b4df052f2e4845 (patch) | |
tree | de244726d35c165a2778afd82639de7543d3a5c3 /Tools | |
parent | 8966d3de70521a60fa3d658e8c72db9ed63283a6 (diff) | |
download | cpython-2ab0ae6a5431205aeda1142342b4df052f2e4845.zip cpython-2ab0ae6a5431205aeda1142342b4df052f2e4845.tar.gz cpython-2ab0ae6a5431205aeda1142342b4df052f2e4845.tar.bz2 |
More factorization.
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/bgen/bgen/bgenType.py | 12 | ||||
-rw-r--r-- | Tools/bgen/bgen/bgenVariable.py | 5 |
2 files changed, 14 insertions, 3 deletions
diff --git a/Tools/bgen/bgen/bgenType.py b/Tools/bgen/bgen/bgenType.py index 9d5b4f8..2f0bc57 100644 --- a/Tools/bgen/bgen/bgenType.py +++ b/Tools/bgen/bgen/bgenType.py @@ -24,11 +24,16 @@ class Type: 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() @@ -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. diff --git a/Tools/bgen/bgen/bgenVariable.py b/Tools/bgen/bgen/bgenVariable.py index 36c287d..a71d0f5 100644 --- a/Tools/bgen/bgen/bgenVariable.py +++ b/Tools/bgen/bgen/bgenVariable.py @@ -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.""" |