blob: 544e303fda24567735c9dc651b0f71dbfd19e9b2 [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 regsub
9import MacOS
Jack Jansen0c4d9471998-04-17 14:07:56 +000010
11BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
12sys.path.append(BGENDIR)
Jack Jansen46d9e791996-04-12 16:29:23 +000013from bgenlocations import TOOLBOXDIR
Guido van Rossum17448e21995-01-30 11:53:55 +000014
15from scantools import Scanner
16
17def main():
18 input = "Resources.h"
19 output = "resgen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000020 defsoutput = TOOLBOXDIR + "Resources.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000021 scanner = ResourcesScanner(input, output, defsoutput)
22 scanner.scan()
23 scanner.close()
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",
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
50 def makegreylist(self):
51 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000052 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansene79dc762000-06-02 21:35:07 +000053 'RGetResource',
54 'OpenResFile',
55 'CreateResFile',
56 'RsrcZoneInit',
57 'InitResources',
58 'RsrcMapEntry',
Jack Jansen723ad8a2000-12-12 22:10:21 +000059 ]),
60 ('#if TARGET_API_MAC_CARBON', [
61 'GetNextResourceFile',
62 'GetTopResourceFile',
63 'FSpOpenOrphanResFile',
64 'DetachResourceFile',
65 'InsertResourceFile',
Jack Jansen043732e2001-03-02 16:32:03 +000066 'FSpResourceFileAlreadyOpen',
Jack Jansene79dc762000-06-02 21:35:07 +000067 ])]
Guido van Rossum17448e21995-01-30 11:53:55 +000068
69 def makerepairinstructions(self):
70 return [
71 ([("Str255", "*", "InMode")],
72 [("*", "*", "OutMode")]),
73
74 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
75 [("InBuffer", "*", "*")]),
76
77 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
78 [("InOutBuffer", "*", "*")]),
79
80 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
81 ("long", "*", "OutMode")],
82 [("OutBuffer", "*", "InOutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000083
84 ([("SInt8", "*", "*")],
85 [("SignedByte", "*", "*")])
Guido van Rossum17448e21995-01-30 11:53:55 +000086 ]
87
88if __name__ == "__main__":
89 main()