]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
More factorization.
authorJack Jansen <jack.jansen@cwi.nl>
Thu, 16 Jun 2005 21:26:24 +0000 (21:26 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Thu, 16 Jun 2005 21:26:24 +0000 (21:26 +0000)
Tools/bgen/bgen/bgenType.py
Tools/bgen/bgen/bgenVariable.py

index 9d5b4f81212af97fe15b9154ae6bb5b0417c443c..2f0bc57350d16c8696fa293f4d9dc2901fc80ceb 100644 (file)
@@ -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.
 
index 36c287d6e5df1fb3c55930afc3550f312aeb3dbf..a71d0f54e8d400de254077f04ee74dd6364d1922 100644 (file)
@@ -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."""