Skip to content

Commit

Permalink
Added methods mkvaluePreCheck and getargsPreCheck, which are called (for
Browse files Browse the repository at this point in the history
each variable) before calling Py_BuildValue and PyArg_Parse.
  • Loading branch information
jackjansen committed Jul 1, 2005
1 parent 87de8ed commit a660caf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Tools/bgen/bgen/bgenGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def getargs(self):
if arg.flags == SelfMode:
continue
if arg.mode in (InMode, InOutMode):
arg.getargsPreCheck()
fmt = fmt + arg.getargsFormat()
args = arg.getargsArgs()
if args:
Expand Down Expand Up @@ -242,6 +243,7 @@ def returnvalue(self):
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 == "":
Expand Down
15 changes: 14 additions & 1 deletion Tools/bgen/bgen/bgenType.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,18 @@ def getargsArgs(self, name):
"""
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.
Expand Down Expand Up @@ -119,6 +126,12 @@ def mkvalueArgs(self, name):
"""
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.
Expand Down
6 changes: 6 additions & 0 deletions Tools/bgen/bgen/bgenVariable.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def getargsArgs(self):
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.
Expand Down Expand Up @@ -95,6 +98,9 @@ def mkvalueArgs(self):
"""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)

0 comments on commit a660caf

Please sign in to comment.