diff options
author | Guido van Rossum <guido@python.org> | 1995-03-10 14:42:57 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-03-10 14:42:57 (GMT) |
commit | 227a4232e6580891d3ee74b25888685a3c436fe2 (patch) | |
tree | 91b47c2e4b16996cb95836cb5223a87474c1992b /Tools | |
parent | fc8a01fc5a2890b24ca044f3d00a5139a13e40b2 (diff) | |
download | cpython-227a4232e6580891d3ee74b25888685a3c436fe2.zip cpython-227a4232e6580891d3ee74b25888685a3c436fe2.tar.gz cpython-227a4232e6580891d3ee74b25888685a3c436fe2.tar.bz2 |
the usual
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/bgen/bgen/bgenBuffer.py | 24 | ||||
-rw-r--r-- | Tools/bgen/bgen/bgenHeapBuffer.py | 12 | ||||
-rw-r--r-- | Tools/bgen/bgen/bgenStackBuffer.py | 4 |
3 files changed, 26 insertions, 14 deletions
diff --git a/Tools/bgen/bgen/bgenBuffer.py b/Tools/bgen/bgen/bgenBuffer.py index 925b937..46f3db4 100644 --- a/Tools/bgen/bgen/bgenBuffer.py +++ b/Tools/bgen/bgen/bgenBuffer.py @@ -53,21 +53,22 @@ class FixedInputOutputBufferType(InputOnlyType): def declareSize(self, name): Output("%s %s__len__;", self.sizetype, name) + Output("int %s__in_len__;", name) def getargsFormat(self): - # XXX This only works if the size is int-sized!!! return "s#" def getargsArgs(self, name): - return "&%s__in__, &%s__len__" % (name, name) + return "&%s__in__, &%s__in_len__" % (name, name) def getargsCheck(self, name): - Output("if (%s__len__ != %s)", name, self.size) + Output("if (%s__in_len__ != %s)", name, self.size) OutLbrace() Output('PyErr_SetString(PyExc_TypeError, "buffer length should be %s");', self.size) Output("goto %s__error__;", name) OutRbrace() + Output("%s__len__ = %s__in_len__;", name, name) def passOutput(self, name): return "%s__in__, %s__out__" % (name, name) @@ -76,7 +77,7 @@ class FixedInputOutputBufferType(InputOnlyType): return "s#" def mkvalueArgs(self, name): - return "%s__out__, %s" % (name, self.size) + return "%s__out__, (int)%s" % (name, self.size) def cleanup(self, name): DedentLevel() @@ -138,7 +139,7 @@ class VarInputBufferType(FixedInputBufferType): FixedInputBufferType.__init__(self, "0", datatype, sizetype, sizeformat) def getargsCheck(self, name): - pass + Output("%s__len__ = %s__in_len__;", name, name) def passInput(self, name): return "%s__in__, %s__len__" % (name, name) @@ -161,11 +162,14 @@ class StructInputOutputBufferType(FixedInputOutputBufferType): def declareInputBuffer(self, name): Output("%s *%s__in__;", self.type, name) + def declareSize(self, name): + Output("int %s__in_len__;", name) + def declareOutputBuffer(self, name): Output("%s %s__out__;", self.type, name) def getargsArgs(self, name): - return "(char **)&%s__in__, &%s__len__" % (name, name) + return "(char **)&%s__in__, &%s__in_len__" % (name, name) def passInput(self, name): return "%s__in__" % name @@ -174,7 +178,7 @@ class StructInputOutputBufferType(FixedInputOutputBufferType): return "%s__in__, &%s__out__" % (name, name) def mkvalueArgs(self, name): - return "(char *)&%s__out__, %s" % (name, self.size) + return "(char *)&%s__out__, (int)%s" % (name, self.size) class StructCombinedInputOutputBufferType(StructInputOutputBufferType): @@ -211,6 +215,9 @@ class StructOutputBufferType(OutputOnlyBufferMixIn, StructInputOutputBufferType) Instantiate with the struct type as parameter. """ + + def declareSize(self, name): + pass def passOutput(self, name): return "&%s__out__" % name @@ -222,6 +229,9 @@ class ArrayOutputBufferType(OutputOnlyBufferMixIn, StructInputOutputBufferType): Instantiate with the struct type as parameter. """ + + def declareSize(self, name): + pass def passOutput(self, name): return "%s__out__" % name diff --git a/Tools/bgen/bgen/bgenHeapBuffer.py b/Tools/bgen/bgen/bgenHeapBuffer.py index 2c51695..c6160ba 100644 --- a/Tools/bgen/bgen/bgenHeapBuffer.py +++ b/Tools/bgen/bgen/bgenHeapBuffer.py @@ -20,17 +20,19 @@ class HeapInputOutputBufferType(FixedInputOutputBufferType): Output("%s *%s__out__;", self.datatype, name) def getargsCheck(self, name): - Output("if ((%s__out__ = malloc(%s__len__)) == NULL)", name, name) + Output("if ((%s__out__ = malloc(%s__in_len__)) == NULL)", name, name) OutLbrace() Output('PyErr_NoMemory();') Output("goto %s__error__;", name) OutRbrace() + Output("%s__len__ = %s__in_len__;", name, name) def passOutput(self, name): - return "%s__in__, %s__out__, %s__len__" % (name, name, name) + return "%s__in__, %s__out__, (%s)%s__len__" % \ + (name, name, self.sizetype, name) def mkvalueArgs(self, name): - return "%s__out__, %s__len__" % (name, name) + return "%s__out__, (int)%s__len__" % (name, name) def cleanup(self, name): Output("free(%s__out__);", name) @@ -75,10 +77,10 @@ class HeapOutputBufferType(OutputOnlyMixIn, HeapInputOutputBufferType): pass def getargsFormat(self): - return self.sizeformat + return "i" def getargsArgs(self, name): - return "&%s__len__" % name + return "&%s__in_len__" % name def passOutput(self, name): return "%s__out__, %s__len__" % (name, name) diff --git a/Tools/bgen/bgen/bgenStackBuffer.py b/Tools/bgen/bgen/bgenStackBuffer.py index b7df5bd..1b6350a 100644 --- a/Tools/bgen/bgen/bgenStackBuffer.py +++ b/Tools/bgen/bgen/bgenStackBuffer.py @@ -29,7 +29,7 @@ class VarStackOutputBufferType(StackOutputBufferType): return "%s__out__, &%s__len__" % (name, name) def mkvalueArgs(self, name): - return "%s__out__, %s__len__" % (name, name) + return "%s__out__, (int)%s__len__" % (name, name) class VarVarStackOutputBufferType(VarStackOutputBufferType): @@ -56,4 +56,4 @@ class ReturnVarStackOutputBufferType(VarStackOutputBufferType): return "%s__out__, %s__len__" % (name, name) def mkvalueArgs(self, name): - return "%s__out__, _rv" % name + return "%s__out__, (int)_rv" % name |