summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2005-09-20 21:11:19 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2005-09-20 21:11:19 (GMT)
commit2190f8c47e6383449987b8fd9e87711499dc2a10 (patch)
tree87e12dc611add58b0495cf5eb1b50a46cf465e4e /Tools
parenta2534c86184b9169ec4306af6f7abe8452f2cccb (diff)
downloadcpython-2190f8c47e6383449987b8fd9e87711499dc2a10.zip
cpython-2190f8c47e6383449987b8fd9e87711499dc2a10.tar.gz
cpython-2190f8c47e6383449987b8fd9e87711499dc2a10.tar.bz2
Added a class MallocHeapOutputBufferType for types that are passed
as &buffer, &size and allocated by the called function.
Diffstat (limited to 'Tools')
-rw-r--r--Tools/bgen/bgen/bgenHeapBuffer.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/Tools/bgen/bgen/bgenHeapBuffer.py b/Tools/bgen/bgen/bgenHeapBuffer.py
index 002a260..d677f29 100644
--- a/Tools/bgen/bgen/bgenHeapBuffer.py
+++ b/Tools/bgen/bgen/bgenHeapBuffer.py
@@ -111,3 +111,32 @@ class VarVarHeapOutputBufferType(VarHeapOutputBufferType):
def passOutput(self, name):
return "%s__out__, %s__len__, &%s__len__" % (name, name, name)
+
+class MallocHeapOutputBufferType(HeapOutputBufferType):
+ """Output buffer allocated by the called function -- passed as (&buffer, &size).
+
+ Instantiate without parameters.
+ Call from Python without parameters.
+ """
+
+ def getargsCheck(self, name):
+ Output("%s__out__ = NULL;", name)
+
+ def getAuxDeclarations(self, name):
+ return []
+
+ def passOutput(self, name):
+ return "&%s__out__, &%s__len__" % (name, name)
+
+ def getargsFormat(self):
+ return ""
+
+ def getargsArgs(self, name):
+ return None
+
+ def mkvalueFormat(self):
+ return "z#"
+
+ def cleanup(self, name):
+ Output("if( %s__out__ ) free(%s__out__);", name, name)
+