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 5import sys 6import MacOS 7 8from bgenlocations import TOOLBOXDIR, BGENDIR 9sys.path.append(BGENDIR) 10 11from scantools import Scanner 12 13def main(): 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() 20 print "=== Testing definitions output code ===" 21 execfile(defsoutput, {}, {}) 22 print "=== Done scanning and generating, now doing 'import ressupport' ===" 23 import ressupport 24 print "=== Done 'import ressupport'. It's up to you to compile Resmodule.c ===" 25 26class ResourcesScanner(Scanner): 27 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 37 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 ] 81 82if __name__ == "__main__": 83 main() 84