blob: 1136fe5d73d048e9198c59029cca65ee8d6df118 [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
5BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
6sys.path.append(BGENDIR)
Jack Jansenb9968561995-11-30 15:03:09 +00007from scantools import Scanner
Jack Jansen46d9e791996-04-12 16:29:23 +00008from bgenlocations import TOOLBOXDIR
Jack Jansenb9968561995-11-30 15:03:09 +00009
10LONG = "Components"
Jack Jansen21f96871998-02-20 16:02:09 +000011SHORT = "cm"
Jack Jansenb9968561995-11-30 15:03:09 +000012
13def main():
14 input = "Components.h"
15 output = SHORT + "gen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000016 defsoutput = TOOLBOXDIR + LONG + ".py"
Jack Jansenb9968561995-11-30 15:03:09 +000017 scanner = MyScanner(input, output, defsoutput)
18 scanner.scan()
19 scanner.close()
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! ==="
23
24class MyScanner(Scanner):
25
26 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
42
Jack Jansen21f96871998-02-20 16:02:09 +000043 def writeinitialdefs(self):
44 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
45
Jack Jansenb9968561995-11-30 15:03:09 +000046 def makeblacklistnames(self):
47 return [
Jack Jansen4a8c54e1997-02-24 13:56:59 +000048 "OpenADefaultComponent",
49 "GetComponentTypeModSeed",
50 "OpenAComponentResFile",
51 "CallComponentUnregister",
52 "CallComponentTarget",
53 "CallComponentRegister",
54 "CallComponentVersion",
55 "CallComponentCanDo",
56 "CallComponentClose",
57 "CallComponentOpen",
58 "OpenAComponent",
Jack Jansenf7d5aa62000-12-10 23:43:49 +000059 "GetComponentPublicResource", # Missing in CW Pro 6
60 "CallComponentGetPublicResource", # Missing in CW Pro 6
Jack Jansenb9968561995-11-30 15:03:09 +000061 ]
62
Jack Jansen8d929ae2000-06-21 22:07:06 +000063 def makegreylist(self):
64 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000065 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansen8d929ae2000-06-21 22:07:06 +000066 'SetComponentInstanceA5',
67 'GetComponentInstanceA5',
68 ])]
69
Jack Jansenb9968561995-11-30 15:03:09 +000070 def makeblacklisttypes(self):
71 return [
72 "ResourceSpec",
73 "ComponentResource",
74 "ComponentPlatformInfo",
75 "ComponentResourceExtension",
76 "ComponentPlatformInfoArray",
77 "ExtComponentResource",
78 "ComponentParameters",
79
80 "ComponentRoutineUPP",
Jack Jansen4a8c54e1997-02-24 13:56:59 +000081 "ComponentMPWorkFunctionUPP",
Jack Jansenf7d5aa62000-12-10 23:43:49 +000082 "ComponentFunctionUPP",
83 "GetMissingComponentResourceUPP",
Jack Jansenb9968561995-11-30 15:03:09 +000084 ]
85
86 def makerepairinstructions(self):
87 return [
88 ([('ComponentDescription', 'looking', 'OutMode')],
89 [('ComponentDescription', '*', 'InMode')]),
90 ]
91
92if __name__ == "__main__":
93 main()