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 |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 6 | import MacOS |
Jack Jansen | 0c4d947 | 1998-04-17 14:07:56 +0000 | [diff] [blame] | 7 | |
Jack Jansen | aaebdd6 | 2002-08-05 15:39:30 +0000 | [diff] [blame] | 8 | from bgenlocations import TOOLBOXDIR, BGENDIR |
Jack Jansen | 0c4d947 | 1998-04-17 14:07:56 +0000 | [diff] [blame] | 9 | sys.path.append(BGENDIR) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 10 | |
| 11 | from scantools import Scanner |
| 12 | |
| 13 | def main(): |
Tim Peters | 182b5ac | 2004-07-18 06:16:08 +0000 | [diff] [blame] | 14 | input = "Resources.h" |
| 15 | output = "resgen.py" |
| 16 | defsoutput = TOOLBOXDIR + "Resources.py" |
| 17 | scanner = ResourcesScanner(input, output, defsoutput) |
| 18 | scanner.scan() |
| 19 | scanner.close() |
Collin Winter | e7bf59f | 2007-08-30 18:39:28 +0000 | [diff] [blame] | 20 | print("=== Testing definitions output code ===") |
Neal Norwitz | 0168802 | 2007-08-12 00:43:29 +0000 | [diff] [blame] | 21 | exec(open(defsoutput).read(), {}, {}) |
Collin Winter | e7bf59f | 2007-08-30 18:39:28 +0000 | [diff] [blame] | 22 | print("=== Done scanning and generating, now doing 'import ressupport' ===") |
Tim Peters | 182b5ac | 2004-07-18 06:16:08 +0000 | [diff] [blame] | 23 | import ressupport |
Collin Winter | e7bf59f | 2007-08-30 18:39:28 +0000 | [diff] [blame] | 24 | print("=== Done 'import ressupport'. It's up to you to compile Resmodule.c ===") |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 25 | |
| 26 | class ResourcesScanner(Scanner): |
| 27 | |
Tim Peters | 182b5ac | 2004-07-18 06:16:08 +0000 | [diff] [blame] | 28 | def destination(self, type, name, arglist): |
| 29 | classname = "ResFunction" |
| 30 | listname = "functions" |
| 31 | if arglist: |
| 32 | t, n, m = arglist[0] |
| 33 | if t == "Handle" and m == "InMode": |
| 34 | classname = "ResMethod" |
| 35 | listname = "resmethods" |
| 36 | return classname, listname |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 37 | |
Tim Peters | 182b5ac | 2004-07-18 06:16:08 +0000 | [diff] [blame] | 38 | def makeblacklistnames(self): |
| 39 | return [ |
| 40 | "ReadPartialResource", |
| 41 | "WritePartialResource", |
| 42 | "TempInsertROMMap", |
| 43 | ## "RmveResource", # RemoveResource |
| 44 | ## "SizeResource", # GetResourceSizeOnDisk |
| 45 | ## "MaxSizeRsrc", # GetMaxResourceSize |
| 46 | # OS8 only |
| 47 | 'RGetResource', |
| 48 | 'OpenResFile', |
| 49 | 'CreateResFile', |
| 50 | 'RsrcZoneInit', |
| 51 | 'InitResources', |
| 52 | 'RsrcMapEntry', |
| 53 | ] |
| 54 | |
| 55 | def makeblacklisttypes(self): |
| 56 | return [ |
| 57 | ] |
| 58 | |
| 59 | def makerepairinstructions(self): |
| 60 | return [ |
| 61 | ([("Str255", "*", "InMode")], |
| 62 | [("*", "*", "OutMode")]), |
| 63 | |
| 64 | ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], |
| 65 | [("InBuffer", "*", "*")]), |
| 66 | |
| 67 | ([("void", "*", "OutMode"), ("long", "*", "InMode")], |
| 68 | [("InOutBuffer", "*", "*")]), |
| 69 | |
| 70 | ([("void", "*", "OutMode"), ("long", "*", "InMode"), |
| 71 | ("long", "*", "OutMode")], |
| 72 | [("OutBuffer", "*", "InOutMode")]), |
| 73 | |
| 74 | ([("SInt8", "*", "*")], |
| 75 | [("SignedByte", "*", "*")]), |
| 76 | |
| 77 | |
| 78 | ([("UniCharCount", "*", "InMode"), ("UniChar_ptr", "*", "InMode")], |
| 79 | [("UnicodeReverseInBuffer", "*", "*")]), |
| 80 | ] |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 81 | |
| 82 | if __name__ == "__main__": |
Tim Peters | 182b5ac | 2004-07-18 06:16:08 +0000 | [diff] [blame] | 83 | main() |