Another batch of updates...
[python/dscho.git] / Mac / Modules / waste / wastescan.py
blobadd9364fe55752093d9dc8b1b8dfdb939cef781d
1 # Scan an Apple header file, generating a Python file of generator calls.
3 import addpack
4 addpack.addpack(':tools:bgen:bgen')
5 from scantools import Scanner
6 from bgenlocations import TOOLBOXDIR
8 WASTEDIR=":::::Waste 1.2 distribution:"
10 OBJECT = "TEHandle"
11 SHORT = "waste"
12 OBJECT = "WEReference"
13 OBJECT2 = "WEObjectReference"
15 def 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()
21 ## scanner.gentypetest(SHORT+"typetest.py")
22 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! ==="
27 class MyScanner(Scanner):
29 def destination(self, type, name, arglist):
30 classname = "Function"
31 listname = "functions"
32 if arglist:
33 t, n, m = arglist[-1]
34 # This is non-functional today
35 if t == OBJECT and m == "InMode":
36 classname = "Method"
37 listname = "methods"
38 else:
39 t, n, m = arglist[0]
40 if t == OBJECT2 and m == "InMode":
41 classname = "Method2"
42 listname = "methods2"
43 return classname, listname
45 def makeblacklistnames(self):
46 return [
47 "WEDispose",
48 "WESetInfo", # Argument type unknown...
49 "WEGetInfo",
50 "WEVersion", # Unfortunately...
53 def makeblacklisttypes(self):
54 return [
55 "DragReference", # For now...
56 "UniversalProcPtr",
59 def makerepairinstructions(self):
60 return [
61 ([("void_ptr", "*", "InMode"), ("SInt32", "*", "InMode")],
62 [("InBuffer", "*", "*")]),
64 # WEContinuousStyle
65 ([("WEStyleMode", "mode", "OutMode"), ("TextStyle", "ts", "OutMode")],
66 [("WEStyleMode", "mode", "InOutMode"), ("TextStyle", "ts", "OutMode")]),
68 # WECopyRange
69 ([('Handle', 'hText', 'InMode'), ('StScrpHandle', 'hStyles', 'InMode'),
70 ('WESoupHandle', 'hSoup', 'InMode')],
71 [('OptHandle', 'hText', 'InMode'), ('OptStScrpHandle', 'hStyles', 'InMode'),
72 ('OptSoupHandle', 'hSoup', 'InMode')]),
74 # WEInsert
75 ([('StScrpHandle', 'hStyles', 'InMode'), ('WESoupHandle', 'hSoup', 'InMode')],
76 [('OptStScrpHandle', 'hStyles', 'InMode'), ('OptSoupHandle', 'hSoup', 'InMode')]),
78 # WEGetObjectOwner
79 ("WEGetObjectOwner",
80 [('WEReference', '*', 'ReturnMode')],
81 [('ExistingWEReference', '*', 'ReturnMode')])
85 if __name__ == "__main__":
86 main()