blob: 376ca4c10a147fb8f43ee6f586f5c2dee191f717 [file] [log] [blame]
Jack Jansen90ecdf41996-04-16 14:29:15 +00001# Scan an Apple header file, generating a Python file of generator calls.
2
3import addpack
4addpack.addpack(':tools:bgen:bgen')
5from scantools import Scanner
6from bgenlocations import TOOLBOXDIR
7
8WASTEDIR=":::::Waste 1.2a5:"
9
10OBJECT = "TEHandle"
11SHORT = "waste"
12OBJECT = "WEReference"
13OBJECT2 = "WEObjectReference"
14
15def main():
16 input = WASTEDIR + "WASTE C/C++ Headers:WASTE.h"
17 output = SHORT + "gen.py"
18 defsoutput = TOOLBOXDIR + "WASTEconst.py"
19 scanner = MyScanner(input, output, defsoutput)
20 scanner.scan()
Jack Jansen8ae8e4f1996-04-23 16:17:08 +000021## scanner.gentypetest(SHORT+"typetest.py")
Jack Jansen90ecdf41996-04-16 14:29:15 +000022 scanner.close()
23 print "=== Done scanning and generating, now importing the generated code... ==="
24 exec "import " + SHORT + "support"
25 print "=== Done. It's up to you to compile it now! ==="
26
27class MyScanner(Scanner):
28
29 def initpatterns(self):
30 # Waste doesn't use 'extern':
31 Scanner.initpatterns(self)
32 self.head_pat = "^pascal[ \t]+"
33
34 def destination(self, type, name, arglist):
35 classname = "Function"
36 listname = "functions"
37 if arglist:
38 t, n, m = arglist[-1]
39 # This is non-functional today
40 if t == OBJECT and m == "InMode":
41 classname = "Method"
42 listname = "methods"
43 else:
44 t, n, m = arglist[0]
45 if t == OBJECT2 and m == "InMode":
46 classname = "Method2"
47 listname = "methods2"
48 return classname, listname
49
50 def makeblacklistnames(self):
51 return [
52 "WEDispose",
53 "WESetInfo", # Argument type unknown...
54 "WEGetInfo",
Jack Jansen90ecdf41996-04-16 14:29:15 +000055 ]
56
57 def makeblacklisttypes(self):
58 return [
59 "DragReference", # For now...
60 "UniversalProcPtr",
61 ]
62
63 def makerepairinstructions(self):
64 return [
65 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
66 [("InBuffer", "*", "*")]),
67
68 # WEContinuousStyle
Jack Jansen8ae8e4f1996-04-23 16:17:08 +000069 ([("WEStyleMode", "mode", "OutMode"), ("TextStyle", "ts", "OutMode")],
70 [("WEStyleMode", "mode", "InOutMode"), ("TextStyle", "ts", "OutMode")]),
71
72 # WECopyRange
73 ([('Handle', 'hText', 'InMode'), ('StScrpHandle', 'hStyles', 'InMode'),
74 ('WESoupHandle', 'hSoup', 'InMode')],
75 [('OptHandle', 'hText', 'InMode'), ('OptStScrpHandle', 'hStyles', 'InMode'),
76 ('OptSoupHandle', 'hSoup', 'InMode')]),
77
78 # WEInsert
79 ([('StScrpHandle', 'hStyles', 'InMode'), ('WESoupHandle', 'hSoup', 'InMode')],
Jack Jansen756522f1996-05-07 15:24:01 +000080 [('OptStScrpHandle', 'hStyles', 'InMode'), ('OptSoupHandle', 'hSoup', 'InMode')]),
81
82 # WEGetObjectOwner
83 ("WEGetObjectOwner",
84 [('WEReference', '*', 'ReturnMode')],
85 [('ExistingWEReference', '*', 'ReturnMode')])
Jack Jansen8ae8e4f1996-04-23 16:17:08 +000086
Jack Jansen90ecdf41996-04-16 14:29:15 +000087 ]
88
89if __name__ == "__main__":
90 main()