| 1 | # Scan <Menus.h>, generating menugen.py.
|
|---|
| 2 | import sys
|
|---|
| 3 | import os
|
|---|
| 4 | from bgenlocations import TOOLBOXDIR, BGENDIR
|
|---|
| 5 | sys.path.append(BGENDIR)
|
|---|
| 6 |
|
|---|
| 7 | from scantools import Scanner
|
|---|
| 8 |
|
|---|
| 9 | def main():
|
|---|
| 10 | input = "Menus.h"
|
|---|
| 11 | output = "menugen.py"
|
|---|
| 12 | defsoutput = TOOLBOXDIR + "Menus.py"
|
|---|
| 13 | scanner = MyScanner(input, output, defsoutput)
|
|---|
| 14 | scanner.scan()
|
|---|
| 15 | scanner.close()
|
|---|
| 16 | print "=== Testing definitions output code ==="
|
|---|
| 17 | execfile(defsoutput, {}, {})
|
|---|
| 18 | print "=== Done scanning and generating, now doing 'import menusupport' ==="
|
|---|
| 19 | import menusupport
|
|---|
| 20 | print "=== Done. It's up to you to compile Menumodule.c ==="
|
|---|
| 21 |
|
|---|
| 22 | class MyScanner(Scanner):
|
|---|
| 23 |
|
|---|
| 24 | def destination(self, type, name, arglist):
|
|---|
| 25 | classname = "Function"
|
|---|
| 26 | listname = "functions"
|
|---|
| 27 | if arglist:
|
|---|
| 28 | t, n, m = arglist[0]
|
|---|
| 29 | if t in ("MenuHandle", "MenuRef") and m == "InMode":
|
|---|
| 30 | classname = "Method"
|
|---|
| 31 | listname = "methods"
|
|---|
| 32 | return classname, listname
|
|---|
| 33 |
|
|---|
| 34 | def makeblacklistnames(self):
|
|---|
| 35 | return [
|
|---|
| 36 | ## "IsShowContextualMenuClick", # Can't find it in the library
|
|---|
| 37 | ## "InitContextualMenus", # ditto
|
|---|
| 38 | "GetMenuItemProperty", # difficult for the moment
|
|---|
| 39 | "GetMenuItemPropertySize",
|
|---|
| 40 | "SetMenuItemProperty",
|
|---|
| 41 | "RemoveMenuItemProperty",
|
|---|
| 42 | "SetMenuCommandProperty",
|
|---|
| 43 | "GetMenuCommandProperty",
|
|---|
| 44 | "GetMenuTitle", # Funny arg/returnvalue
|
|---|
| 45 | "SetMenuTitle",
|
|---|
| 46 | "SetMenuTitleIcon", # void*
|
|---|
| 47 | # OS8 calls:
|
|---|
| 48 | 'GetMenuItemRefCon2',
|
|---|
| 49 | 'SetMenuItemRefCon2',
|
|---|
| 50 | 'EnableItem',
|
|---|
| 51 | 'DisableItem',
|
|---|
| 52 | 'CheckItem',
|
|---|
| 53 | 'CountMItems',
|
|---|
| 54 | 'OpenDeskAcc',
|
|---|
| 55 | 'SystemEdit',
|
|---|
| 56 | 'SystemMenu',
|
|---|
| 57 | 'SetMenuFlash',
|
|---|
| 58 | 'InitMenus',
|
|---|
| 59 | 'InitProcMenu',
|
|---|
| 60 | ]
|
|---|
| 61 |
|
|---|
| 62 | def makeblacklisttypes(self):
|
|---|
| 63 | return [
|
|---|
| 64 | 'MCTableHandle',
|
|---|
| 65 | 'MCEntryPtr',
|
|---|
| 66 | 'MCTablePtr',
|
|---|
| 67 | 'AEDesc_ptr', # For now: doable, but not easy
|
|---|
| 68 | 'ProcessSerialNumber', # ditto
|
|---|
| 69 | "MenuDefSpecPtr", # Too difficult for now
|
|---|
| 70 | "MenuDefSpec_ptr", # ditto
|
|---|
| 71 | "MenuTrackingData",
|
|---|
| 72 | "void_ptr", # Don't know yet.
|
|---|
| 73 | "EventRef", # For now, not exported yet.
|
|---|
| 74 | "MenuItemDataPtr", # Not yet.
|
|---|
| 75 | "MenuItemDataRec_ptr",
|
|---|
| 76 | ]
|
|---|
| 77 |
|
|---|
| 78 | def makerepairinstructions(self):
|
|---|
| 79 | return [
|
|---|
| 80 | ([("Str255", "itemString", "InMode")],
|
|---|
| 81 | [("*", "*", "OutMode")]),
|
|---|
| 82 |
|
|---|
| 83 | ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
|
|---|
| 84 | [("InBuffer", "*", "*")]),
|
|---|
| 85 |
|
|---|
| 86 | ([("void", "*", "OutMode"), ("long", "*", "InMode"),
|
|---|
| 87 | ("long", "*", "OutMode")],
|
|---|
| 88 | [("VarVarOutBuffer", "*", "InOutMode")]),
|
|---|
| 89 | ([("MenuRef", 'outHierMenu', "OutMode")],
|
|---|
| 90 | [("OptMenuRef", 'outHierMenu', "OutMode")]),
|
|---|
| 91 | ]
|
|---|
| 92 |
|
|---|
| 93 | def writeinitialdefs(self):
|
|---|
| 94 | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
|
|---|
| 95 |
|
|---|
| 96 | if __name__ == "__main__":
|
|---|
| 97 | main()
|
|---|