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 |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 8 | import MacOS |
Jack Jansen | 0c4d947 | 1998-04-17 14:07:56 +0000 | [diff] [blame] | 9 | |
Jack Jansen | aaebdd6 | 2002-08-05 15:39:30 +0000 | [diff] [blame] | 10 | from bgenlocations import TOOLBOXDIR, BGENDIR |
Jack Jansen | 0c4d947 | 1998-04-17 14:07:56 +0000 | [diff] [blame] | 11 | sys.path.append(BGENDIR) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 12 | |
| 13 | from scantools import Scanner |
| 14 | |
| 15 | def main(): |
| 16 | input = "Resources.h" |
| 17 | output = "resgen.py" |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 18 | defsoutput = TOOLBOXDIR + "Resources.py" |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 19 | scanner = ResourcesScanner(input, output, defsoutput) |
| 20 | scanner.scan() |
| 21 | scanner.close() |
Jack Jansen | 87eea88 | 2002-08-15 21:48:16 +0000 | [diff] [blame] | 22 | print "=== Testing definitions output code ===" |
| 23 | execfile(defsoutput, {}, {}) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 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 |
Jack Jansen | 6c7e326 | 2002-12-12 10:31:54 +0000 | [diff] [blame] | 48 | # OS8 only |
| 49 | 'RGetResource', |
| 50 | 'OpenResFile', |
| 51 | 'CreateResFile', |
| 52 | 'RsrcZoneInit', |
| 53 | 'InitResources', |
| 54 | 'RsrcMapEntry', |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 55 | ] |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 56 | |
Jack Jansen | 620a766 | 2001-12-18 15:39:38 +0000 | [diff] [blame] | 57 | def makeblacklisttypes(self): |
| 58 | return [ |
Jack Jansen | 620a766 | 2001-12-18 15:39:38 +0000 | [diff] [blame] | 59 | ] |
| 60 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 61 | def makerepairinstructions(self): |
| 62 | return [ |
| 63 | ([("Str255", "*", "InMode")], |
| 64 | [("*", "*", "OutMode")]), |
| 65 | |
| 66 | ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], |
| 67 | [("InBuffer", "*", "*")]), |
| 68 | |
| 69 | ([("void", "*", "OutMode"), ("long", "*", "InMode")], |
| 70 | [("InOutBuffer", "*", "*")]), |
| 71 | |
| 72 | ([("void", "*", "OutMode"), ("long", "*", "InMode"), |
| 73 | ("long", "*", "OutMode")], |
| 74 | [("OutBuffer", "*", "InOutMode")]), |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 75 | |
| 76 | ([("SInt8", "*", "*")], |
Jack Jansen | 69ac361 | 2002-01-01 22:43:13 +0000 | [diff] [blame] | 77 | [("SignedByte", "*", "*")]), |
| 78 | |
| 79 | |
| 80 | ([("UniCharCount", "*", "InMode"), ("UniChar_ptr", "*", "InMode")], |
| 81 | [("UnicodeReverseInBuffer", "*", "*")]), |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 82 | ] |
| 83 | |
| 84 | if __name__ == "__main__": |
| 85 | main() |