From: Jack Jansen Date: Tue, 20 Sep 2005 21:11:19 +0000 (+0000) Subject: Added a class MallocHeapOutputBufferType for types that are passed X-Git-Tag: v2.5a0~1348 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2190f8c47e6383449987b8fd9e87711499dc2a10;p=thirdparty%2FPython%2Fcpython.git Added a class MallocHeapOutputBufferType for types that are passed as &buffer, &size and allocated by the called function. --- diff --git a/Tools/bgen/bgen/bgenHeapBuffer.py b/Tools/bgen/bgen/bgenHeapBuffer.py index 002a2606f6e4..d677f291848c 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) +