diff options
author | Guido van Rossum <guido@python.org> | 2000-01-20 20:49:28 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-01-20 20:49:28 (GMT) |
commit | f158887505bb9489a44ae6e6aa237b0717bf4210 (patch) | |
tree | d2e82324efa231fc263b6ab7826d1b98747b42d9 | |
parent | 6d7e47b8ea1b8cf82927dacc364689b8eeb8708b (diff) | |
download | cpython-f158887505bb9489a44ae6e6aa237b0717bf4210.zip cpython-f158887505bb9489a44ae6e6aa237b0717bf4210.tar.gz cpython-f158887505bb9489a44ae6e6aa237b0717bf4210.tar.bz2 |
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
-rw-r--r-- | Tools/bgen/bgen/macsupport.py | 10 | ||||
-rw-r--r-- | Tools/bgen/bgen/scantools.py | 13 |
2 files changed, 16 insertions, 7 deletions
diff --git a/Tools/bgen/bgen/macsupport.py b/Tools/bgen/bgen/macsupport.py index ba2fd8f..344f87b 100644 --- a/Tools/bgen/bgen/macsupport.py +++ b/Tools/bgen/bgen/macsupport.py @@ -15,7 +15,7 @@ SignedByte = Type("SignedByte", "b") ScriptCode = Type("ScriptCode", "h") Size = Type("Size", "l") Style = Type("Style", "b") -StyleParameter = Type("StyleParameter", "h") +StyleParameter = Type("Style", "h") CharParameter = Type("CharParameter", "h") TextEncoding = Type("TextEncoding", "l") @@ -31,7 +31,7 @@ ConstStr255Param = OpaqueArrayType("Str255", "PyMac_BuildStr255", "PyMac_GetStr2 Str255 = OpaqueArrayType("Str255", "PyMac_BuildStr255", "PyMac_GetStr255") # 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 def OSTypeType(typename): @@ -66,6 +66,7 @@ Fixed = OpaqueByValueType("Fixed", "PyMac_BuildFixed", "PyMac_GetFixed") # Quickdraw data types Rect = Rect_ptr = OpaqueType("Rect", "PyMac_BuildRect", "PyMac_GetRect") Point = OpaqueByValueType("Point", "PyMac_BuildPoint", "PyMac_GetPoint") +Point_ptr = OpaqueType("Point", "PyMac_BuildPoint", "PyMac_GetPoint") # Event records EventRecord = OpaqueType("EventRecord", "PyMac_BuildEventRecord", "PyMac_GetEventRecord") @@ -84,7 +85,6 @@ OSStatus = OSErrType("OSStatus", 'l') # Various buffer types InBuffer = VarInputBufferType('char', 'long', 'l') # (buf, len) -OptionalInBuffer = OptionalVarInputBufferType('char', 'long', 'l') # (buf, len) InOutBuffer = HeapInputOutputBufferType('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 # errorCheck method. class OSErrMixIn: - "Mix-in class to treat OSErr/OSStatus return values special" + "Mix-in class to treat OSErr return values special" def makereturnvar(self): - if self.returntype.__class__ == OSErrType: + if self.returntype is OSErr: return Variable(self.returntype, "_err", ErrorMode) else: return Variable(self.returntype, "_rv", OutMode) diff --git a/Tools/bgen/bgen/scantools.py b/Tools/bgen/bgen/scantools.py index 80cfd5e..f31996d 100644 --- a/Tools/bgen/bgen/scantools.py +++ b/Tools/bgen/bgen/scantools.py @@ -234,10 +234,13 @@ if missing: raise "Missing Types" self.args_pat = "(\(<args>\([^(;=)]+\|([^(;=)]*)\)*\))" self.whole_pat = self.type_pat + self.name_pat + self.args_pat # 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]*=" + \ - "[ \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.comment1_pat = "\(<rest>.*\)//.*" + # note that the next pattern only removes comments that are wholly within one line + self.comment2_pat = "\(<rest>.*\)/\*.*\*/" def compilepatterns(self): for name in dir(self): @@ -372,6 +375,10 @@ if missing: raise "Missing Types" while 1: try: line = self.getline() 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: self.dosymdef() continue @@ -386,6 +393,8 @@ if missing: raise "Missing Types" name, defn = self.sym.group('name', 'defn') if not name in self.blacklistnames: self.defsfile.write("%s = %s\n" % (name, defn)) + else: + self.defsfile.write("# %s = %s\n" % (name, defn)) def dofuncspec(self): raw = self.line |