]> granicus.if.org Git - python/commitdiff
Added methods mkvaluePreCheck and getargsPreCheck, which are called (for
authorJack Jansen <jack.jansen@cwi.nl>
Fri, 1 Jul 2005 20:23:27 +0000 (20:23 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Fri, 1 Jul 2005 20:23:27 +0000 (20:23 +0000)
each variable) before calling Py_BuildValue and PyArg_Parse.

Tools/bgen/bgen/bgenGenerator.py
Tools/bgen/bgen/bgenType.py
Tools/bgen/bgen/bgenVariable.py

index 83ff552b0cb6f3b940dfdfefe185b1e96346b1b3..d77da31700fe3e207a93cb3462a033e96bb6fb2c 100644 (file)
@@ -194,6 +194,7 @@ class FunctionGenerator(BaseFunctionGenerator):
             if arg.flags == SelfMode:
                 continue
             if arg.mode in (InMode, InOutMode):
+                arg.getargsPreCheck()
                 fmt = fmt + arg.getargsFormat()
                 args = arg.getargsArgs()
                 if args:
@@ -242,6 +243,7 @@ class FunctionGenerator(BaseFunctionGenerator):
             if not arg: continue
             if arg.flags == ErrorMode: continue
             if arg.mode in (OutMode, InOutMode):
+                arg.mkvaluePreCheck()
                 fmt = fmt + arg.mkvalueFormat()
                 lst = lst + sep + arg.mkvalueArgs()
         if fmt == "":
index f7cb3886373f3d76583aed546fe05a207e23da28..00dd9d7ad67c3ccf33d3395c0c7569ed5d0dab9d 100644 (file)
@@ -61,11 +61,18 @@ class Type:
         """
         return "&" + name
 
+    def getargsPreCheck(self, name):
+        """Perform any actions needed before calling getargs().
+        
+        This could include declaring temporary variables and such.
+        """
+    
     def getargsCheck(self, name):
         """Perform any needed post-[new]getargs() checks.
 
         This is type-dependent; the default does not check for errors.
-        An example would be a check for a maximum string length."""
+        An example would be a check for a maximum string length, or it
+        could do post-getargs() copying or conversion."""
 
     def passInput(self, name):
         """Return an argument for passing a variable into a call.
@@ -119,6 +126,12 @@ class Type:
         """
         return name
 
+    def mkvaluePreCheck(self, name):
+        """Perform any actions needed before calling mkvalue().
+        
+        This could include declaring temporary variables and such.
+        """
+    
     def cleanup(self, name):
         """Clean up if necessary.
 
index 6edeb873fca2b94872a4e6349457e057bac2d71e..7848a4fa21f472baa5696c65fc943b5a44df85d4 100644 (file)
@@ -63,6 +63,9 @@ class Variable:
     def getargsCheck(self):
         return self.type.getargsCheck(self.name)
 
+    def getargsPreCheck(self):
+        return self.type.getargsPreCheck(self.name)
+
     def passArgument(self):
         """Return the string required to pass the variable as argument.
 
@@ -95,6 +98,9 @@ class Variable:
         """Call the type's mkvalueArgs method."""
         return self.type.mkvalueArgs(self.name)
 
+    def mkvaluePreCheck(self):
+        return self.type.mkvaluePreCheck(self.name)
+
     def cleanup(self):
         """Call the type's cleanup method."""
         return self.type.cleanup(self.name)