blob: a21d3f2cc12fa9dd0f29f9ccb43358798ac401ac [file] [log] [blame]
Jack Jansend0e59fb2002-11-22 15:53:32 +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_OSX
8
9LONG = "Aliases"
10SHORT = "alias"
11OBJECT = "AliasHandle"
12
13def main():
14 input = LONG + ".h"
15 output = SHORT + "gen.py"
16 defsoutput = TOOLBOXDIR + LONG + ".py"
17 scanner = MyScanner(input, output, defsoutput)
18 scanner.scan()
19 scanner.close()
20 scanner.gentypetest(SHORT+"typetest.py")
21 print "=== Testing definitions output code ==="
22 execfile(defsoutput, {}, {})
23 print "=== Done scanning and generating, now importing the generated code... ==="
24 exec "import " + SHORT + "support"
25 print "=== Done. It's up to you to compile it now! ==="
26
27class MyScanner(Scanner_OSX):
28
29 def destination(self, type, name, arglist):
30 classname = "Function"
31 listname = "functions"
32 if arglist:
33 t, n, m = arglist[0]
34 # This is non-functional today
35 if t == OBJECT and m == "InMode":
36 classname = "Method"
37 listname = "methods"
38 return classname, listname
39
40 def makeblacklistnames(self):
41 return [
42 # Constants with incompatible definitions
43
44 ]
45
46 def makeblacklisttypes(self):
47 return [
48 "AliasFilterProcPtr",
49 "AliasFilterUPP",
50 "CInfoPBPtr",
51 ]
52
53 def makerepairinstructions(self):
54 return [
55 ([('Str63', 'theString', 'InMode')],
56 [('Str63', 'theString', 'OutMode')]),
57
58 ([('short', 'fullPathLength', 'InMode'),
59 ('void_ptr', 'fullPath', 'InMode')],
60 [('FullPathName', 'fullPath', 'InMode')]),
61
62 ]
63
64
65 def writeinitialdefs(self):
66 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
67 self.defsfile.write("true = True\n")
68 self.defsfile.write("false = False\n")
69
70if __name__ == "__main__":
71 main()