blob: 542d3ec0d8d29ee0880ee348164e6e3d946e38c1 [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
Guido van Rossum17448e21995-01-30 11:53:55 +00006import MacOS
Jack Jansen0c4d9471998-04-17 14:07:56 +00007
Jack Jansenaaebdd62002-08-05 15:39:30 +00008from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen0c4d9471998-04-17 14:07:56 +00009sys.path.append(BGENDIR)
Guido van Rossum17448e21995-01-30 11:53:55 +000010
11from scantools import Scanner
12
13def main():
Tim Peters182b5ac2004-07-18 06:16:08 +000014 input = "Resources.h"
15 output = "resgen.py"
16 defsoutput = TOOLBOXDIR + "Resources.py"
17 scanner = ResourcesScanner(input, output, defsoutput)
18 scanner.scan()
19 scanner.close()
Collin Wintere7bf59f2007-08-30 18:39:28 +000020 print("=== Testing definitions output code ===")
Neal Norwitz01688022007-08-12 00:43:29 +000021 exec(open(defsoutput).read(), {}, {})
Collin Wintere7bf59f2007-08-30 18:39:28 +000022 print("=== Done scanning and generating, now doing 'import ressupport' ===")
Tim Peters182b5ac2004-07-18 06:16:08 +000023 import ressupport
Collin Wintere7bf59f2007-08-30 18:39:28 +000024 print("=== Done 'import ressupport'. It's up to you to compile Resmodule.c ===")
Guido van Rossum17448e21995-01-30 11:53:55 +000025
26class ResourcesScanner(Scanner):
27
Tim Peters182b5ac2004-07-18 06:16:08 +000028 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
Guido van Rossum17448e21995-01-30 11:53:55 +000037
Tim Peters182b5ac2004-07-18 06:16:08 +000038 def makeblacklistnames(self):
39 return [
40 "ReadPartialResource",
41 "WritePartialResource",
42 "TempInsertROMMap",
43## "RmveResource", # RemoveResource
44## "SizeResource", # GetResourceSizeOnDisk
45## "MaxSizeRsrc", # GetMaxResourceSize
46 # OS8 only
47 'RGetResource',
48 'OpenResFile',
49 'CreateResFile',
50 'RsrcZoneInit',
51 'InitResources',
52 'RsrcMapEntry',
53 ]
54
55 def makeblacklisttypes(self):
56 return [
57 ]
58
59 def makerepairinstructions(self):
60 return [
61 ([("Str255", "*", "InMode")],
62 [("*", "*", "OutMode")]),
63
64 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
65 [("InBuffer", "*", "*")]),
66
67 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
68 [("InOutBuffer", "*", "*")]),
69
70 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
71 ("long", "*", "OutMode")],
72 [("OutBuffer", "*", "InOutMode")]),
73
74 ([("SInt8", "*", "*")],
75 [("SignedByte", "*", "*")]),
76
77
78 ([("UniCharCount", "*", "InMode"), ("UniChar_ptr", "*", "InMode")],
79 [("UnicodeReverseInBuffer", "*", "*")]),
80 ]
Guido van Rossum17448e21995-01-30 11:53:55 +000081
82if __name__ == "__main__":
Tim Peters182b5ac2004-07-18 06:16:08 +000083 main()