]> git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Tools/bgen/bgen/bgenStringBuffer.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Tools / bgen / bgen / bgenStringBuffer.py
1 """Buffers used to hold null-terminated strings."""
2
3
4 from bgenBuffer import FixedOutputBufferType
5 from bgenStackBuffer import StackOutputBufferType
6 from bgenHeapBuffer import HeapOutputBufferType
7
8
9 class StringBufferMixIn:
10
11 """Mix-in class to create various string buffer types.
12
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 """
25
26 def getSizeDeclarations(self, name):
27 return []
28
29 def getAuxDeclarations(self, name):
30 return []
31
32 def getargsFormat(self):
33 return "s"
34
35 def getargsArgs(self, name):
36 return "&%s__in__" % name
37
38 def mkvalueFormat(self):
39 return "s"
40
41 def mkvalueArgs(self, name):
42 return "%s__out__" % name
43
44
45 class FixedOutputStringType(StringBufferMixIn, FixedOutputBufferType):
46
47 """Null-terminated output string -- passed without size.
48
49 Instantiate with buffer size as parameter.
50 """
51
52
53 class StackOutputStringType(StringBufferMixIn, StackOutputBufferType):
54
55 """Null-terminated output string -- passed as (buffer, size).
56
57 Instantiate with buffer size as parameter.
58 """
59
60
61 class HeapOutputStringType(StringBufferMixIn, HeapOutputBufferType):
62
63 """Null-terminated output string -- passed as (buffer, size).
64
65 Instantiate without parameters.
66 Call from Python with buffer size.
67 """