From a660caf35108506d7f29b1eaa07c221be21512cd Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Fri, 1 Jul 2005 20:23:27 +0000 Subject: [PATCH] Added methods mkvaluePreCheck and getargsPreCheck, which are called (for each variable) before calling Py_BuildValue and PyArg_Parse. --- Tools/bgen/bgen/bgenGenerator.py | 2 ++ Tools/bgen/bgen/bgenType.py | 15 ++++++++++++++- Tools/bgen/bgen/bgenVariable.py | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Tools/bgen/bgen/bgenGenerator.py b/Tools/bgen/bgen/bgenGenerator.py index 83ff552b0cb..d77da31700f 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 f7cb3886373..00dd9d7ad67 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 6edeb873fca..7848a4fa21f 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)