diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2005-07-01 20:23:27 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2005-07-01 20:23:27 (GMT) |
commit | a660caf35108506d7f29b1eaa07c221be21512cd (patch) | |
tree | 11640f729b2b9cb24c38a0402d99dd36a874c586 | |
parent | 87de8ed4b929d338fca743347df5b7100ead1ae0 (diff) | |
download | cpython-a660caf35108506d7f29b1eaa07c221be21512cd.zip cpython-a660caf35108506d7f29b1eaa07c221be21512cd.tar.gz cpython-a660caf35108506d7f29b1eaa07c221be21512cd.tar.bz2 |
Added methods mkvaluePreCheck and getargsPreCheck, which are called (for
each variable) before calling Py_BuildValue and PyArg_Parse.
-rw-r--r-- | Tools/bgen/bgen/bgenGenerator.py | 2 | ||||
-rw-r--r-- | Tools/bgen/bgen/bgenType.py | 15 | ||||
-rw-r--r-- | Tools/bgen/bgen/bgenVariable.py | 6 |
3 files changed, 22 insertions, 1 deletions
diff --git a/Tools/bgen/bgen/bgenGenerator.py b/Tools/bgen/bgen/bgenGenerator.py index 83ff552..d77da31 100644 --- a/Tools/bgen/bgen/bgenGenerator.py +++ b/Tools/bgen/bgen/bgenGenerator.py @@ -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 == "": diff --git a/Tools/bgen/bgen/bgenType.py b/Tools/bgen/bgen/bgenType.py index f7cb388..00dd9d7 100644 --- a/Tools/bgen/bgen/bgenType.py +++ b/Tools/bgen/bgen/bgenType.py @@ -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. diff --git a/Tools/bgen/bgen/bgenVariable.py b/Tools/bgen/bgen/bgenVariable.py index 6edeb87..7848a4f 100644 --- a/Tools/bgen/bgen/bgenVariable.py +++ b/Tools/bgen/bgen/bgenVariable.py @@ -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) |