summaryrefslogtreecommitdiffstats
path: root/Tools/bgen
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-02-23 15:30:44 (GMT)
committerGuido van Rossum <guido@python.org>1998-02-23 15:30:44 (GMT)
commit557f44661899fc3fdc276db8079df07b7f2cdb7e (patch)
tree5db275d3dd2bda6b04c0701cf15c18b1f37e2fa4 /Tools/bgen
parenta705da7aa01fb8bc4fa5b6582079bd226e972acc (diff)
downloadcpython-557f44661899fc3fdc276db8079df07b7f2cdb7e.zip
cpython-557f44661899fc3fdc276db8079df07b7f2cdb7e.tar.gz
cpython-557f44661899fc3fdc276db8079df07b7f2cdb7e.tar.bz2
Patches from Jack for new Apple headers
Diffstat (limited to 'Tools/bgen')
-rw-r--r--Tools/bgen/bgen/bgenlocations.py4
-rw-r--r--Tools/bgen/bgen/macsupport.py4
-rw-r--r--Tools/bgen/bgen/scantools.py34
3 files changed, 36 insertions, 6 deletions
diff --git a/Tools/bgen/bgen/bgenlocations.py b/Tools/bgen/bgen/bgenlocations.py
index 1b6b31d..56d9e6e 100644
--- a/Tools/bgen/bgen/bgenlocations.py
+++ b/Tools/bgen/bgen/bgenlocations.py
@@ -3,11 +3,11 @@
#
# Where to find the Universal Header include files:
-MWERKSDIR="Moes:Metrowerks:Metrowerks CodeWarrior:"
+MWERKSDIR="flap:Metrowerks:Metrowerks CodeWarrior:"
INCLUDEDIR=MWERKSDIR + "MacOS Support:Headers:Universal Headers:"
# Where to put the python definitions file:
-TOOLBOXDIR="Moes:Development:Jack:Python:Mac:Lib:toolbox:"
+TOOLBOXDIR="flap:Jack:Python:Mac:Lib:lib-toolbox:"
# Creator for C files:
CREATOR="CWIE"
diff --git a/Tools/bgen/bgen/macsupport.py b/Tools/bgen/bgen/macsupport.py
index f8570e4..4c84dbf 100644
--- a/Tools/bgen/bgen/macsupport.py
+++ b/Tools/bgen/bgen/macsupport.py
@@ -15,6 +15,9 @@ SignedByte = Type("SignedByte", "b")
ScriptCode = Type("ScriptCode", "h")
Size = Type("Size", "l")
Style = Type("Style", "b")
+StyleParameter = Type("Style", "h")
+CharParameter = Type("CharParameter", "h")
+TextEncoding = Type("TextEncoding", "l")
UInt8 = Type("UInt8", "b")
SInt8 = Type("SInt8", "b")
@@ -75,6 +78,7 @@ class OSErrType(Type):
Output("if (%s != noErr) return PyMac_Error(%s);", name, name)
self.used = 1
OSErr = OSErrType("OSErr", 'h')
+OSStatus = OSErrType("OSStatus", 'l')
# Various buffer types
diff --git a/Tools/bgen/bgen/scantools.py b/Tools/bgen/bgen/scantools.py
index 5800681..851a4d0 100644
--- a/Tools/bgen/bgen/scantools.py
+++ b/Tools/bgen/bgen/scantools.py
@@ -93,6 +93,9 @@ if missing: raise "Missing Types"
if not self.silent:
print format%args
+ def writeinitialdefs(self):
+ pass
+
def initblacklists(self):
self.blacklistnames = self.makeblacklistnames()
self.blacklisttypes = ["unknown", "-"] + self.makeblacklisttypes()
@@ -219,14 +222,21 @@ if missing: raise "Missing Types"
self.includepath = [':', INCLUDEDIR]
def initpatterns(self):
- self.head_pat = "^extern pascal[ \t]+" # XXX Mac specific!
+# self.head_pat = "^extern pascal[ \t]+" # XXX Mac specific!
+ self.head_pat = "^EXTERN_API[^_]"
self.tail_pat = "[;={}]"
- self.type_pat = "pascal[ \t\n]+\(<type>[a-zA-Z0-9_ \t]*[a-zA-Z0-9_]\)[ \t\n]+"
+# self.type_pat = "pascal[ \t\n]+\(<type>[a-zA-Z0-9_ \t]*[a-zA-Z0-9_]\)[ \t\n]+"
+ self.type_pat = "EXTERN_API" + \
+ "[ \t\n]*([ \t\n]*" + \
+ "\(<type>[a-zA-Z0-9_ \t]*[a-zA-Z0-9_]\)" + \
+ "[ \t\n]*)[ \t\n]*"
self.name_pat = "\(<name>[a-zA-Z0-9_]+\)[ \t\n]*"
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,;}]*\),?"
self.sym_pat = "^[ \t]*\(<name>[a-zA-Z0-9_]+\)[ \t]*=" + \
- "[ \t]*\(<defn>[-0-9'\"][^\t\n,;}]*\),?"
+ "[ \t]*\(<defn>[-0-9_a-zA-Z'\"][^\t\n,;}]*\),?"
self.asplit_pat = "^\(<type>.*[^a-zA-Z0-9_]\)\(<name>[a-zA-Z0-9_]+\)$"
def compilepatterns(self):
@@ -356,6 +366,7 @@ if missing: raise "Missing Types"
else:
self.report("defsfile = %s", `self.defsfile.name`)
self.defsfile.write("# Generated from %s\n\n" % `inputname`)
+ self.writeinitialdefs()
self.alreadydone = []
try:
while 1:
@@ -373,7 +384,8 @@ if missing: raise "Missing Types"
def dosymdef(self):
name, defn = self.sym.group('name', 'defn')
- self.defsfile.write("%s = %s\n" % (name, defn))
+ if not name in self.blacklistnames:
+ self.defsfile.write("%s = %s\n" % (name, defn))
def dofuncspec(self):
raw = self.line
@@ -519,6 +531,20 @@ if missing: raise "Missing Types"
return 1
return 0
+class Scanner_PreUH3(Scanner):
+ """Scanner for Universal Headers before release 3"""
+ def initpatterns(self):
+ self.head_pat = "^extern pascal[ \t]+" # XXX Mac specific!
+ self.tail_pat = "[;={}]"
+ self.type_pat = "pascal[ \t\n]+\(<type>[a-zA-Z0-9_ \t]*[a-zA-Z0-9_]\)[ \t\n]+"
+ self.name_pat = "\(<name>[a-zA-Z0-9_]+\)[ \t\n]*"
+ 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,;}]*\),?"
+ self.asplit_pat = "^\(<type>.*[^a-zA-Z0-9_]\)\(<name>[a-zA-Z0-9_]+\)$"
+
+
def test():
input = "D:Development:THINK C:Mac #includes:Apple #includes:AppleEvents.h"
output = "@aespecs.py"