blob: 73261f58b28e32de4a9d46ccdfd717d103187799 [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
Jack Jansenaaebdd62002-08-05 15:39:30 +00004from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen0c4d9471998-04-17 14:07:56 +00005sys.path.append(BGENDIR)
Jack Jansenb9968561995-11-30 15:03:09 +00006from scantools import Scanner
7
8LONG = "Components"
Jack Jansen21f96871998-02-20 16:02:09 +00009SHORT = "cm"
Jack Jansenb9968561995-11-30 15:03:09 +000010
11def main():
Tim Peters182b5ac2004-07-18 06:16:08 +000012 input = "Components.h"
13 output = SHORT + "gen.py"
14 defsoutput = TOOLBOXDIR + LONG + ".py"
15 scanner = MyScanner(input, output, defsoutput)
16 scanner.scan()
17 scanner.close()
18 print "=== Testing definitions output code ==="
19 execfile(defsoutput, {}, {})
20 print "=== Done scanning and generating, now importing the generated code... ==="
21 exec "import " + SHORT + "support"
22 print "=== Done. It's up to you to compile it now! ==="
Jack Jansenb9968561995-11-30 15:03:09 +000023
24class MyScanner(Scanner):
25
Tim Peters182b5ac2004-07-18 06:16:08 +000026 def destination(self, type, name, arglist):
27 classname = "Function"
28 listname = "functions"
29 if arglist:
30 t, n, m = arglist[0]
31 #
32 # FindNextComponent is a special case, since it call also be called
33 # with None as the argument. Hence, we make it a function
34 #
35 if t == "Component" and m == "InMode" and name != "FindNextComponent":
36 classname = "Method"
37 listname = "c_methods"
38 elif t == "ComponentInstance" and m == "InMode":
39 classname = "Method"
40 listname = "ci_methods"
41 return classname, listname
Jack Jansenb9968561995-11-30 15:03:09 +000042
Tim Peters182b5ac2004-07-18 06:16:08 +000043 def writeinitialdefs(self):
44 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
Jack Jansen21f96871998-02-20 16:02:09 +000045
Tim Peters182b5ac2004-07-18 06:16:08 +000046 def makeblacklistnames(self):
47 return [
48 "OpenADefaultComponent",
49 "GetComponentTypeModSeed",
50 "OpenAComponentResFile",
51 "CallComponentUnregister",
52 "CallComponentTarget",
53 "CallComponentRegister",
54 "CallComponentVersion",
55 "CallComponentCanDo",
56 "CallComponentClose",
57 "CallComponentOpen",
58 "OpenAComponent",
59 "GetComponentPublicResource", # Missing in CW Pro 6
60 "CallComponentGetPublicResource", # Missing in CW Pro 6
61 'SetComponentInstanceA5',
62 'GetComponentInstanceA5',
63 ]
Jack Jansenb9968561995-11-30 15:03:09 +000064
Tim Peters182b5ac2004-07-18 06:16:08 +000065 def makeblacklisttypes(self):
66 return [
67 "ResourceSpec",
68 "ComponentResource",
69 "ComponentPlatformInfo",
70 "ComponentResourceExtension",
71 "ComponentPlatformInfoArray",
72 "ExtComponentResource",
73 "ComponentParameters",
Jack Jansenb9968561995-11-30 15:03:09 +000074
Tim Peters182b5ac2004-07-18 06:16:08 +000075 "ComponentRoutineUPP",
76 "ComponentMPWorkFunctionUPP",
77 "ComponentFunctionUPP",
78 "GetMissingComponentResourceUPP",
79 ]
80
81 def makerepairinstructions(self):
82 return [
83 ([('ComponentDescription', 'looking', 'OutMode')],
84 [('ComponentDescription', '*', 'InMode')]),
85 ]
86
Jack Jansenb9968561995-11-30 15:03:09 +000087if __name__ == "__main__":
Tim Peters182b5ac2004-07-18 06:16:08 +000088 main()