]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Tools/bgen/bgen/bgenStringBuffer.py
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
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.)
26 def getSizeDeclarations(self
, name
):
29 def getAuxDeclarations(self
, name
):
32 def getargsFormat(self
):
35 def getargsArgs(self
, name
):
36 return "&%s__in__" % name
38 def mkvalueFormat(self
):
41 def mkvalueArgs(self
, name
):
42 return "%s__out__" % name
45 class FixedOutputStringType(StringBufferMixIn
, FixedOutputBufferType
):
47 """Null-terminated output string -- passed without size.
49 Instantiate with buffer size as parameter.
53 class StackOutputStringType(StringBufferMixIn
, StackOutputBufferType
):
55 """Null-terminated output string -- passed as (buffer, size).
57 Instantiate with buffer size as parameter.
61 class HeapOutputStringType(StringBufferMixIn
, HeapOutputBufferType
):
63 """Null-terminated output string -- passed as (buffer, size).
65 Instantiate without parameters.
66 Call from Python with buffer size.