source: vendor/python/2.5/Mac/Modules/res/resscan.py

Last change on this file was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 2.7 KB
RevLine 
[3225]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.)
4
5import sys
6import os
7import string
8import MacOS
9
10from bgenlocations import TOOLBOXDIR, BGENDIR
11sys.path.append(BGENDIR)
12
13from scantools import Scanner
14
15def 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 ==="
27
28class ResourcesScanner(Scanner):
29
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
39
40 def makeblacklistnames(self):
41 return [
42 "ReadPartialResource",
43 "WritePartialResource",
44 "TempInsertROMMap",
45## "RmveResource", # RemoveResource
46## "SizeResource", # GetResourceSizeOnDisk
47## "MaxSizeRsrc", # GetMaxResourceSize
48 # OS8 only
49 'RGetResource',
50 'OpenResFile',
51 'CreateResFile',
52 'RsrcZoneInit',
53 'InitResources',
54 'RsrcMapEntry',
55 ]
56
57 def makeblacklisttypes(self):
58 return [
59 ]
60
61 def makerepairinstructions(self):
62 return [
63 ([("Str255", "*", "InMode")],
64 [("*", "*", "OutMode")]),
65
66 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
67 [("InBuffer", "*", "*")]),
68
69 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
70 [("InOutBuffer", "*", "*")]),
71
72 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
73 ("long", "*", "OutMode")],
74 [("OutBuffer", "*", "InOutMode")]),
75
76 ([("SInt8", "*", "*")],
77 [("SignedByte", "*", "*")]),
78
79
80 ([("UniCharCount", "*", "InMode"), ("UniChar_ptr", "*", "InMode")],
81 [("UnicodeReverseInBuffer", "*", "*")]),
82 ]
83
84if __name__ == "__main__":
85 main()
Note: See TracBrowser for help on using the repository browser.