blob: 51bf38d4550e71eb9919bdd11f24e5acb4296099 [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()
Jack Jansen87eea882002-08-15 21:48:16 +000022 print "=== Testing definitions output code ==="
23 execfile(defsoutput, {}, {})
Guido van Rossum17448e21995-01-30 11:53:55 +000024 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",
Jack Jansen7d0bc831995-06-09 20:56:31 +000044 "TempInsertROMMap",
Guido van Rossum227a4231995-03-10 14:42:57 +000045## "RmveResource", # RemoveResource
46## "SizeResource", # GetResourceSizeOnDisk
47## "MaxSizeRsrc", # GetMaxResourceSize
Guido van Rossum17448e21995-01-30 11:53:55 +000048 ]
Jack Jansene79dc762000-06-02 21:35:07 +000049
Jack Jansen620a7662001-12-18 15:39:38 +000050 def makeblacklisttypes(self):
51 return [
Jack Jansen620a7662001-12-18 15:39:38 +000052 ]
53
Jack Jansene79dc762000-06-02 21:35:07 +000054 def makegreylist(self):
55 return [
Jack Jansenfa77e1a2001-05-22 21:56:42 +000056 ('#if TARGET_API_MAC_OS8', [
Jack Jansene79dc762000-06-02 21:35:07 +000057 'RGetResource',
58 'OpenResFile',
59 'CreateResFile',
60 'RsrcZoneInit',
61 'InitResources',
62 'RsrcMapEntry',
Jack Jansen723ad8a2000-12-12 22:10:21 +000063 ]),
64 ('#if TARGET_API_MAC_CARBON', [
65 'GetNextResourceFile',
66 'GetTopResourceFile',
67 'FSpOpenOrphanResFile',
68 'DetachResourceFile',
69 'InsertResourceFile',
Jack Jansen043732e2001-03-02 16:32:03 +000070 'FSpResourceFileAlreadyOpen',
Jack Jansen3bac5ca2002-01-04 16:00:27 +000071 'FSOpenResourceFile',
72 'FSCreateResourceFile',
Jack Jansene79dc762000-06-02 21:35:07 +000073 ])]
Guido van Rossum17448e21995-01-30 11:53:55 +000074
75 def makerepairinstructions(self):
76 return [
77 ([("Str255", "*", "InMode")],
78 [("*", "*", "OutMode")]),
79
80 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
81 [("InBuffer", "*", "*")]),
82
83 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
84 [("InOutBuffer", "*", "*")]),
85
86 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
87 ("long", "*", "OutMode")],
88 [("OutBuffer", "*", "InOutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000089
90 ([("SInt8", "*", "*")],
Jack Jansen69ac3612002-01-01 22:43:13 +000091 [("SignedByte", "*", "*")]),
92
93
94 ([("UniCharCount", "*", "InMode"), ("UniChar_ptr", "*", "InMode")],
95 [("UnicodeReverseInBuffer", "*", "*")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000096 ]
97
98if __name__ == "__main__":
99 main()