Bump to 2.3.1 to pick up the missing file.
[python/dscho.git] / Mac / Modules / res / resscan.py
blob51bf38d4550e71eb9919bdd11f24e5acb4296099
1 # Scan Resources.h header file, generate resgen.py and Resources.py files.
2 # Then run ressupport to generate Resmodule.c.
3 # (Should learn how to tell the compiler to compile it as well.)
5 import sys
6 import os
7 import string
8 import MacOS
10 from bgenlocations import TOOLBOXDIR, BGENDIR
11 sys.path.append(BGENDIR)
13 from scantools import Scanner
15 def main():
16 input = "Resources.h"
17 output = "resgen.py"
18 defsoutput = TOOLBOXDIR + "Resources.py"
19 scanner = ResourcesScanner(input, output, defsoutput)
20 scanner.scan()
21 scanner.close()
22 print "=== Testing definitions output code ==="
23 execfile(defsoutput, {}, {})
24 print "=== Done scanning and generating, now doing 'import ressupport' ==="
25 import ressupport
26 print "=== Done 'import ressupport'. It's up to you to compile Resmodule.c ==="
28 class ResourcesScanner(Scanner):
30 def destination(self, type, name, arglist):
31 classname = "ResFunction"
32 listname = "functions"
33 if arglist:
34 t, n, m = arglist[0]
35 if t == "Handle" and m == "InMode":
36 classname = "ResMethod"
37 listname = "resmethods"
38 return classname, listname
40 def makeblacklistnames(self):
41 return [
42 "ReadPartialResource",
43 "WritePartialResource",
44 "TempInsertROMMap",
45 ## "RmveResource", # RemoveResource
46 ## "SizeResource", # GetResourceSizeOnDisk
47 ## "MaxSizeRsrc", # GetMaxResourceSize
50 def makeblacklisttypes(self):
51 return [
54 def makegreylist(self):
55 return [
56 ('#if TARGET_API_MAC_OS8', [
57 'RGetResource',
58 'OpenResFile',
59 'CreateResFile',
60 'RsrcZoneInit',
61 'InitResources',
62 'RsrcMapEntry',
63 ]),
64 ('#if TARGET_API_MAC_CARBON', [
65 'GetNextResourceFile',
66 'GetTopResourceFile',
67 'FSpOpenOrphanResFile',
68 'DetachResourceFile',
69 'InsertResourceFile',
70 'FSpResourceFileAlreadyOpen',
71 'FSOpenResourceFile',
72 'FSCreateResourceFile',
73 ])]
75 def makerepairinstructions(self):
76 return [
77 ([("Str255", "*", "InMode")],
78 [("*", "*", "OutMode")]),
80 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
81 [("InBuffer", "*", "*")]),
83 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
84 [("InOutBuffer", "*", "*")]),
86 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
87 ("long", "*", "OutMode")],
88 [("OutBuffer", "*", "InOutMode")]),
90 ([("SInt8", "*", "*")],
91 [("SignedByte", "*", "*")]),
94 ([("UniCharCount", "*", "InMode"), ("UniChar_ptr", "*", "InMode")],
95 [("UnicodeReverseInBuffer", "*", "*")]),
98 if __name__ == "__main__":
99 main()