When the classes in wave.py opened files themselves, their .close() methods
[python/dscho.git] / Mac / Modules / cm / cmscan.py
blob1c36eaa2d76a98655f44d8af2c3b3badd07208fb
1 # Scan an Apple header file, generating a Python file of generator calls.
3 import sys
4 import os
5 BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
6 sys.path.append(BGENDIR)
7 from scantools import Scanner
8 from bgenlocations import TOOLBOXDIR
10 LONG = "Components"
11 SHORT = "cm"
13 def main():
14 input = "Components.h"
15 output = SHORT + "gen.py"
16 defsoutput = TOOLBOXDIR + LONG + ".py"
17 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! ==="
24 class MyScanner(Scanner):
26 def destination(self, type, name, arglist):
27 classname = "Function"
28 listname = "functions"
29 if arglist:
30 t, n, m = arglist[0]
32 # FindNextComponent is a special case, since it call also be called
33 # with None as the argument. Hence, we make it a function
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
43 def writeinitialdefs(self):
44 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
46 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",
61 def makegreylist(self):
62 return [
63 ('#if !TARGET_API_MAC_CARBON', [
64 'SetComponentInstanceA5',
65 'GetComponentInstanceA5',
66 ])]
68 def makeblacklisttypes(self):
69 return [
70 "ResourceSpec",
71 "ComponentResource",
72 "ComponentPlatformInfo",
73 "ComponentResourceExtension",
74 "ComponentPlatformInfoArray",
75 "ExtComponentResource",
76 "ComponentParameters",
78 "ComponentRoutineUPP",
79 "ComponentMPWorkFunctionUPP",
82 def makerepairinstructions(self):
83 return [
84 ([('ComponentDescription', 'looking', 'OutMode')],
85 [('ComponentDescription', '*', 'InMode')]),
88 if __name__ == "__main__":
89 main()