blob: 75e1a0808aa3275e21f75e2ca9f952c5a97e2417 [file] [log] [blame]
Jack Jansenfe3fe4a2003-12-03 22:34:19 +00001# Scan an Apple header file, generating a Python file of generator calls.
2
3import sys
4import os
5from bgenlocations import TOOLBOXDIR, BGENDIR
6sys.path.append(BGENDIR)
7from scantools import Scanner
8
9LONG = "OSAconst"
10SHORT = "osa"
11
12def main():
13 input = "OSA.h"
14 output = SHORT + "gen.py"
15 defsoutput = TOOLBOXDIR + LONG + ".py"
16 scanner = MyScanner(input, output, defsoutput)
17 scanner.scan()
18 scanner.close()
19 scanner.gentypetest(SHORT+"typetest.py")
20 print "=== Testing definitions output code ==="
21 execfile(defsoutput, {}, {})
22 print "=== Done scanning and generating, now importing the generated code... ==="
23 exec "import " + SHORT + "support"
24 print "=== Done. It's up to you to compile it now! ==="
25
26class MyScanner(Scanner):
27
28 def destination(self, type, name, arglist):
29 classname = "Function"
30 listname = "functions"
31 if arglist:
32 t, n, m = arglist[0]
33 if t == "ComponentInstance" and m == "InMode":
34 classname = "Method"
35 listname = "methods"
36 return classname, listname
37
38 def writeinitialdefs(self):
39 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
40 self.defsfile.write("from Carbon.AppleEvents import *\n")
41 self.defsfile.write("kAEUseStandardDispatch = -1\n")
42
43 def makeblacklistnames(self):
44 return [
45 "OSACopyScript",
46 ]
47
48 def makeblacklisttypes(self):
49 return [
Jack Jansenda6081f2003-12-03 23:20:13 +000050 "OSALocalOrGlobal",
Jack Jansenfe3fe4a2003-12-03 22:34:19 +000051 "OSACreateAppleEventUPP",
52 "OSAActiveUPP",
53 "AEEventHandlerUPP",
54 "OSASendUPP",
55 ]
56
57 def makerepairinstructions(self):
58 return [
59 ]
60
61if __name__ == "__main__":
62 main()