1 # Scan an Apple header file, generating a Python file of generator calls.
4 from bgenlocations import TOOLBOXDIR, BGENDIR
5 sys.path.append(BGENDIR)
6 from scantools import Scanner
14 output = SHORT + "gen.py"
15 defsoutput = TOOLBOXDIR + LONG + ".py"
16 scanner = MyScanner(input, output, defsoutput)
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! ==="
25 class MyScanner(Scanner):
27 def destination(self, type, name, arglist):
28 classname = "Function"
29 listname = "functions"
32 # This is non-functional today
33 if t in ('ListHandle', 'ListRef') and m == "InMode":
36 return classname, listname
38 def makeblacklistnames(self):
40 "LDispose", # Done by removing the object
41 "LSearch", # We don't want to handle procs just yet
42 "CreateCustomList", # done manually
43 "SetListDefinitionProc",
45 # These have funny argument/return values
49 "GetListVisibleCells",
50 "GetListClickLocation",
51 "GetListMouseLocation",
56 def makeblacklisttypes(self):
58 "ListClickLoopUPP", # Too difficult for now
59 "ListDefSpecPtr", # later
62 def makerepairinstructions(self):
64 ([('ListBounds_ptr', '*', 'InMode')],
65 [('Rect_ptr', '*', 'InMode')]),
67 ([("Cell", "theCell", "OutMode")],
68 [("Cell", "theCell", "InOutMode")]),
70 ([("void_ptr", "*", "InMode"), ("short", "*", "InMode")],
71 [("InBufferShortsize", "*", "*")]),
73 ([("void", "*", "OutMode"), ("short", "*", "OutMode")],
74 [("VarOutBufferShortsize", "*", "InOutMode")]),
76 # SetListCellIndent doesn't have const
77 ([("Point", "indent", "OutMode")],
78 [("Point_ptr", "indent", "InMode")]),
82 def writeinitialdefs(self):
83 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
86 if __name__ == "__main__":