ยปCore Development>Code coverage>Mac/Modules/dlg/dlgscan.py

Python code coverage for Mac/Modules/dlg/dlgscan.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/a
7n/afrom scantools import Scanner
8n/a
9n/aLONG = "Dialogs"
10n/aSHORT = "dlg"
11n/aOBJECT = "DialogPtr"
12n/a
13n/adef main():
14n/a input = LONG + ".h"
15n/a output = SHORT + "gen.py"
16n/a defsoutput = TOOLBOXDIR + LONG + ".py"
17n/a scanner = MyScanner(input, output, defsoutput)
18n/a scanner.scan()
19n/a scanner.close()
20n/a print "=== Testing definitions output code ==="
21n/a execfile(defsoutput, {}, {})
22n/a print "=== Done scanning and generating, now importing the generated code... ==="
23n/a exec "import " + SHORT + "support"
24n/a print "=== Done. It's up to you to compile it now! ==="
25n/a
26n/aclass MyScanner(Scanner):
27n/a
28n/a def destination(self, type, name, arglist):
29n/a classname = "Function"
30n/a listname = "functions"
31n/a if arglist:
32n/a t, n, m = arglist[0]
33n/a if t in ("DialogPtr", "DialogRef") 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 'InitDialogs',
41n/a 'ErrorSound',
42n/a # Dialogs are disposed when the object is deleted
43n/a 'CloseDialog',
44n/a 'DisposDialog',
45n/a 'DisposeDialog',
46n/a 'UpdtDialog',
47n/a 'CouldAlert',
48n/a 'FreeAlert',
49n/a 'CouldDialog',
50n/a 'FreeDialog',
51n/a 'GetStdFilterProc',
52n/a 'GetDialogParent',
53n/a## # Can't find these in the CW Pro 3 libraries
54n/a 'SetDialogMovableModal',
55n/a 'GetDialogControlNotificationProc',
56n/a 'SetGrafPortOfDialog', # Funny, and probably not useful
57n/a # Can't find these:
58n/a 'CloseStandardSheet',
59n/a 'RunStandardAlert',
60n/a ]
61n/a
62n/a def makeblacklisttypes(self):
63n/a return [
64n/a "AlertStdAlertParamPtr", # Too much work, for now
65n/a "AlertStdAlertParamRec", # ditto
66n/a "AlertStdAlertParamRec_ptr", # ditto
67n/a "AlertStdCFStringAlertParamPtr", # ditto
68n/a "AlertStdCFStringAlertParamRec",
69n/a "AlertStdCFStringAlertParamRec_ptr",
70n/a "QTModelessCallbackProcPtr",
71n/a ]
72n/a
73n/a def makerepairinstructions(self):
74n/a return [
75n/a ([("Str255", "*", "InMode")],
76n/a [("*", "*", "OutMode")]),
77n/a
78n/a ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
79n/a [("InBuffer", "*", "*")]),
80n/a
81n/a ([("void", "*", "OutMode"), ("long", "*", "InMode"),
82n/a ("long", "*", "OutMode")],
83n/a [("VarVarOutBuffer", "*", "InOutMode")]),
84n/a
85n/a # GetDialogItem return handle is optional
86n/a ([("Handle", "item", "OutMode")],
87n/a [("OptHandle", "item", "OutMode")]),
88n/a
89n/a # NewDialog ETC.
90n/a ([("void", "*", "OutMode")],
91n/a [("NullStorage", "*", "InMode")]),
92n/a
93n/a ([("DialogPtr", "*", "OutMode")],
94n/a [("ExistingDialogPtr", "*", "*")]),
95n/a ([("DialogRef", "*", "OutMode")],
96n/a [("ExistingDialogPtr", "*", "*")]),
97n/a ([("WindowPtr", "*", "OutMode")],
98n/a [("ExistingWindowPtr", "*", "*")]),
99n/a ([("WindowPtr", "*", "ReturnMode")],
100n/a [("ExistingWindowPtr", "*", "*")]),
101n/a
102n/a # StdFilterProc
103n/a ([('EventRecord', 'event', 'OutMode'),
104n/a ('DialogItemIndex', 'itemHit', 'OutMode')],
105n/a [('EventRecord', 'event', 'InOutMode'),
106n/a ('DialogItemIndex', 'itemHit', 'InOutMode')])
107n/a
108n/a ]
109n/a
110n/a def writeinitialdefs(self):
111n/a self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
112n/a
113n/a
114n/aif __name__ == "__main__":
115n/a main()