blob: eff0005a8cc8ee86f33362c390f358ae9abf9fbb [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
8import regex
9import regsub
10import MacOS
Jack Jansenb81cf9d1995-06-06 13:08:40 +000011import addpack
12addpack.addpack(':Tools:bgen:bgen')
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 ]
49
50 def makerepairinstructions(self):
51 return [
52 ([("Str255", "*", "InMode")],
53 [("*", "*", "OutMode")]),
54
55 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
56 [("InBuffer", "*", "*")]),
57
58 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
59 [("InOutBuffer", "*", "*")]),
60
61 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
62 ("long", "*", "OutMode")],
63 [("OutBuffer", "*", "InOutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000064
65 ([("SInt8", "*", "*")],
66 [("SignedByte", "*", "*")])
Guido van Rossum17448e21995-01-30 11:53:55 +000067 ]
68
69if __name__ == "__main__":
70 main()