blob: ba860b45713b4c7e28eeb829c633a068c732bf81 [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",
Guido van Rossum227a4231995-03-10 14:42:57 +000043## "RmveResource", # RemoveResource
44## "SizeResource", # GetResourceSizeOnDisk
45## "MaxSizeRsrc", # GetMaxResourceSize
Guido van Rossum17448e21995-01-30 11:53:55 +000046 ]
47
48 def makerepairinstructions(self):
49 return [
50 ([("Str255", "*", "InMode")],
51 [("*", "*", "OutMode")]),
52
53 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
54 [("InBuffer", "*", "*")]),
55
56 ([("void", "*", "OutMode"), ("long", "*", "InMode")],
57 [("InOutBuffer", "*", "*")]),
58
59 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
60 ("long", "*", "OutMode")],
61 [("OutBuffer", "*", "InOutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000062
63 ([("SInt8", "*", "*")],
64 [("SignedByte", "*", "*")])
Guido van Rossum17448e21995-01-30 11:53:55 +000065 ]
66
67if __name__ == "__main__":
68 main()