blob: 3e091a6dd86b08758eb077fa3d78f06b5d387449 [file] [log] [blame]
Jack Jansenb9968561995-11-30 15:03:09 +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
Jack Jansen46d9e791996-04-12 16:29:23 +00006from bgenlocations import TOOLBOXDIR
Jack Jansenb9968561995-11-30 15:03:09 +00007
8LONG = "Components"
Jack Jansen21f96871998-02-20 16:02:09 +00009SHORT = "cm"
Jack Jansenb9968561995-11-30 15:03:09 +000010
11def main():
12 input = "Components.h"
13 output = SHORT + "gen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000014 defsoutput = TOOLBOXDIR + LONG + ".py"
Jack Jansenb9968561995-11-30 15:03:09 +000015 scanner = MyScanner(input, output, defsoutput)
16 scanner.scan()
17 scanner.close()
18 print "=== Done scanning and generating, now importing the generated code... ==="
19 exec "import " + SHORT + "support"
20 print "=== Done. It's up to you to compile it now! ==="
21
22class MyScanner(Scanner):
23
24 def destination(self, type, name, arglist):
25 classname = "Function"
26 listname = "functions"
27 if arglist:
28 t, n, m = arglist[0]
29 #
30 # FindNextComponent is a special case, since it call also be called
31 # with None as the argument. Hence, we make it a function
32 #
33 if t == "Component" and m == "InMode" and name != "FindNextComponent":
34 classname = "Method"
35 listname = "c_methods"
36 elif t == "ComponentInstance" and m == "InMode":
37 classname = "Method"
38 listname = "ci_methods"
39 return classname, listname
40
Jack Jansen21f96871998-02-20 16:02:09 +000041 def writeinitialdefs(self):
42 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
43
Jack Jansenb9968561995-11-30 15:03:09 +000044 def makeblacklistnames(self):
45 return [
Jack Jansen4a8c54e1997-02-24 13:56:59 +000046 "OpenADefaultComponent",
47 "GetComponentTypeModSeed",
48 "OpenAComponentResFile",
49 "CallComponentUnregister",
50 "CallComponentTarget",
51 "CallComponentRegister",
52 "CallComponentVersion",
53 "CallComponentCanDo",
54 "CallComponentClose",
55 "CallComponentOpen",
56 "OpenAComponent",
Jack Jansenb9968561995-11-30 15:03:09 +000057 ]
58
59 def makeblacklisttypes(self):
60 return [
61 "ResourceSpec",
62 "ComponentResource",
63 "ComponentPlatformInfo",
64 "ComponentResourceExtension",
65 "ComponentPlatformInfoArray",
66 "ExtComponentResource",
67 "ComponentParameters",
68
69 "ComponentRoutineUPP",
Jack Jansen4a8c54e1997-02-24 13:56:59 +000070 "ComponentMPWorkFunctionUPP",
Jack Jansenb9968561995-11-30 15:03:09 +000071 ]
72
73 def makerepairinstructions(self):
74 return [
75 ([('ComponentDescription', 'looking', 'OutMode')],
76 [('ComponentDescription', '*', 'InMode')]),
77 ]
78
79if __name__ == "__main__":
80 main()