blob: 9420a03c42a5ffdb6fb8b5fa9859ecb0e5a0da3c [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')
Guido van Rossum17448e21995-01-30 11:53:55 +000013
14from scantools import Scanner
15
16def main():
17 input = "Resources.h"
18 output = "resgen.py"
19 defsoutput = "Resources.py"
20 scanner = ResourcesScanner(input, output, defsoutput)
21 scanner.scan()
22 scanner.close()
23 print "=== Done scanning and generating, now doing 'import ressupport' ==="
24 import ressupport
25 print "=== Done 'import ressupport'. It's up to you to compile Resmodule.c ==="
26
27class ResourcesScanner(Scanner):
28
29 def destination(self, type, name, arglist):
30 classname = "ResFunction"
31 listname = "functions"
32 if arglist:
33 t, n, m = arglist[0]
34 if t == "Handle" and m == "InMode":
35 classname = "ResMethod"
36 listname = "resmethods"
37 return classname, listname
38
39 def makeblacklistnames(self):
40 return [
41 "ReadPartialResource",
42 "WritePartialResource",
Jack Jansen7d0bc831995-06-09 20:56:31 +000043 "TempInsertROMMap",
Guido van Rossum227a4231995-03-10 14:42:57 +000044## "RmveResource", # RemoveResource
45## "SizeResource", # GetResourceSizeOnDisk
46## "MaxSizeRsrc", # GetMaxResourceSize
Guido van Rossum17448e21995-01-30 11:53:55 +000047 ]
48
49 def makerepairinstructions(self):
50 return [
51 ([("Str255", "*", "InMode")],
52 [("*", "*", "OutMode")]),
53
54 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
55 [("InBuffer", "*", "*")]),
56
57 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
58 [("InOutBuffer", "*", "*")]),
59
60 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
61 ("long", "*", "OutMode")],
62 [("OutBuffer", "*", "InOutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000063
64 ([("SInt8", "*", "*")],
65 [("SignedByte", "*", "*")])
Guido van Rossum17448e21995-01-30 11:53:55 +000066 ]
67
68if __name__ == "__main__":
69 main()