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 |
| 11 | |
| 12 | from scantools import Scanner |
| 13 | |
| 14 | def main(): |
| 15 | input = "Resources.h" |
| 16 | output = "resgen.py" |
| 17 | defsoutput = "Resources.py" |
| 18 | scanner = ResourcesScanner(input, output, defsoutput) |
| 19 | scanner.scan() |
| 20 | scanner.close() |
| 21 | print "=== Done scanning and generating, now doing 'import ressupport' ===" |
| 22 | import ressupport |
| 23 | print "=== Done 'import ressupport'. It's up to you to compile Resmodule.c ===" |
| 24 | |
| 25 | class ResourcesScanner(Scanner): |
| 26 | |
| 27 | def destination(self, type, name, arglist): |
| 28 | classname = "ResFunction" |
| 29 | listname = "functions" |
| 30 | if arglist: |
| 31 | t, n, m = arglist[0] |
| 32 | if t == "Handle" and m == "InMode": |
| 33 | classname = "ResMethod" |
| 34 | listname = "resmethods" |
| 35 | return classname, listname |
| 36 | |
| 37 | def makeblacklistnames(self): |
| 38 | return [ |
| 39 | "ReadPartialResource", |
| 40 | "WritePartialResource", |
Guido van Rossum | 227a423 | 1995-03-10 14:42:57 +0000 | [diff] [blame^] | 41 | ## "RmveResource", # RemoveResource |
| 42 | ## "SizeResource", # GetResourceSizeOnDisk |
| 43 | ## "MaxSizeRsrc", # GetMaxResourceSize |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 44 | ] |
| 45 | |
| 46 | def makerepairinstructions(self): |
| 47 | return [ |
| 48 | ([("Str255", "*", "InMode")], |
| 49 | [("*", "*", "OutMode")]), |
| 50 | |
| 51 | ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], |
| 52 | [("InBuffer", "*", "*")]), |
| 53 | |
| 54 | ([("void", "*", "OutMode"), ("long", "*", "InMode")], |
| 55 | [("InOutBuffer", "*", "*")]), |
| 56 | |
| 57 | ([("void", "*", "OutMode"), ("long", "*", "InMode"), |
| 58 | ("long", "*", "OutMode")], |
| 59 | [("OutBuffer", "*", "InOutMode")]), |
| 60 | ] |
| 61 | |
| 62 | if __name__ == "__main__": |
| 63 | main() |