Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1 | # 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 | |
| 5 | import sys |
| 6 | import os |
| 7 | import string |
| 8 | import regex |
| 9 | import regsub |
| 10 | import MacOS |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 11 | import addpack |
| 12 | addpack.addpack(':Tools:bgen:bgen') |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 13 | from bgenlocations import TOOLBOXDIR |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 14 | |
| 15 | from scantools import Scanner |
| 16 | |
| 17 | def main(): |
| 18 | input = "Resources.h" |
| 19 | output = "resgen.py" |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 20 | defsoutput = TOOLBOXDIR + "Resources.py" |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 21 | 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 | |
| 28 | class 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 Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 44 | "TempInsertROMMap", |
Guido van Rossum | 227a423 | 1995-03-10 14:42:57 +0000 | [diff] [blame] | 45 | ## "RmveResource", # RemoveResource |
| 46 | ## "SizeResource", # GetResourceSizeOnDisk |
| 47 | ## "MaxSizeRsrc", # GetMaxResourceSize |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 48 | ] |
| 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 Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 64 | |
| 65 | ([("SInt8", "*", "*")], |
| 66 | [("SignedByte", "*", "*")]) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 67 | ] |
| 68 | |
| 69 | if __name__ == "__main__": |
| 70 | main() |