blob: c846eb00af7b9c5d15a1003cdb021da4bb2c34c3 [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()
19 print "=== Done scanning and generating, now importing the generated code... ==="
20 exec "import " + SHORT + "support"
21 print "=== Done. It's up to you to compile it now! ==="
22
23class MyScanner(Scanner):
24
25 def destination(self, type, name, arglist):
26 classname = "Function"
27 listname = "functions"
28 if arglist:
29 t, n, m = arglist[0]
30 #
31 # FindNextComponent is a special case, since it call also be called
32 # with None as the argument. Hence, we make it a function
33 #
34 if t == "Component" and m == "InMode" and name != "FindNextComponent":
35 classname = "Method"
36 listname = "c_methods"
37 elif t == "ComponentInstance" and m == "InMode":
38 classname = "Method"
39 listname = "ci_methods"
40 return classname, listname
41
Jack Jansen21f96871998-02-20 16:02:09 +000042 def writeinitialdefs(self):
43 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
44
Jack Jansenb9968561995-11-30 15:03:09 +000045 def makeblacklistnames(self):
46 return [
Jack Jansen4a8c54e1997-02-24 13:56:59 +000047 "OpenADefaultComponent",
48 "GetComponentTypeModSeed",
49 "OpenAComponentResFile",
50 "CallComponentUnregister",
51 "CallComponentTarget",
52 "CallComponentRegister",
53 "CallComponentVersion",
54 "CallComponentCanDo",
55 "CallComponentClose",
56 "CallComponentOpen",
57 "OpenAComponent",
Jack Jansenf7d5aa62000-12-10 23:43:49 +000058 "GetComponentPublicResource", # Missing in CW Pro 6
59 "CallComponentGetPublicResource", # Missing in CW Pro 6
Jack Jansenb9968561995-11-30 15:03:09 +000060 ]
61
Jack Jansen8d929ae2000-06-21 22:07:06 +000062 def makegreylist(self):
63 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000064 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansen8d929ae2000-06-21 22:07:06 +000065 'SetComponentInstanceA5',
66 'GetComponentInstanceA5',
67 ])]
68
Jack Jansenb9968561995-11-30 15:03:09 +000069 def makeblacklisttypes(self):
70 return [
71 "ResourceSpec",
72 "ComponentResource",
73 "ComponentPlatformInfo",
74 "ComponentResourceExtension",
75 "ComponentPlatformInfoArray",
76 "ExtComponentResource",
77 "ComponentParameters",
78
79 "ComponentRoutineUPP",
Jack Jansen4a8c54e1997-02-24 13:56:59 +000080 "ComponentMPWorkFunctionUPP",
Jack Jansenf7d5aa62000-12-10 23:43:49 +000081 "ComponentFunctionUPP",
82 "GetMissingComponentResourceUPP",
Jack Jansenb9968561995-11-30 15:03:09 +000083 ]
84
85 def makerepairinstructions(self):
86 return [
87 ([('ComponentDescription', 'looking', 'OutMode')],
88 [('ComponentDescription', '*', 'InMode')]),
89 ]
90
91if __name__ == "__main__":
92 main()