Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1 | # Scan <Menus.h>, generating menugen.py. |
Jack Jansen | 0c4d947 | 1998-04-17 14:07:56 +0000 | [diff] [blame] | 2 | import sys |
| 3 | import os |
Jack Jansen | aaebdd6 | 2002-08-05 15:39:30 +0000 | [diff] [blame^] | 4 | from bgenlocations import TOOLBOXDIR, BGENDIR |
Jack Jansen | 0c4d947 | 1998-04-17 14:07:56 +0000 | [diff] [blame] | 5 | sys.path.append(BGENDIR) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 6 | |
| 7 | from scantools import Scanner |
| 8 | |
| 9 | def main(): |
| 10 | input = "Menus.h" |
| 11 | output = "menugen.py" |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 12 | defsoutput = TOOLBOXDIR + "Menus.py" |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 13 | scanner = MyScanner(input, output, defsoutput) |
| 14 | scanner.scan() |
| 15 | scanner.close() |
| 16 | print "=== Done scanning and generating, now doing 'import menusupport' ===" |
| 17 | import menusupport |
| 18 | print "=== Done. It's up to you to compile Menumodule.c ===" |
| 19 | |
| 20 | class MyScanner(Scanner): |
| 21 | |
| 22 | def destination(self, type, name, arglist): |
| 23 | classname = "Function" |
| 24 | listname = "functions" |
| 25 | if arglist: |
| 26 | t, n, m = arglist[0] |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 27 | if t in ("MenuHandle", "MenuRef") and m == "InMode": |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 28 | classname = "Method" |
| 29 | listname = "methods" |
| 30 | return classname, listname |
| 31 | |
| 32 | def makeblacklistnames(self): |
| 33 | return [ |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 34 | ## "IsShowContextualMenuClick", # Can't find it in the library |
| 35 | ## "InitContextualMenus", # ditto |
| 36 | "GetMenuItemProperty", # difficult for the moment |
| 37 | "GetMenuItemPropertySize", |
| 38 | "SetMenuItemProperty", |
| 39 | "RemoveMenuItemProperty", |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 40 | "SetMenuCommandProperty", |
| 41 | "GetMenuCommandProperty", |
| 42 | "GetMenuTitle", # Funny arg/returnvalue |
| 43 | "SetMenuTitle", |
Jack Jansen | 2168e9d | 2001-12-16 20:18:40 +0000 | [diff] [blame] | 44 | "SetMenuTitleIcon", # void* |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 45 | ] |
| 46 | |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 47 | def makegreylist(self): |
| 48 | return [ |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 49 | ('#if !TARGET_API_MAC_CARBON', [ |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 50 | 'GetMenuItemRefCon2', |
| 51 | 'SetMenuItemRefCon2', |
| 52 | 'EnableItem', |
| 53 | 'DisableItem', |
| 54 | 'CheckItem', |
| 55 | 'CountMItems', |
| 56 | 'OpenDeskAcc', |
| 57 | 'SystemEdit', |
| 58 | 'SystemMenu', |
| 59 | 'SetMenuFlash', |
| 60 | 'InitMenus', |
| 61 | 'InitProcMenu', |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 62 | ]), |
| 63 | ('#if TARGET_API_MAC_CARBON', [ |
| 64 | 'DisposeMenuBar', |
| 65 | 'DuplicateMenuBar', |
| 66 | 'CreateNewMenu', |
| 67 | 'GetFontFamilyFromMenuSelection', |
| 68 | 'UpdateStandardFontMenu', |
| 69 | 'CreateStandardFontMenu', |
| 70 | 'RemoveMenuCommandProperty', |
| 71 | 'GetMenuCommandPropertySize', |
| 72 | 'IsMenuCommandEnabled', |
| 73 | 'DisableMenuCommand', |
| 74 | 'EnableMenuCommand', |
| 75 | 'GetIndMenuItemWithCommandID', |
| 76 | 'CountMenuItemsWithCommandID', |
| 77 | 'MenuHasEnabledItems', |
| 78 | 'EnableAllMenuItems', |
| 79 | 'DisableAllMenuItems', |
| 80 | 'ChangeMenuItemAttributes', |
| 81 | 'GetMenuItemAttributes', |
| 82 | 'ChangeMenuAttributes', |
| 83 | 'GetMenuAttributes', |
| 84 | 'ChangeMenuItemPropertyAttributes', |
| 85 | 'GetMenuItemPropertyAttributes', |
Jack Jansen | 2168e9d | 2001-12-16 20:18:40 +0000 | [diff] [blame] | 86 | 'AcquireRootMenu', |
| 87 | 'UpdateInvalidMenuItems', |
| 88 | 'InvalidateMenuItems', |
| 89 | 'IsMenuItemInvalid', |
| 90 | 'GetMenuCommandMark', |
| 91 | 'SetMenuCommandMark', |
| 92 | 'GetMenuType', |
| 93 | 'SetMenuItemCommandKey', |
| 94 | 'GetMenuItemCommandKey', |
| 95 | 'SetMenuItemIndent', |
| 96 | 'GetMenuItemIndent', |
| 97 | 'SetMenuItemTextWithCFString', |
| 98 | 'CopyMenuItemTextAsCFString', |
| 99 | 'GetMenuItemHierarchicalMenu', |
| 100 | 'SetMenuItemHierarchicalMenu', |
| 101 | 'SetRootMenu', |
| 102 | 'IsMenuBarInvalid', |
| 103 | 'InvalidateMenuEnabling', |
| 104 | 'InsertMenuItemTextWithCFString', |
| 105 | 'AppendMenuItemTextWithCFString', |
| 106 | 'DeleteMenuItems', |
| 107 | 'CopyMenuItems', |
| 108 | 'IsMenuSizeInvalid', |
| 109 | 'InvalidateMenuSize', |
| 110 | 'SetMenuTitleWithCFString', |
| 111 | 'CopyMenuTitleAsCFString', |
| 112 | 'DuplicateMenu', |
| 113 | 'ReleaseMenu', |
| 114 | 'RetainMenu', |
| 115 | 'GetMenuRetainCount', |
| 116 | 'IsValidMenu', |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 117 | ])] |
| 118 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 119 | def makeblacklisttypes(self): |
| 120 | return [ |
| 121 | 'MCTableHandle', |
| 122 | 'MCEntryPtr', |
| 123 | 'MCTablePtr', |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 124 | 'AEDesc_ptr', # For now: doable, but not easy |
| 125 | 'ProcessSerialNumber', # ditto |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 126 | "MenuDefSpecPtr", # Too difficult for now |
| 127 | "MenuDefSpec_ptr", # ditto |
| 128 | "MenuTrackingData", |
Jack Jansen | 2168e9d | 2001-12-16 20:18:40 +0000 | [diff] [blame] | 129 | "void_ptr", # Don't know yet. |
| 130 | "EventRef", # For now, not exported yet. |
| 131 | "MenuItemDataPtr", # Not yet. |
| 132 | "MenuItemDataRec_ptr", |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 133 | ] |
| 134 | |
| 135 | def makerepairinstructions(self): |
| 136 | return [ |
| 137 | ([("Str255", "itemString", "InMode")], |
| 138 | [("*", "*", "OutMode")]), |
| 139 | |
| 140 | ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], |
| 141 | [("InBuffer", "*", "*")]), |
| 142 | |
| 143 | ([("void", "*", "OutMode"), ("long", "*", "InMode"), |
| 144 | ("long", "*", "OutMode")], |
| 145 | [("VarVarOutBuffer", "*", "InOutMode")]), |
Just van Rossum | 8edfc54 | 2002-01-03 12:16:18 +0000 | [diff] [blame] | 146 | ([("MenuRef", 'outHierMenu', "OutMode")], |
| 147 | [("OptMenuRef", 'outHierMenu', "OutMode")]), |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 148 | ] |
| 149 | |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 150 | def writeinitialdefs(self): |
| 151 | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") |
| 152 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 153 | if __name__ == "__main__": |
| 154 | main() |