ยปCore Development>Code coverage>Mac/Modules/file/filescan.py

Python code coverage for Mac/Modules/file/filescan.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_OSX
7n/a
8n/aLONG = "Files"
9n/aSHORT = "file"
10n/a
11n/adef main():
12n/a input = ["Files.h", "Aliases.h", "Finder.h"]
13n/a output = SHORT + "gen.py"
14n/a defsoutput = TOOLBOXDIR + LONG + ".py"
15n/a scanner = MyScanner(input, output, defsoutput)
16n/a scanner.scan()
17n/a scanner.close()
18n/a scanner.gentypetest(SHORT+"typetest.py")
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_OSX):
26n/a
27n/a def destination(self, type, name, arglist):
28n/a classname = "Function"
29n/a listname = "functions"
30n/a if arglist:
31n/a # Funny special case
32n/a if len(arglist) > 2:
33n/a t, n, m = arglist[1]
34n/a if t == "AliasHandle" and m == "InMode":
35n/a classname = "Arg2MethodGenerator"
36n/a listname = "alias_methods"
37n/a return classname, listname
38n/a # Normal cases
39n/a t, n, m = arglist[0]
40n/a if t == "AliasHandle" and m == "InMode":
41n/a classname = "Method"
42n/a listname = "alias_methods"
43n/a if t == "FSSpec_ptr" and m == "InMode":
44n/a classname = "Method"
45n/a listname = "fsspec_methods"
46n/a if t == "FSRef_ptr" and m == "InMode":
47n/a classname = "Method"
48n/a listname = "fsref_methods"
49n/a return classname, listname
50n/a
51n/a def makeblacklistnames(self):
52n/a return [
53n/a # Constants with incompatible definitions
54n/a "kioACAccessOwnerMask",
55n/a "kFSCatInfoReserved",
56n/a "kFSIterateReserved",
57n/a "kSystemFolderType",
58n/a
59n/a "FSRefMakePath", # Do this manually
60n/a# "ResolveAlias", # Do this manually
61n/a# "ResolveAliasWithMountFlags", # Do this manually
62n/a# "FollowFinderAlias", # Do this manually
63n/a
64n/a "FSRead", # Couldn't be bothered
65n/a "FSWrite", # ditto
66n/a "FSReadFork", # ditto
67n/a "FSWriteFork", # ditto
68n/a
69n/a # Old routines:
70n/a "GetWDInfo",
71n/a "OpenWD",
72n/a "CloseWD",
73n/a "FInitQueue",
74n/a "rstflock",
75n/a "setflock",
76n/a "setfinfo",
77n/a "fsrename",
78n/a "fsdelete",
79n/a "create",
80n/a "flushvol",
81n/a "eject",
82n/a "umountvol",
83n/a "setvol",
84n/a "getvol",
85n/a "getfinfo",
86n/a "getvinfo",
87n/a "fsopen",
88n/a "RstFLock",
89n/a "SetFLock",
90n/a "SetFInfo",
91n/a "Rename",
92n/a "OpenRF",
93n/a "FSDelete",
94n/a "Create",
95n/a "GetVol",
96n/a "GetFInfo",
97n/a "GetVInfo",
98n/a "FSOpen",
99n/a "Eject",
100n/a "SetVol",
101n/a "openrf",
102n/a "unmountvol",
103n/a "OpenDF",
104n/a
105n/a ]
106n/a
107n/a def makeblacklisttypes(self):
108n/a return [
109n/a "CInfoPBPtr", # Old stuff
110n/a "CMovePBPtr", # Old stuff
111n/a "ParmBlkPtr", # Old stuff
112n/a "HParmBlkPtr", # Old stuff
113n/a "DTPBPtr", # Old stuff
114n/a "FCBPBPtr", # Old stuff
115n/a "QHdrPtr", # Old stuff
116n/a "CSParamPtr", # Old stuff
117n/a "FSCatalogBulkParam", # old stuff
118n/a "FSForkCBInfoParam", # old stuff
119n/a "FSForkIOParam", # old stuff
120n/a "FSRefParam", # old stuff
121n/a "FSVolumeInfoParam", # old stuff
122n/a "WDPBPtr", # old stuff
123n/a "XCInfoPBPtr", # old stuff
124n/a "XVolumeParamPtr", # old stuff
125n/a
126n/a
127n/a "CatPositionRec", # State variable, not too difficult
128n/a "FSIterator", # Should become an object
129n/a "FSForkInfo", # Lots of fields, difficult struct
130n/a "FSSearchParams", # Also catsearch stuff
131n/a "FSVolumeInfo", # big struct
132n/a "FSVolumeInfo_ptr", # big struct
133n/a
134n/a "IOCompletionProcPtr", # proc pointer
135n/a "IOCompletionUPP", # Proc pointer
136n/a "AliasFilterProcPtr",
137n/a "AliasFilterUPP",
138n/a "FNSubscriptionUPP",
139n/a
140n/a "FNSubscriptionRef", # Lazy, for now.
141n/a ]
142n/a
143n/a def makerepairinstructions(self):
144n/a return [
145n/a # Various ways to give pathnames
146n/a ([('char_ptr', '*', 'InMode')],
147n/a [('stringptr', '*', 'InMode')]
148n/a ),
149n/a
150n/a # Unicode filenames passed as length, buffer
151n/a ([('UniCharCount', '*', 'InMode'),
152n/a ('UniChar_ptr', '*', 'InMode')],
153n/a [('UnicodeReverseInBuffer', '*', 'InMode')]
154n/a ),
155n/a # Wrong guess
156n/a ([('Str63', 'theString', 'InMode')],
157n/a [('Str63', 'theString', 'OutMode')]),
158n/a
159n/a # Yet another way to give a pathname:-)
160n/a ([('short', 'fullPathLength', 'InMode'),
161n/a ('void_ptr', 'fullPath', 'InMode')],
162n/a [('FullPathName', 'fullPath', 'InMode')]),
163n/a
164n/a # Various ResolveAliasFileXXXX functions
165n/a ([('FSSpec', 'theSpec', 'OutMode')],
166n/a [('FSSpec_ptr', 'theSpec', 'InOutMode')]),
167n/a
168n/a ([('FSRef', 'theRef', 'OutMode')],
169n/a [('FSRef_ptr', 'theRef', 'InOutMode')]),
170n/a
171n/a # The optional FSSpec to all ResolveAlias and NewAlias methods
172n/a ([('FSSpec_ptr', 'fromFile', 'InMode')],
173n/a [('OptFSSpecPtr', 'fromFile', 'InMode')]),
174n/a
175n/a ([('FSRef_ptr', 'fromFile', 'InMode')],
176n/a [('OptFSRefPtr', 'fromFile', 'InMode')]),
177n/a
178n/a## # FSCatalogInfo input handling
179n/a## ([('FSCatalogInfoBitmap', 'whichInfo', 'InMode'),
180n/a## ('FSCatalogInfo_ptr', 'catalogInfo', 'InMode')],
181n/a## [('FSCatalogInfoAndBitmap_in', 'catalogInfo', 'InMode')]),
182n/a##
183n/a## # FSCatalogInfo output handling
184n/a## ([('FSCatalogInfoBitmap', 'whichInfo', 'InMode'),
185n/a## ('FSCatalogInfo', 'catalogInfo', 'OutMode')],
186n/a## [('FSCatalogInfoAndBitmap_out', 'catalogInfo', 'InOutMode')]),
187n/a##
188n/a
189n/a ]
190n/a
191n/a
192n/a def writeinitialdefs(self):
193n/a self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
194n/a self.defsfile.write("true = True\n")
195n/a self.defsfile.write("false = False\n")
196n/a
197n/aif __name__ == "__main__":
198n/a main()