blob: 625e7ed71a69b245d660a0ac1d06c1dd6b690b78 [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001# Scan <Menus.h>, generating menugen.py.
Jack Jansen0c4d9471998-04-17 14:07:56 +00002import sys
3import os
Jack Jansenaaebdd62002-08-05 15:39:30 +00004from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen0c4d9471998-04-17 14:07:56 +00005sys.path.append(BGENDIR)
Guido van Rossum17448e21995-01-30 11:53:55 +00006
7from scantools import Scanner
8
9def main():
10 input = "Menus.h"
11 output = "menugen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000012 defsoutput = TOOLBOXDIR + "Menus.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000013 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
20class 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 Jansenb81cf9d1995-06-06 13:08:40 +000027 if t in ("MenuHandle", "MenuRef") and m == "InMode":
Guido van Rossum17448e21995-01-30 11:53:55 +000028 classname = "Method"
29 listname = "methods"
30 return classname, listname
31
32 def makeblacklistnames(self):
33 return [
Jack Jansena05ac601999-12-12 21:41:51 +000034## "IsShowContextualMenuClick", # Can't find it in the library
35## "InitContextualMenus", # ditto
36 "GetMenuItemProperty", # difficult for the moment
37 "GetMenuItemPropertySize",
38 "SetMenuItemProperty",
39 "RemoveMenuItemProperty",
Jack Jansenf7d5aa62000-12-10 23:43:49 +000040 "SetMenuCommandProperty",
41 "GetMenuCommandProperty",
42 "GetMenuTitle", # Funny arg/returnvalue
43 "SetMenuTitle",
Jack Jansen2168e9d2001-12-16 20:18:40 +000044 "SetMenuTitleIcon", # void*
Guido van Rossum17448e21995-01-30 11:53:55 +000045 ]
46
Jack Jansene79dc762000-06-02 21:35:07 +000047 def makegreylist(self):
48 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000049 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansene79dc762000-06-02 21:35:07 +000050 'GetMenuItemRefCon2',
51 'SetMenuItemRefCon2',
52 'EnableItem',
53 'DisableItem',
54 'CheckItem',
55 'CountMItems',
56 'OpenDeskAcc',
57 'SystemEdit',
58 'SystemMenu',
59 'SetMenuFlash',
60 'InitMenus',
61 'InitProcMenu',
Jack Jansenf7d5aa62000-12-10 23:43:49 +000062 ]),
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 Jansen2168e9d2001-12-16 20:18:40 +000086 '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 Jansene79dc762000-06-02 21:35:07 +0000117 ])]
118
Guido van Rossum17448e21995-01-30 11:53:55 +0000119 def makeblacklisttypes(self):
120 return [
121 'MCTableHandle',
122 'MCEntryPtr',
123 'MCTablePtr',
Jack Jansen1c4e6141998-04-21 15:23:55 +0000124 'AEDesc_ptr', # For now: doable, but not easy
125 'ProcessSerialNumber', # ditto
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000126 "MenuDefSpecPtr", # Too difficult for now
127 "MenuDefSpec_ptr", # ditto
128 "MenuTrackingData",
Jack Jansen2168e9d2001-12-16 20:18:40 +0000129 "void_ptr", # Don't know yet.
130 "EventRef", # For now, not exported yet.
131 "MenuItemDataPtr", # Not yet.
132 "MenuItemDataRec_ptr",
Guido van Rossum17448e21995-01-30 11:53:55 +0000133 ]
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 Rossum8edfc542002-01-03 12:16:18 +0000146 ([("MenuRef", 'outHierMenu', "OutMode")],
147 [("OptMenuRef", 'outHierMenu', "OutMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000148 ]
149
Jack Jansene180d991998-04-24 10:28:20 +0000150 def writeinitialdefs(self):
151 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
152
Guido van Rossum17448e21995-01-30 11:53:55 +0000153if __name__ == "__main__":
154 main()