Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dcfc202

Browse files
committed
Added some support for Uicode arguments. Still leaves something to be desired, especially because of poor unicode support in PyArg_ParseTuple.
1 parent f147238 commit dcfc202

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

Tools/bgen/bgen/bgenBuffer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,13 @@ def getargsCheck(self, name):
159159

160160
def passInput(self, name):
161161
return "%s__in__, %s__len__" % (name, name)
162-
162+
163+
class ReverseInputBufferMixin:
164+
""" Mixin for input buffers that are passed as (size, buffer) """
165+
166+
def passInput(self, name):
167+
return "%s__len__, %s__in__" % (name, name)
168+
163169
class OptionalVarInputBufferType(OptionalInputBufferMixIn, VarInputBufferType):
164170
pass
165171

Tools/bgen/bgen/bgenType.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class OutputOnlyType(OutputOnlyMixIn, Type):
149149
# For input, this is easy. For output, and for other uses of char *,
150150
# see the module bgenBuffer.
151151
stringptr = InputOnlyType("char*", "s")
152+
unicodestringptr = InputOnlyType("wchar_t *", "u")
152153

153154

154155
# Some Python related types.

Tools/bgen/bgen/macsupport.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
# File System Specifications
4848
FSSpec_ptr = OpaqueType("FSSpec", "PyMac_BuildFSSpec", "PyMac_GetFSSpec")
4949
FSSpec = OpaqueByValueType("FSSpec", "PyMac_BuildFSSpec", "PyMac_GetFSSpec")
50+
FSRef_ptr = OpaqueType("FSRef", "PyMac_BuildFSRef", "PyMac_GetFSRef")
51+
FSRef = OpaqueByValueType("FSRef", "PyMac_BuildFSRef", "PyMac_GetFSRef")
5052

5153
# OSType and ResType: 4-byte character strings
5254
def OSTypeType(typename):
@@ -111,6 +113,19 @@ def errorCheck(self, name):
111113
VarOutBuffer = VarHeapOutputBufferType('char', 'long', 'l') # (buf, &len)
112114
VarVarOutBuffer = VarVarHeapOutputBufferType('char', 'long', 'l') # (buf, len, &len)
113115

116+
# Unicode arguments sometimes have reversed len, buffer (don't understand why Apple did this...)
117+
class VarUnicodeInputBufferType(VarInputBufferType):
118+
119+
def getargsFormat(self):
120+
return "u#"
121+
122+
class VarUnicodeReverseInputBufferType(ReverseInputBufferMixin, VarUnicodeInputBufferType):
123+
pass
124+
125+
UnicodeInBuffer = VarUnicodeInputBufferType('UniChar', 'UniCharCount', 'l')
126+
UnicodeReverseInBuffer = VarUnicodeReverseInputBufferType('UniChar', 'UniCharCount', 'l')
127+
UniChar_ptr = InputOnlyType("UniCharPtr", "u")
128+
114129

115130
# Predefine various pieces of program text to be passed to Module() later:
116131

0 commit comments

Comments
 (0)