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') |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 13 | |
| 14 | from scantools import Scanner |
| 15 | |
| 16 | def 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 | |
| 27 | class 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 Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame^] | 43 | "TempInsertROMMap", |
Guido van Rossum | 227a423 | 1995-03-10 14:42:57 +0000 | [diff] [blame] | 44 | ## "RmveResource", # RemoveResource |
| 45 | ## "SizeResource", # GetResourceSizeOnDisk |
| 46 | ## "MaxSizeRsrc", # GetMaxResourceSize |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 47 | ] |
| 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 Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 63 | |
| 64 | ([("SInt8", "*", "*")], |
| 65 | [("SignedByte", "*", "*")]) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 66 | ] |
| 67 | |
| 68 | if __name__ == "__main__": |
| 69 | main() |