]> granicus.if.org Git - python/commitdiff
Two patches from Jack Jansen:
authorGuido van Rossum <guido@python.org>
Thu, 20 Jan 2000 20:49:28 +0000 (20:49 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 20 Jan 2000 20:49:28 +0000 (20:49 +0000)
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

Tools/bgen/bgen/macsupport.py
Tools/bgen/bgen/scantools.py

index ba2fd8fa1805cce8c74b3fd3984c2b43e184a70c..344f87b0158b3ad7a5db51619fb09822469d1b9c 100644 (file)
@@ -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)
index 80cfd5e009cf2e5b38003a45b26596c8dce44821..f31996d954f7f0485ce00f47f6604a313fa10b91 100644 (file)
@@ -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