move sections
[python/dscho.git] / Mac / Modules / res / resscan.py
blob6966e85819638862931db0ccdcc1ad641032c607
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 MacOS
8 from bgenlocations import TOOLBOXDIR, BGENDIR
9 sys.path.append(BGENDIR)
11 from scantools import Scanner
13 def main():
14 input = "Resources.h"
15 output = "resgen.py"
16 defsoutput = TOOLBOXDIR + "Resources.py"
17 scanner = ResourcesScanner(input, output, defsoutput)
18 scanner.scan()
19 scanner.close()
20 print "=== Testing definitions output code ==="
21 execfile(defsoutput, {}, {})
22 print "=== Done scanning and generating, now doing 'import ressupport' ==="
23 import ressupport
24 print "=== Done 'import ressupport'. It's up to you to compile Resmodule.c ==="
26 class ResourcesScanner(Scanner):
28 def destination(self, type, name, arglist):
29 classname = "ResFunction"
30 listname = "functions"
31 if arglist:
32 t, n, m = arglist[0]
33 if t == "Handle" and m == "InMode":
34 classname = "ResMethod"
35 listname = "resmethods"
36 return classname, listname
38 def makeblacklistnames(self):
39 return [
40 "ReadPartialResource",
41 "WritePartialResource",
42 "TempInsertROMMap",
43 ## "RmveResource", # RemoveResource
44 ## "SizeResource", # GetResourceSizeOnDisk
45 ## "MaxSizeRsrc", # GetMaxResourceSize
46 # OS8 only
47 'RGetResource',
48 'OpenResFile',
49 'CreateResFile',
50 'RsrcZoneInit',
51 'InitResources',
52 'RsrcMapEntry',
55 def makeblacklisttypes(self):
56 return [
59 def makerepairinstructions(self):
60 return [
61 ([("Str255", "*", "InMode")],
62 [("*", "*", "OutMode")]),
64 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
65 [("InBuffer", "*", "*")]),
67 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
68 [("InOutBuffer", "*", "*")]),
70 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
71 ("long", "*", "OutMode")],
72 [("OutBuffer", "*", "InOutMode")]),
74 ([("SInt8", "*", "*")],
75 [("SignedByte", "*", "*")]),
78 ([("UniCharCount", "*", "InMode"), ("UniChar_ptr", "*", "InMode")],
79 [("UnicodeReverseInBuffer", "*", "*")]),
82 if __name__ == "__main__":
83 main()