blob: 8c51528e40c85c2a7987aa86043200ae6422d85d [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
Guido van Rossum17448e21995-01-30 11:53:55 +00008import MacOS
Jack Jansen0c4d9471998-04-17 14:07:56 +00009
10BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
11sys.path.append(BGENDIR)
Jack Jansen46d9e791996-04-12 16:29:23 +000012from bgenlocations import TOOLBOXDIR
Guido van Rossum17448e21995-01-30 11:53:55 +000013
14from scantools import Scanner
15
16def main():
17 input = "Resources.h"
18 output = "resgen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000019 defsoutput = TOOLBOXDIR + "Resources.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000020 scanner = ResourcesScanner(input, output, defsoutput)
21 scanner.scan()
22 scanner.close()
23 print "=== Done scanning and generating, now doing 'import ressupport' ==="
24 import ressupport
25 print "=== Done 'import ressupport'. It's up to you to compile Resmodule.c ==="
26
27class ResourcesScanner(Scanner):
28
29 def destination(self, type, name, arglist):
30 classname = "ResFunction"
31 listname = "functions"
32 if arglist:
33 t, n, m = arglist[0]
34 if t == "Handle" and m == "InMode":
35 classname = "ResMethod"
36 listname = "resmethods"
37 return classname, listname
38
39 def makeblacklistnames(self):
40 return [
41 "ReadPartialResource",
42 "WritePartialResource",
Jack Jansen7d0bc831995-06-09 20:56:31 +000043 "TempInsertROMMap",
Guido van Rossum227a4231995-03-10 14:42:57 +000044## "RmveResource", # RemoveResource
45## "SizeResource", # GetResourceSizeOnDisk
46## "MaxSizeRsrc", # GetMaxResourceSize
Guido van Rossum17448e21995-01-30 11:53:55 +000047 ]
Jack Jansene79dc762000-06-02 21:35:07 +000048
Jack Jansen620a7662001-12-18 15:39:38 +000049 def makeblacklisttypes(self):
50 return [
Jack Jansen620a7662001-12-18 15:39:38 +000051 ]
52
Jack Jansene79dc762000-06-02 21:35:07 +000053 def makegreylist(self):
54 return [
Jack Jansenfa77e1a2001-05-22 21:56:42 +000055 ('#if TARGET_API_MAC_OS8', [
Jack Jansene79dc762000-06-02 21:35:07 +000056 'RGetResource',
57 'OpenResFile',
58 'CreateResFile',
59 'RsrcZoneInit',
60 'InitResources',
61 'RsrcMapEntry',
Jack Jansen723ad8a2000-12-12 22:10:21 +000062 ]),
63 ('#if TARGET_API_MAC_CARBON', [
64 'GetNextResourceFile',
65 'GetTopResourceFile',
66 'FSpOpenOrphanResFile',
67 'DetachResourceFile',
68 'InsertResourceFile',
Jack Jansen043732e2001-03-02 16:32:03 +000069 'FSpResourceFileAlreadyOpen',
Jack Jansen3bac5ca2002-01-04 16:00:27 +000070 'FSOpenResourceFile',
71 'FSCreateResourceFile',
Jack Jansene79dc762000-06-02 21:35:07 +000072 ])]
Guido van Rossum17448e21995-01-30 11:53:55 +000073
74 def makerepairinstructions(self):
75 return [
76 ([("Str255", "*", "InMode")],
77 [("*", "*", "OutMode")]),
78
79 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
80 [("InBuffer", "*", "*")]),
81
82 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
83 [("InOutBuffer", "*", "*")]),
84
85 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
86 ("long", "*", "OutMode")],
87 [("OutBuffer", "*", "InOutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000088
89 ([("SInt8", "*", "*")],
Jack Jansen69ac3612002-01-01 22:43:13 +000090 [("SignedByte", "*", "*")]),
91
92
93 ([("UniCharCount", "*", "InMode"), ("UniChar_ptr", "*", "InMode")],
94 [("UnicodeReverseInBuffer", "*", "*")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000095 ]
96
97if __name__ == "__main__":
98 main()