blob: efb538c791c2ffd0283c0e97b4c4fb8eb96b7487 [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 Jansen0c4d9471998-04-17 14:07:56 +000011
12BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
13sys.path.append(BGENDIR)
Jack Jansen46d9e791996-04-12 16:29:23 +000014from bgenlocations import TOOLBOXDIR
Guido van Rossum17448e21995-01-30 11:53:55 +000015
16from scantools import Scanner
17
18def main():
19 input = "Resources.h"
20 output = "resgen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000021 defsoutput = TOOLBOXDIR + "Resources.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000022 scanner = ResourcesScanner(input, output, defsoutput)
23 scanner.scan()
24 scanner.close()
25 print "=== Done scanning and generating, now doing 'import ressupport' ==="
26 import ressupport
27 print "=== Done 'import ressupport'. It's up to you to compile Resmodule.c ==="
28
29class ResourcesScanner(Scanner):
30
31 def destination(self, type, name, arglist):
32 classname = "ResFunction"
33 listname = "functions"
34 if arglist:
35 t, n, m = arglist[0]
36 if t == "Handle" and m == "InMode":
37 classname = "ResMethod"
38 listname = "resmethods"
39 return classname, listname
40
41 def makeblacklistnames(self):
42 return [
43 "ReadPartialResource",
44 "WritePartialResource",
Jack Jansen7d0bc831995-06-09 20:56:31 +000045 "TempInsertROMMap",
Guido van Rossum227a4231995-03-10 14:42:57 +000046## "RmveResource", # RemoveResource
47## "SizeResource", # GetResourceSizeOnDisk
48## "MaxSizeRsrc", # GetMaxResourceSize
Guido van Rossum17448e21995-01-30 11:53:55 +000049 ]
50
51 def makerepairinstructions(self):
52 return [
53 ([("Str255", "*", "InMode")],
54 [("*", "*", "OutMode")]),
55
56 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
57 [("InBuffer", "*", "*")]),
58
59 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
60 [("InOutBuffer", "*", "*")]),
61
62 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
63 ("long", "*", "OutMode")],
64 [("OutBuffer", "*", "InOutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000065
66 ([("SInt8", "*", "*")],
67 [("SignedByte", "*", "*")])
Guido van Rossum17448e21995-01-30 11:53:55 +000068 ]
69
70if __name__ == "__main__":
71 main()