Added methods mkvaluePreCheck and getargsPreCheck, which are called (for

each variable) before calling Py_BuildValue and PyArg_Parse.
This commit is contained in:
Jack Jansen 2005-07-01 20:23:27 +00:00
parent 87de8ed4b9
commit a660caf351
3 changed files with 22 additions and 1 deletions

View 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 == "":

View 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.

View 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)