self.sizeformat = sizeformat or type2format[sizetype]
self.label_needed = 0
- def getArgDeclarations(self, name, reference=False, constmode=False):
+ def getArgDeclarations(self, name, reference=False, constmode=False, outmode=False):
if reference:
raise RuntimeError, "Cannot pass buffer types by reference"
return (self.getBufferDeclarations(name, constmode) +
- self.getSizeDeclarations(name))
+ self.getSizeDeclarations(name, outmode))
- def getBufferDeclarations(self, name, constmode=False):
+ def getBufferDeclarations(self, name, constmode=False, outmode=False):
return self.getInputBufferDeclarations(name, constmode) + \
- self.getOutputBufferDeclarations(name, constmode)
+ self.getOutputBufferDeclarations(name, constmode, outmode)
def getInputBufferDeclarations(self, name, constmode=False):
if constmode:
const = ""
return ["%s%s *%s__in__" % (const, self.datatype, name)]
- def getOutputBufferDeclarations(self, name, constmode=False):
+ def getOutputBufferDeclarations(self, name, constmode=False, outmode=False):
if constmode:
raise RuntimeError, "Cannot use const output buffer"
- return ["%s %s__out__[%s]" % (self.datatype, name, self.size)]
+ if outmode:
+ out = "*"
+ else:
+ out = ""
+ return ["%s%s %s__out__[%s]" % (self.datatype, out, name, self.size)]
- def getSizeDeclarations(self, name):
- return ["%s %s__len__" %(self.sizetype, name)]
+ def getSizeDeclarations(self, name, outmode=False):
+ if outmode:
+ out = "*"
+ else:
+ out = ""
+ return ["%s%s %s__len__" %(self.sizetype, out, name)]
def getAuxDeclarations(self, name):
return ["int %s__in_len__" %(name)]
class InputOnlyBufferMixIn(InputOnlyMixIn):
- def getOutputBufferDeclarations(self, name, constmode=False):
+ def getOutputBufferDeclarations(self, name, constmode=False, outmode=False):
return []
const = ""
return ["%s%s *%s__in__" % (const, self.type, name)]
- def getSizeDeclarations(self, name):
+ def getSizeDeclarations(self, name, outmode=False):
return []
def getAuxDeclarations(self, name):
return ["int %s__in_len__" % (name)]
- def getOutputBufferDeclarations(self, name, constmode=False):
+ def getOutputBufferDeclarations(self, name, constmode=False, outmode=False):
if constmode:
raise RuntimeError, "Cannot use const output buffer"
- return ["%s %s__out__" % (self.type, name)]
+ if outmode:
+ out = "*"
+ else:
+ out = ""
+ return ["%s%s %s__out__" % (self.type, out, name)]
def getargsArgs(self, name):
return "(char **)&%s__in__, &%s__in_len__" % (name, name)
Instantiate with the struct type as parameter.
"""
- def getSizeDeclarations(self, name):
+ def getSizeDeclarations(self, name, outmode=False):
return []
def getAuxDeclarations(self, name):
Instantiate with the struct type as parameter.
"""
- def getSizeDeclarations(self, name):
+ def getSizeDeclarations(self, name, outmode=False):
return []
def getAuxDeclarations(self, name):
def __init__(self, datatype = 'char', sizetype = 'int', sizeformat = None):
FixedInputOutputBufferType.__init__(self, "0", datatype, sizetype, sizeformat)
- def getOutputBufferDeclarations(self, name, constmode=False):
+ def getOutputBufferDeclarations(self, name, constmode=False, outmode=False):
if constmode:
raise RuntimeError, "Cannot use const output buffer"
- return ["%s *%s__out__" % (self.datatype, name)]
+ if outmode:
+ out = "*"
+ else:
+ out = ""
+ return ["%s%s *%s__out__" % (self.datatype, out, name)]
def getargsCheck(self, name):
Output("if ((%s__out__ = malloc(%s__in_len__)) == NULL)", name, name)
for decl in self.getAuxDeclarations(name):
Output("%s;", decl)
- def getArgDeclarations(self, name, reference=False, constmode=False):
+ def getArgDeclarations(self, name, reference=False, constmode=False, outmode=False):
"""Return the main part of the declarations for this type: the items
that will be passed as arguments in the C/C++ function call."""
if reference:
const = "const "
else:
const = ""
- return ["%s%s%s %s" % (const, self.typeName, ref, name)]
+ if outmode:
+ out = "*"
+ else:
+ out = ""
+ return ["%s%s%s%s %s" % (const, self.typeName, ref, out, name)]
def getAuxDeclarations(self, name):
"""Return any auxiliary declarations needed for implementing this
self.substitute = substitute
self.typeName = None # Don't show this argument in __doc__ string
- def getArgDeclarations(self, name, reference=False, constmode=False):
+ def getArgDeclarations(self, name, reference=False, constmode=False, outmode=False):
return []
def getAuxDeclarations(self, name, reference=False):