blob: cf4bcb136f420d98b52a5af7a32944984984c7b5 [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
Jack Jansenaaebdd62002-08-05 15:39:30 +000010from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen0c4d9471998-04-17 14:07:56 +000011sys.path.append(BGENDIR)
Guido van Rossum17448e21995-01-30 11:53:55 +000012
13from scantools import Scanner
14
15def main():
16 input = "Resources.h"
17 output = "resgen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000018 defsoutput = TOOLBOXDIR + "Resources.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000019 scanner = ResourcesScanner(input, output, defsoutput)
20 scanner.scan()
21 scanner.close()
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 ==="
25
26class ResourcesScanner(Scanner):
27
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
37
38 def makeblacklistnames(self):
39 return [
40 "ReadPartialResource",
41 "WritePartialResource",
Jack Jansen7d0bc831995-06-09 20:56:31 +000042 "TempInsertROMMap",
Guido van Rossum227a4231995-03-10 14:42:57 +000043## "RmveResource", # RemoveResource
44## "SizeResource", # GetResourceSizeOnDisk
45## "MaxSizeRsrc", # GetMaxResourceSize
Guido van Rossum17448e21995-01-30 11:53:55 +000046 ]
Jack Jansene79dc762000-06-02 21:35:07 +000047
Jack Jansen620a7662001-12-18 15:39:38 +000048 def makeblacklisttypes(self):
49 return [
Jack Jansen620a7662001-12-18 15:39:38 +000050 ]
51
Jack Jansene79dc762000-06-02 21:35:07 +000052 def makegreylist(self):
53 return [
Jack Jansenfa77e1a2001-05-22 21:56:42 +000054 ('#if TARGET_API_MAC_OS8', [
Jack Jansene79dc762000-06-02 21:35:07 +000055 'RGetResource',
56 'OpenResFile',
57 'CreateResFile',
58 'RsrcZoneInit',
59 'InitResources',
60 'RsrcMapEntry',
Jack Jansen723ad8a2000-12-12 22:10:21 +000061 ]),
62 ('#if TARGET_API_MAC_CARBON', [
63 'GetNextResourceFile',
64 'GetTopResourceFile',
65 'FSpOpenOrphanResFile',
66 'DetachResourceFile',
67 'InsertResourceFile',
Jack Jansen043732e2001-03-02 16:32:03 +000068 'FSpResourceFileAlreadyOpen',
Jack Jansen3bac5ca2002-01-04 16:00:27 +000069 'FSOpenResourceFile',
70 'FSCreateResourceFile',
Jack Jansene79dc762000-06-02 21:35:07 +000071 ])]
Guido van Rossum17448e21995-01-30 11:53:55 +000072
73 def makerepairinstructions(self):
74 return [
75 ([("Str255", "*", "InMode")],
76 [("*", "*", "OutMode")]),
77
78 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
79 [("InBuffer", "*", "*")]),
80
81 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
82 [("InOutBuffer", "*", "*")]),
83
84 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
85 ("long", "*", "OutMode")],
86 [("OutBuffer", "*", "InOutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000087
88 ([("SInt8", "*", "*")],
Jack Jansen69ac3612002-01-01 22:43:13 +000089 [("SignedByte", "*", "*")]),
90
91
92 ([("UniCharCount", "*", "InMode"), ("UniChar_ptr", "*", "InMode")],
93 [("UnicodeReverseInBuffer", "*", "*")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000094 ]
95
96if __name__ == "__main__":
97 main()