ยปCore Development>Code coverage>Mac/Modules/qdoffs/qdoffsscan.py

Python code coverage for Mac/Modules/qdoffs/qdoffsscan.py

#countcontent
1n/a# Scan an Apple header file, generating a Python file of generator calls.
2n/aimport sys
3n/afrom bgenlocations import TOOLBOXDIR, BGENDIR
4n/asys.path.append(BGENDIR)
5n/a
6n/afrom scantools import Scanner
7n/a
8n/adef main():
9n/a input = "QDOffscreen.h"
10n/a output = "qdoffsgen.py"
11n/a defsoutput = TOOLBOXDIR + "QDOffscreen.py"
12n/a scanner = MyScanner(input, output, defsoutput)
13n/a scanner.scan()
14n/a scanner.close()
15n/a print "=== Testing definitions output code ==="
16n/a execfile(defsoutput, {}, {})
17n/a print "=== Done scanning and generating, now importing the generated code... ==="
18n/a import qdoffssupport
19n/a print "=== Done. It's up to you to compile it now! ==="
20n/a
21n/aclass MyScanner(Scanner):
22n/a
23n/a def destination(self, type, name, arglist):
24n/a classname = "Function"
25n/a listname = "functions"
26n/a if arglist:
27n/a t, n, m = arglist[0]
28n/a if t == "GWorldPtr" and m in ("InMode", "InOutMode"):
29n/a classname = "Method"
30n/a listname = "methods"
31n/a return classname, listname
32n/a
33n/a def writeinitialdefs(self):
34n/a self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
35n/a
36n/a def makeblacklistnames(self):
37n/a return [
38n/a 'DisposeGWorld', # Implied when the object is deleted
39n/a 'NewGWorldFromHBITMAP', # Don't know what the args do
40n/a 'GetGDeviceAttributes', # Windows-only
41n/a ]
42n/a
43n/a def makeblacklisttypes(self):
44n/a return [
45n/a "void_ptr", # GetGDeviceSurface, blacklisted for now
46n/a "Ptr", # Again, for now (array is probably ok here)
47n/a ]
48n/a
49n/a def makerepairinstructions(self):
50n/a return [
51n/a
52n/a## ("UpdateGWorld",
53n/a## [("GWorldPtr", "*", "OutMode")],
54n/a## [("*", "*", "InOutMode")]),
55n/a
56n/a # This one is incorrect: we say that all input gdevices are
57n/a # optional, but some are not. Most are, however, so users passing
58n/a # None for non-optional gdevices will get a qd error, I guess, in
59n/a # stead of a python argument error.
60n/a ([("GDHandle", "*", "InMode")],
61n/a [("OptGDHandle", "*", "InMode")]),
62n/a ]
63n/a
64n/aif __name__ == "__main__":
65n/a main()