blob: 5fc2e9f6f090889a7ef8f1adbc3b9cfa3691a8e3 [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
Jack Jansenfe3fe4a2003-12-03 22:34:19 +00004from bgenlocations import TOOLBOXDIR, BGENDIR
5sys.path.append(BGENDIR)
6from scantools import Scanner
7
8LONG = "OSAconst"
9SHORT = "osa"
10
11def main():
Tim Peters182b5ac2004-07-18 06:16:08 +000012 input = "OSA.h"
13 output = SHORT + "gen.py"
14 defsoutput = TOOLBOXDIR + LONG + ".py"
15 scanner = MyScanner(input, output, defsoutput)
16 scanner.scan()
17 scanner.close()
18 scanner.gentypetest(SHORT+"typetest.py")
19 print "=== Testing definitions output code ==="
20 execfile(defsoutput, {}, {})
21 print "=== Done scanning and generating, now importing the generated code... ==="
22 exec "import " + SHORT + "support"
23 print "=== Done. It's up to you to compile it now! ==="
Jack Jansenfe3fe4a2003-12-03 22:34:19 +000024
25class MyScanner(Scanner):
26
Tim Peters182b5ac2004-07-18 06:16:08 +000027 def destination(self, type, name, arglist):
28 classname = "Function"
29 listname = "functions"
30 if arglist:
31 t, n, m = arglist[0]
32 if t == "ComponentInstance" and m == "InMode":
33 classname = "Method"
34 listname = "methods"
35 return classname, listname
Jack Jansenfe3fe4a2003-12-03 22:34:19 +000036
Tim Peters182b5ac2004-07-18 06:16:08 +000037 def writeinitialdefs(self):
38 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
39 self.defsfile.write("from Carbon.AppleEvents import *\n")
40 self.defsfile.write("kAEUseStandardDispatch = -1\n")
Jack Jansenfe3fe4a2003-12-03 22:34:19 +000041
Tim Peters182b5ac2004-07-18 06:16:08 +000042 def makeblacklistnames(self):
43 return [
44 "OSACopyScript",
45 ]
Jack Jansenfe3fe4a2003-12-03 22:34:19 +000046
Tim Peters182b5ac2004-07-18 06:16:08 +000047 def makeblacklisttypes(self):
48 return [
49 "OSALocalOrGlobal",
50 "OSACreateAppleEventUPP",
51 "OSAActiveUPP",
52 "AEEventHandlerUPP",
53 "OSASendUPP",
54 ]
Jack Jansenfe3fe4a2003-12-03 22:34:19 +000055
Tim Peters182b5ac2004-07-18 06:16:08 +000056 def makerepairinstructions(self):
57 return [
58 ]
59
Jack Jansenfe3fe4a2003-12-03 22:34:19 +000060if __name__ == "__main__":
Tim Peters182b5ac2004-07-18 06:16:08 +000061 main()