Bump version to 0.9.1.
[python/dscho.git] / Mac / Modules / res / resscan.py
blobb417cd7db3f3beaf3bdc2e9467a1df9043840704
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 regex
9 import regsub
10 import MacOS
12 BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
13 sys.path.append(BGENDIR)
14 from bgenlocations import TOOLBOXDIR
16 from scantools import Scanner
18 def main():
19 input = "Resources.h"
20 output = "resgen.py"
21 defsoutput = TOOLBOXDIR + "Resources.py"
22 scanner = ResourcesScanner(input, output, defsoutput)
23 scanner.scan()
24 scanner.close()
25 print "=== Done scanning and generating, now doing 'import ressupport' ==="
26 import ressupport
27 print "=== Done 'import ressupport'. It's up to you to compile Resmodule.c ==="
29 class ResourcesScanner(Scanner):
31 def destination(self, type, name, arglist):
32 classname = "ResFunction"
33 listname = "functions"
34 if arglist:
35 t, n, m = arglist[0]
36 if t == "Handle" and m == "InMode":
37 classname = "ResMethod"
38 listname = "resmethods"
39 return classname, listname
41 def makeblacklistnames(self):
42 return [
43 "ReadPartialResource",
44 "WritePartialResource",
45 "TempInsertROMMap",
46 ## "RmveResource", # RemoveResource
47 ## "SizeResource", # GetResourceSizeOnDisk
48 ## "MaxSizeRsrc", # GetMaxResourceSize
51 def makegreylist(self):
52 return [
53 ('#if !TARGET_API_MAC_CARBON', [
54 'RGetResource',
55 'OpenResFile',
56 'CreateResFile',
57 'RsrcZoneInit',
58 'InitResources',
59 'RsrcMapEntry',
60 ])]
62 def makerepairinstructions(self):
63 return [
64 ([("Str255", "*", "InMode")],
65 [("*", "*", "OutMode")]),
67 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
68 [("InBuffer", "*", "*")]),
70 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
71 [("InOutBuffer", "*", "*")]),
73 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
74 ("long", "*", "OutMode")],
75 [("OutBuffer", "*", "InOutMode")]),
77 ([("SInt8", "*", "*")],
78 [("SignedByte", "*", "*")])
81 if __name__ == "__main__":
82 main()