diff options
author | Guido van Rossum <guido@python.org> | 1999-09-30 14:15:14 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-09-30 14:15:14 (GMT) |
commit | fa968ac35b8a3891958d328d4b15a0120179f5a2 (patch) | |
tree | d1c18df8fdb5f60efabb1f8476e9e69d873e5fa6 /Tools | |
parent | 8bd738278ede0e1e74e1bd05b629e380026d7984 (diff) | |
download | cpython-fa968ac35b8a3891958d328d4b15a0120179f5a2.zip cpython-fa968ac35b8a3891958d328d4b15a0120179f5a2.tar.gz cpython-fa968ac35b8a3891958d328d4b15a0120179f5a2.tar.bz2 |
Patches by Jack Jansen: new type OptionalInBuffer allows
passing either a string/input buffer or None.
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/bgen/bgen/bgenBuffer.py | 14 | ||||
-rw-r--r-- | Tools/bgen/bgen/macsupport.py | 1 |
2 files changed, 14 insertions, 1 deletions
diff --git a/Tools/bgen/bgen/bgenBuffer.py b/Tools/bgen/bgen/bgenBuffer.py index af9fb19..9d28b80 100644 --- a/Tools/bgen/bgen/bgenBuffer.py +++ b/Tools/bgen/bgen/bgenBuffer.py @@ -108,6 +108,14 @@ class OutputOnlyBufferMixIn(OutputOnlyMixIn): def declareInputBuffer(self, name): pass +class OptionalInputBufferMixIn: + + """Add to input buffers if the buffer may be omitted: pass None in Python + and the C code will get a NULL pointer and zero size""" + + def getargsFormat(self): + return "z#" + class FixedInputBufferType(InputOnlyBufferMixIn, FixedInputOutputBufferType): @@ -119,6 +127,8 @@ class FixedInputBufferType(InputOnlyBufferMixIn, FixedInputOutputBufferType): def passInput(self, name): return "%s__in__" % name +class OptionalFixedInputBufferType(OptionalInputBufferMixIn, FixedInputBufferType): + pass class FixedOutputBufferType(OutputOnlyBufferMixIn, FixedInputOutputBufferType): @@ -147,7 +157,9 @@ class VarInputBufferType(FixedInputBufferType): def passInput(self, name): return "%s__in__, %s__len__" % (name, name) - +class OptionalVarInputBufferType(OptionalInputBufferMixIn, VarInputBufferType): + pass + # ----- PART 2: Structure buffers ----- diff --git a/Tools/bgen/bgen/macsupport.py b/Tools/bgen/bgen/macsupport.py index 38c9d96..ba2fd8f 100644 --- a/Tools/bgen/bgen/macsupport.py +++ b/Tools/bgen/bgen/macsupport.py @@ -84,6 +84,7 @@ OSStatus = OSErrType("OSStatus", 'l') # Various buffer types InBuffer = VarInputBufferType('char', 'long', 'l') # (buf, len) +OptionalInBuffer = OptionalVarInputBufferType('char', 'long', 'l') # (buf, len) InOutBuffer = HeapInputOutputBufferType('char', 'long', 'l') # (inbuf, outbuf, len) VarInOutBuffer = VarHeapInputOutputBufferType('char', 'long', 'l') # (inbuf, outbuf, &len) |