blob: 7ca15f24fb17ffbf509444977917c17ba321eceb [file] [log] [blame]
Jack Jansenb9968561995-11-30 15:03:09 +00001# Scan an Apple header file, generating a Python file of generator calls.
2
Jack Jansen0c4d9471998-04-17 14:07:56 +00003import sys
4import os
Jack Jansenaaebdd62002-08-05 15:39:30 +00005from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen0c4d9471998-04-17 14:07:56 +00006sys.path.append(BGENDIR)
Jack Jansenb9968561995-11-30 15:03:09 +00007from scantools import Scanner
8
9LONG = "Components"
Jack Jansen21f96871998-02-20 16:02:09 +000010SHORT = "cm"
Jack Jansenb9968561995-11-30 15:03:09 +000011
12def main():
13 input = "Components.h"
14 output = SHORT + "gen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000015 defsoutput = TOOLBOXDIR + LONG + ".py"
Jack Jansenb9968561995-11-30 15:03:09 +000016 scanner = MyScanner(input, output, defsoutput)
17 scanner.scan()
18 scanner.close()
Jack Jansen87eea882002-08-15 21:48:16 +000019 print "=== Testing definitions output code ==="
20 execfile(defsoutput, {}, {})
Jack Jansenb9968561995-11-30 15:03:09 +000021 print "=== Done scanning and generating, now importing the generated code... ==="
22 exec "import " + SHORT + "support"
23 print "=== Done. It's up to you to compile it now! ==="
24
25class MyScanner(Scanner):
26
27 def destination(self, type, name, arglist):
28 classname = "Function"
29 listname = "functions"
30 if arglist:
31 t, n, m = arglist[0]
32 #
33 # FindNextComponent is a special case, since it call also be called
34 # with None as the argument. Hence, we make it a function
35 #
36 if t == "Component" and m == "InMode" and name != "FindNextComponent":
37 classname = "Method"
38 listname = "c_methods"
39 elif t == "ComponentInstance" and m == "InMode":
40 classname = "Method"
41 listname = "ci_methods"
42 return classname, listname
43
Jack Jansen21f96871998-02-20 16:02:09 +000044 def writeinitialdefs(self):
45 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
46
Jack Jansenb9968561995-11-30 15:03:09 +000047 def makeblacklistnames(self):
48 return [
Jack Jansen4a8c54e1997-02-24 13:56:59 +000049 "OpenADefaultComponent",
50 "GetComponentTypeModSeed",
51 "OpenAComponentResFile",
52 "CallComponentUnregister",
53 "CallComponentTarget",
54 "CallComponentRegister",
55 "CallComponentVersion",
56 "CallComponentCanDo",
57 "CallComponentClose",
58 "CallComponentOpen",
59 "OpenAComponent",
Jack Jansenf7d5aa62000-12-10 23:43:49 +000060 "GetComponentPublicResource", # Missing in CW Pro 6
61 "CallComponentGetPublicResource", # Missing in CW Pro 6
Jack Jansenb9968561995-11-30 15:03:09 +000062 ]
63
Jack Jansen8d929ae2000-06-21 22:07:06 +000064 def makegreylist(self):
65 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000066 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansen8d929ae2000-06-21 22:07:06 +000067 'SetComponentInstanceA5',
68 'GetComponentInstanceA5',
69 ])]
70
Jack Jansenb9968561995-11-30 15:03:09 +000071 def makeblacklisttypes(self):
72 return [
73 "ResourceSpec",
74 "ComponentResource",
75 "ComponentPlatformInfo",
76 "ComponentResourceExtension",
77 "ComponentPlatformInfoArray",
78 "ExtComponentResource",
79 "ComponentParameters",
80
81 "ComponentRoutineUPP",
Jack Jansen4a8c54e1997-02-24 13:56:59 +000082 "ComponentMPWorkFunctionUPP",
Jack Jansenf7d5aa62000-12-10 23:43:49 +000083 "ComponentFunctionUPP",
84 "GetMissingComponentResourceUPP",
Jack Jansenb9968561995-11-30 15:03:09 +000085 ]
86
87 def makerepairinstructions(self):
88 return [
89 ([('ComponentDescription', 'looking', 'OutMode')],
90 [('ComponentDescription', '*', 'InMode')]),
91 ]
92
93if __name__ == "__main__":
94 main()