Apparently the code to forestall Tk eating events was too aggressive (Tk user input...
[python/dscho.git] / Tools / bgen / bgen / bgenStringBuffer.py
blob7d9c77e2967cd7d6ff36e301752cbd6fe7858574
1 """Buffers used to hold null-terminated strings."""
4 from bgenBuffer import FixedOutputBufferType
5 from bgenStackBuffer import StackOutputBufferType
6 from bgenHeapBuffer import HeapOutputBufferType
9 class StringBufferMixIn:
11 """Mix-in class to create various string buffer types.
13 Strings are character arrays terminated by a null byte.
14 (For input, this is also covered by stringptr.)
15 For output, there are again three variants:
16 - Fixed: size is a constant given in the documentation; or
17 - Stack: size is passed to the C function but we decide on a size at
18 code generation time so we can still allocate on the heap); or
19 - Heap: size is passed to the C function and we let the Python caller
20 pass a size.
21 (Note that this doesn't cover output parameters in which a string
22 pointer is returned. These are actually easier (no allocation) but far
23 less common. I'll write the classes when there is demand.)
24 """
26 def declareSize(self, name):
27 pass
29 def getargsFormat(self):
30 return "s"
32 def getargsArgs(self, name):
33 return "&%s__in__" % name
35 def mkvalueFormat(self):
36 return "s"
38 def mkvalueArgs(self, name):
39 return "%s__out__" % name
42 class FixedOutputStringType(StringBufferMixIn, FixedOutputBufferType):
44 """Null-terminated output string -- passed without size.
46 Instantiate with buffer size as parameter.
47 """
50 class StackOutputStringType(StringBufferMixIn, StackOutputBufferType):
52 """Null-terminated output string -- passed as (buffer, size).
54 Instantiate with buffer size as parameter.
55 """
58 class HeapOutputStringType(StringBufferMixIn, HeapOutputBufferType):
60 """Null-terminated output string -- passed as (buffer, size).
62 Instantiate without parameters.
63 Call from Python with buffer size.
64 """