blob: fb8196f67f03aa88b9b9b5411c9408cfb5e911d9 [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():
Tim Peters182b5ac2004-07-18 06:16:08 +000013 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! ==="
Jack Jansenfe3fe4a2003-12-03 22:34:19 +000025
26class MyScanner(Scanner):
27
Tim Peters182b5ac2004-07-18 06:16:08 +000028 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
Jack Jansenfe3fe4a2003-12-03 22:34:19 +000037
Tim Peters182b5ac2004-07-18 06:16:08 +000038 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")
Jack Jansenfe3fe4a2003-12-03 22:34:19 +000042
Tim Peters182b5ac2004-07-18 06:16:08 +000043 def makeblacklistnames(self):
44 return [
45 "OSACopyScript",
46 ]
Jack Jansenfe3fe4a2003-12-03 22:34:19 +000047
Tim Peters182b5ac2004-07-18 06:16:08 +000048 def makeblacklisttypes(self):
49 return [
50 "OSALocalOrGlobal",
51 "OSACreateAppleEventUPP",
52 "OSAActiveUPP",
53 "AEEventHandlerUPP",
54 "OSASendUPP",
55 ]
Jack Jansenfe3fe4a2003-12-03 22:34:19 +000056
Tim Peters182b5ac2004-07-18 06:16:08 +000057 def makerepairinstructions(self):
58 return [
59 ]
60
Jack Jansenfe3fe4a2003-12-03 22:34:19 +000061if __name__ == "__main__":
Tim Peters182b5ac2004-07-18 06:16:08 +000062 main()