blob: b417cd7db3f3beaf3bdc2e9467a1df9043840704 [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001# 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 regex
9import regsub
10import MacOS
Jack Jansen0c4d9471998-04-17 14:07:56 +000011
12BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
13sys.path.append(BGENDIR)
Jack Jansen46d9e791996-04-12 16:29:23 +000014from bgenlocations import TOOLBOXDIR
Guido van Rossum17448e21995-01-30 11:53:55 +000015
16from scantools import Scanner
17
18def main():
19 input = "Resources.h"
20 output = "resgen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000021 defsoutput = TOOLBOXDIR + "Resources.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000022 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 ==="
28
29class ResourcesScanner(Scanner):
30
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
40
41 def makeblacklistnames(self):
42 return [
43 "ReadPartialResource",
44 "WritePartialResource",
Jack Jansen7d0bc831995-06-09 20:56:31 +000045 "TempInsertROMMap",
Guido van Rossum227a4231995-03-10 14:42:57 +000046## "RmveResource", # RemoveResource
47## "SizeResource", # GetResourceSizeOnDisk
48## "MaxSizeRsrc", # GetMaxResourceSize
Guido van Rossum17448e21995-01-30 11:53:55 +000049 ]
Jack Jansene79dc762000-06-02 21:35:07 +000050
51 def makegreylist(self):
52 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000053 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansene79dc762000-06-02 21:35:07 +000054 'RGetResource',
55 'OpenResFile',
56 'CreateResFile',
57 'RsrcZoneInit',
58 'InitResources',
59 'RsrcMapEntry',
60 ])]
Guido van Rossum17448e21995-01-30 11:53:55 +000061
62 def makerepairinstructions(self):
63 return [
64 ([("Str255", "*", "InMode")],
65 [("*", "*", "OutMode")]),
66
67 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
68 [("InBuffer", "*", "*")]),
69
70 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
71 [("InOutBuffer", "*", "*")]),
72
73 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
74 ("long", "*", "OutMode")],
75 [("OutBuffer", "*", "InOutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000076
77 ([("SInt8", "*", "*")],
78 [("SignedByte", "*", "*")])
Guido van Rossum17448e21995-01-30 11:53:55 +000079 ]
80
81if __name__ == "__main__":
82 main()