ยปCore Development>Code coverage>Mac/Modules/list/listscan.py

Python code coverage for Mac/Modules/list/listscan.py

#countcontent
1n/a# Scan an Apple header file, generating a Python file of generator calls.
2n/a
3n/aimport sys
4n/afrom bgenlocations import TOOLBOXDIR, BGENDIR
5n/asys.path.append(BGENDIR)
6n/afrom scantools import Scanner
7n/a
8n/aLONG = "Lists"
9n/aSHORT = "list"
10n/aOBJECT = "ListHandle"
11n/a
12n/adef main():
13n/a input = LONG + ".h"
14n/a output = SHORT + "gen.py"
15n/a defsoutput = TOOLBOXDIR + LONG + ".py"
16n/a scanner = MyScanner(input, output, defsoutput)
17n/a scanner.scan()
18n/a scanner.close()
19n/a print "=== Testing definitions output code ==="
20n/a execfile(defsoutput, {}, {})
21n/a print "=== Done scanning and generating, now importing the generated code... ==="
22n/a exec "import " + SHORT + "support"
23n/a print "=== Done. It's up to you to compile it now! ==="
24n/a
25n/aclass MyScanner(Scanner):
26n/a
27n/a def destination(self, type, name, arglist):
28n/a classname = "Function"
29n/a listname = "functions"
30n/a if arglist:
31n/a t, n, m = arglist[-1]
32n/a # This is non-functional today
33n/a if t in ('ListHandle', 'ListRef') and m == "InMode":
34n/a classname = "Method"
35n/a listname = "methods"
36n/a return classname, listname
37n/a
38n/a def makeblacklistnames(self):
39n/a return [
40n/a "LDispose", # Done by removing the object
41n/a "LSearch", # We don't want to handle procs just yet
42n/a "CreateCustomList", # done manually
43n/a "SetListDefinitionProc",
44n/a
45n/a # These have funny argument/return values
46n/a "GetListViewBounds",
47n/a "GetListCellIndent",
48n/a "GetListCellSize",
49n/a "GetListVisibleCells",
50n/a "GetListClickLocation",
51n/a "GetListMouseLocation",
52n/a "GetListDataBounds",
53n/a "SetListLastClick",
54n/a ]
55n/a
56n/a def makeblacklisttypes(self):
57n/a return [
58n/a "ListClickLoopUPP", # Too difficult for now
59n/a "ListDefSpecPtr", # later
60n/a ]
61n/a
62n/a def makerepairinstructions(self):
63n/a return [
64n/a ([('ListBounds_ptr', '*', 'InMode')],
65n/a [('Rect_ptr', '*', 'InMode')]),
66n/a
67n/a ([("Cell", "theCell", "OutMode")],
68n/a [("Cell", "theCell", "InOutMode")]),
69n/a
70n/a ([("void_ptr", "*", "InMode"), ("short", "*", "InMode")],
71n/a [("InBufferShortsize", "*", "*")]),
72n/a
73n/a ([("void", "*", "OutMode"), ("short", "*", "OutMode")],
74n/a [("VarOutBufferShortsize", "*", "InOutMode")]),
75n/a
76n/a # SetListCellIndent doesn't have const
77n/a ([("Point", "indent", "OutMode")],
78n/a [("Point_ptr", "indent", "InMode")]),
79n/a
80n/a ]
81n/a
82n/a def writeinitialdefs(self):
83n/a self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
84n/a
85n/a
86n/aif __name__ == "__main__":
87n/a main()