Fix three PyChecker-detected gotchas.
[python/dscho.git] / Mac / Modules / list / listscan.py
blobfaf81c038b0271f289657c1968383c9066daf6d5
1 # Scan an Apple header file, generating a Python file of generator calls.
3 import sys
4 import os
5 BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
6 sys.path.append(BGENDIR)
7 from scantools import Scanner
8 from bgenlocations import TOOLBOXDIR
10 LONG = "Lists"
11 SHORT = "list"
12 OBJECT = "ListHandle"
14 def main():
15 input = LONG + ".h"
16 output = SHORT + "gen.py"
17 defsoutput = TOOLBOXDIR + LONG + ".py"
18 scanner = MyScanner(input, output, defsoutput)
19 scanner.scan()
20 scanner.close()
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"
30 if arglist:
31 t, n, m = arglist[-1]
32 # This is non-functional today
33 if t == OBJECT and m == "InMode":
34 classname = "Method"
35 listname = "methods"
36 return classname, listname
38 def makeblacklistnames(self):
39 return [
40 "LDispose", # Done by removing the object
41 "LSearch", # We don't want to handle procs just yet
42 "LGetCellDataLocation", # What does this do??
44 # These have funny argument/return values
45 "GetListViewBounds",
46 "GetListCellIndent",
47 "GetListCellSize",
48 "GetListVisibleCells",
49 "GetListClickLocation",
50 "GetListMouseLocation",
51 "GetListDataBounds",
52 "SetListLastClick",
55 def makeblacklisttypes(self):
56 return [
57 'ListDefSpec', # Too difficult for now
58 'ListDefSpec_ptr', # ditto
59 "ListDefUPP",
60 "ListClickLoopUPP",
63 def makerepairinstructions(self):
64 return [
65 ([('ListBounds_ptr', '*', 'InMode')],
66 [('Rect_ptr', '*', 'InMode')]),
68 ([("Cell", "theCell", "OutMode")],
69 [("Cell", "theCell", "InOutMode")]),
71 ([("void_ptr", "*", "InMode"), ("short", "*", "InMode")],
72 [("InBufferShortsize", "*", "*")]),
74 ([("void", "*", "OutMode"), ("short", "*", "OutMode")],
75 [("VarOutBufferShortsize", "*", "InOutMode")]),
77 # SetListCellIndent doesn't have const
78 ([("Point", "indent", "OutMode")],
79 [("Point_ptr", "indent", "InMode")]),
83 def writeinitialdefs(self):
84 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
87 if __name__ == "__main__":
88 main()