This is (hopefully) last checkin before releasing 2.1c2 -- get rid of
[python/dscho.git] / Mac / Modules / res / resscan.py
blob544e303fda24567735c9dc651b0f71dbfd19e9b2
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 regsub
9 import MacOS
11 BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
12 sys.path.append(BGENDIR)
13 from bgenlocations import TOOLBOXDIR
15 from scantools import Scanner
17 def main():
18 input = "Resources.h"
19 output = "resgen.py"
20 defsoutput = TOOLBOXDIR + "Resources.py"
21 scanner = ResourcesScanner(input, output, defsoutput)
22 scanner.scan()
23 scanner.close()
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 makegreylist(self):
51 return [
52 ('#if !TARGET_API_MAC_CARBON', [
53 'RGetResource',
54 'OpenResFile',
55 'CreateResFile',
56 'RsrcZoneInit',
57 'InitResources',
58 'RsrcMapEntry',
59 ]),
60 ('#if TARGET_API_MAC_CARBON', [
61 'GetNextResourceFile',
62 'GetTopResourceFile',
63 'FSpOpenOrphanResFile',
64 'DetachResourceFile',
65 'InsertResourceFile',
66 'FSpResourceFileAlreadyOpen',
67 ])]
69 def makerepairinstructions(self):
70 return [
71 ([("Str255", "*", "InMode")],
72 [("*", "*", "OutMode")]),
74 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
75 [("InBuffer", "*", "*")]),
77 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
78 [("InOutBuffer", "*", "*")]),
80 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
81 ("long", "*", "OutMode")],
82 [("OutBuffer", "*", "InOutMode")]),
84 ([("SInt8", "*", "*")],
85 [("SignedByte", "*", "*")])
88 if __name__ == "__main__":
89 main()