mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Two patches from Jack Jansen:
Three bgen mods: - support for FSSpecs passed-by-value and points-passed-by-reference added. - strip single-line comments when parsing header files - if a definition is blacklisted _do_ output it, but in comment
This commit is contained in:
parent
6d7e47b8ea
commit
f158887505
2 changed files with 16 additions and 7 deletions
|
@ -15,7 +15,7 @@ SignedByte = Type("SignedByte", "b")
|
||||||
ScriptCode = Type("ScriptCode", "h")
|
ScriptCode = Type("ScriptCode", "h")
|
||||||
Size = Type("Size", "l")
|
Size = Type("Size", "l")
|
||||||
Style = Type("Style", "b")
|
Style = Type("Style", "b")
|
||||||
StyleParameter = Type("StyleParameter", "h")
|
StyleParameter = Type("Style", "h")
|
||||||
CharParameter = Type("CharParameter", "h")
|
CharParameter = Type("CharParameter", "h")
|
||||||
TextEncoding = Type("TextEncoding", "l")
|
TextEncoding = Type("TextEncoding", "l")
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ ConstStr255Param = OpaqueArrayType("Str255", "PyMac_BuildStr255", "PyMac_GetStr2
|
||||||
Str255 = OpaqueArrayType("Str255", "PyMac_BuildStr255", "PyMac_GetStr255")
|
Str255 = OpaqueArrayType("Str255", "PyMac_BuildStr255", "PyMac_GetStr255")
|
||||||
|
|
||||||
# File System Specifications
|
# File System Specifications
|
||||||
FSSpec_ptr = OpaqueType("FSSpec", "PyMac_BuildFSSpec", "PyMac_GetFSSpec")
|
FSSpec = FSSpec_ptr = OpaqueType("FSSpec", "PyMac_BuildFSSpec", "PyMac_GetFSSpec")
|
||||||
|
|
||||||
# OSType and ResType: 4-byte character strings
|
# OSType and ResType: 4-byte character strings
|
||||||
def OSTypeType(typename):
|
def OSTypeType(typename):
|
||||||
|
@ -66,6 +66,7 @@ Fixed = OpaqueByValueType("Fixed", "PyMac_BuildFixed", "PyMac_GetFixed")
|
||||||
# Quickdraw data types
|
# Quickdraw data types
|
||||||
Rect = Rect_ptr = OpaqueType("Rect", "PyMac_BuildRect", "PyMac_GetRect")
|
Rect = Rect_ptr = OpaqueType("Rect", "PyMac_BuildRect", "PyMac_GetRect")
|
||||||
Point = OpaqueByValueType("Point", "PyMac_BuildPoint", "PyMac_GetPoint")
|
Point = OpaqueByValueType("Point", "PyMac_BuildPoint", "PyMac_GetPoint")
|
||||||
|
Point_ptr = OpaqueType("Point", "PyMac_BuildPoint", "PyMac_GetPoint")
|
||||||
|
|
||||||
# Event records
|
# Event records
|
||||||
EventRecord = OpaqueType("EventRecord", "PyMac_BuildEventRecord", "PyMac_GetEventRecord")
|
EventRecord = OpaqueType("EventRecord", "PyMac_BuildEventRecord", "PyMac_GetEventRecord")
|
||||||
|
@ -84,7 +85,6 @@ OSStatus = OSErrType("OSStatus", 'l')
|
||||||
# Various buffer types
|
# Various buffer types
|
||||||
|
|
||||||
InBuffer = VarInputBufferType('char', 'long', 'l') # (buf, len)
|
InBuffer = VarInputBufferType('char', 'long', 'l') # (buf, len)
|
||||||
OptionalInBuffer = OptionalVarInputBufferType('char', 'long', 'l') # (buf, len)
|
|
||||||
|
|
||||||
InOutBuffer = HeapInputOutputBufferType('char', 'long', 'l') # (inbuf, outbuf, len)
|
InOutBuffer = HeapInputOutputBufferType('char', 'long', 'l') # (inbuf, outbuf, len)
|
||||||
VarInOutBuffer = VarHeapInputOutputBufferType('char', 'long', 'l') # (inbuf, outbuf, &len)
|
VarInOutBuffer = VarHeapInputOutputBufferType('char', 'long', 'l') # (inbuf, outbuf, &len)
|
||||||
|
@ -151,9 +151,9 @@ initstuff = """
|
||||||
# This requires that the OSErr type (defined above) has a non-trivial
|
# This requires that the OSErr type (defined above) has a non-trivial
|
||||||
# errorCheck method.
|
# errorCheck method.
|
||||||
class OSErrMixIn:
|
class OSErrMixIn:
|
||||||
"Mix-in class to treat OSErr/OSStatus return values special"
|
"Mix-in class to treat OSErr return values special"
|
||||||
def makereturnvar(self):
|
def makereturnvar(self):
|
||||||
if self.returntype.__class__ == OSErrType:
|
if self.returntype is OSErr:
|
||||||
return Variable(self.returntype, "_err", ErrorMode)
|
return Variable(self.returntype, "_err", ErrorMode)
|
||||||
else:
|
else:
|
||||||
return Variable(self.returntype, "_rv", OutMode)
|
return Variable(self.returntype, "_rv", OutMode)
|
||||||
|
|
|
@ -234,10 +234,13 @@ if missing: raise "Missing Types"
|
||||||
self.args_pat = "(\(<args>\([^(;=)]+\|([^(;=)]*)\)*\))"
|
self.args_pat = "(\(<args>\([^(;=)]+\|([^(;=)]*)\)*\))"
|
||||||
self.whole_pat = self.type_pat + self.name_pat + self.args_pat
|
self.whole_pat = self.type_pat + self.name_pat + self.args_pat
|
||||||
# self.sym_pat = "^[ \t]*\(<name>[a-zA-Z0-9_]+\)[ \t]*=" + \
|
# self.sym_pat = "^[ \t]*\(<name>[a-zA-Z0-9_]+\)[ \t]*=" + \
|
||||||
# "[ \t]*\(<defn>[-0-9'\"][^\t\n,;}]*\),?"
|
# "[ \t]*\(<defn>[-0-9'\"(][^\t\n,;}]*\),?"
|
||||||
self.sym_pat = "^[ \t]*\(<name>[a-zA-Z0-9_]+\)[ \t]*=" + \
|
self.sym_pat = "^[ \t]*\(<name>[a-zA-Z0-9_]+\)[ \t]*=" + \
|
||||||
"[ \t]*\(<defn>[-0-9_a-zA-Z'\"][^\t\n,;}]*\),?"
|
"[ \t]*\(<defn>[-0-9_a-zA-Z'\"(][^\t\n,;}]*\),?"
|
||||||
self.asplit_pat = "^\(<type>.*[^a-zA-Z0-9_]\)\(<name>[a-zA-Z0-9_]+\)$"
|
self.asplit_pat = "^\(<type>.*[^a-zA-Z0-9_]\)\(<name>[a-zA-Z0-9_]+\)$"
|
||||||
|
self.comment1_pat = "\(<rest>.*\)//.*"
|
||||||
|
# note that the next pattern only removes comments that are wholly within one line
|
||||||
|
self.comment2_pat = "\(<rest>.*\)/\*.*\*/"
|
||||||
|
|
||||||
def compilepatterns(self):
|
def compilepatterns(self):
|
||||||
for name in dir(self):
|
for name in dir(self):
|
||||||
|
@ -372,6 +375,10 @@ if missing: raise "Missing Types"
|
||||||
while 1:
|
while 1:
|
||||||
try: line = self.getline()
|
try: line = self.getline()
|
||||||
except EOFError: break
|
except EOFError: break
|
||||||
|
if self.comment1.match(line) >= 0:
|
||||||
|
line = self.comment1.group('rest')
|
||||||
|
if self.comment2.match(line) >= 0:
|
||||||
|
line = self.comment2.group('rest')
|
||||||
if self.defsfile and self.sym.match(line) >= 0:
|
if self.defsfile and self.sym.match(line) >= 0:
|
||||||
self.dosymdef()
|
self.dosymdef()
|
||||||
continue
|
continue
|
||||||
|
@ -386,6 +393,8 @@ if missing: raise "Missing Types"
|
||||||
name, defn = self.sym.group('name', 'defn')
|
name, defn = self.sym.group('name', 'defn')
|
||||||
if not name in self.blacklistnames:
|
if not name in self.blacklistnames:
|
||||||
self.defsfile.write("%s = %s\n" % (name, defn))
|
self.defsfile.write("%s = %s\n" % (name, defn))
|
||||||
|
else:
|
||||||
|
self.defsfile.write("# %s = %s\n" % (name, defn))
|
||||||
|
|
||||||
def dofuncspec(self):
|
def dofuncspec(self):
|
||||||
raw = self.line
|
raw = self.line
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue