blob: 60c691525f1cec39b337faadb13de691f5351ee7 [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()
Jack Jansen87eea882002-08-15 21:48:16 +000016 print "=== Testing definitions output code ==="
17 execfile(defsoutput, {}, {})
Guido van Rossum17448e21995-01-30 11:53:55 +000018 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
22class 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]
Jack Jansenb81cf9d1995-06-06 13:08:40 +000029 if t in ("MenuHandle", "MenuRef") and m == "InMode":
Guido van Rossum17448e21995-01-30 11:53:55 +000030 classname = "Method"
31 listname = "methods"
32 return classname, listname
33
34 def makeblacklistnames(self):
35 return [
Jack Jansena05ac601999-12-12 21:41:51 +000036## "IsShowContextualMenuClick", # Can't find it in the library
37## "InitContextualMenus", # ditto
38 "GetMenuItemProperty", # difficult for the moment
39 "GetMenuItemPropertySize",
40 "SetMenuItemProperty",
41 "RemoveMenuItemProperty",
Jack Jansenf7d5aa62000-12-10 23:43:49 +000042 "SetMenuCommandProperty",
43 "GetMenuCommandProperty",
44 "GetMenuTitle", # Funny arg/returnvalue
45 "SetMenuTitle",
Jack Jansen2168e9d2001-12-16 20:18:40 +000046 "SetMenuTitleIcon", # void*
Guido van Rossum17448e21995-01-30 11:53:55 +000047 ]
48
Jack Jansene79dc762000-06-02 21:35:07 +000049 def makegreylist(self):
50 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000051 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansene79dc762000-06-02 21:35:07 +000052 'GetMenuItemRefCon2',
53 'SetMenuItemRefCon2',
54 'EnableItem',
55 'DisableItem',
56 'CheckItem',
57 'CountMItems',
58 'OpenDeskAcc',
59 'SystemEdit',
60 'SystemMenu',
61 'SetMenuFlash',
62 'InitMenus',
63 'InitProcMenu',
Jack Jansenf7d5aa62000-12-10 23:43:49 +000064 ]),
65 ('#if TARGET_API_MAC_CARBON', [
66 'DisposeMenuBar',
67 'DuplicateMenuBar',
68 'CreateNewMenu',
69 'GetFontFamilyFromMenuSelection',
70 'UpdateStandardFontMenu',
71 'CreateStandardFontMenu',
72 'RemoveMenuCommandProperty',
73 'GetMenuCommandPropertySize',
74 'IsMenuCommandEnabled',
75 'DisableMenuCommand',
76 'EnableMenuCommand',
77 'GetIndMenuItemWithCommandID',
78 'CountMenuItemsWithCommandID',
79 'MenuHasEnabledItems',
80 'EnableAllMenuItems',
81 'DisableAllMenuItems',
82 'ChangeMenuItemAttributes',
83 'GetMenuItemAttributes',
84 'ChangeMenuAttributes',
85 'GetMenuAttributes',
86 'ChangeMenuItemPropertyAttributes',
87 'GetMenuItemPropertyAttributes',
Jack Jansen2168e9d2001-12-16 20:18:40 +000088 'AcquireRootMenu',
89 'UpdateInvalidMenuItems',
90 'InvalidateMenuItems',
91 'IsMenuItemInvalid',
92 'GetMenuCommandMark',
93 'SetMenuCommandMark',
94 'GetMenuType',
95 'SetMenuItemCommandKey',
96 'GetMenuItemCommandKey',
97 'SetMenuItemIndent',
98 'GetMenuItemIndent',
99 'SetMenuItemTextWithCFString',
100 'CopyMenuItemTextAsCFString',
101 'GetMenuItemHierarchicalMenu',
102 'SetMenuItemHierarchicalMenu',
103 'SetRootMenu',
104 'IsMenuBarInvalid',
105 'InvalidateMenuEnabling',
106 'InsertMenuItemTextWithCFString',
107 'AppendMenuItemTextWithCFString',
108 'DeleteMenuItems',
109 'CopyMenuItems',
110 'IsMenuSizeInvalid',
111 'InvalidateMenuSize',
112 'SetMenuTitleWithCFString',
113 'CopyMenuTitleAsCFString',
114 'DuplicateMenu',
115 'ReleaseMenu',
116 'RetainMenu',
117 'GetMenuRetainCount',
118 'IsValidMenu',
Jack Jansene79dc762000-06-02 21:35:07 +0000119 ])]
120
Guido van Rossum17448e21995-01-30 11:53:55 +0000121 def makeblacklisttypes(self):
122 return [
123 'MCTableHandle',
124 'MCEntryPtr',
125 'MCTablePtr',
Jack Jansen1c4e6141998-04-21 15:23:55 +0000126 'AEDesc_ptr', # For now: doable, but not easy
127 'ProcessSerialNumber', # ditto
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000128 "MenuDefSpecPtr", # Too difficult for now
129 "MenuDefSpec_ptr", # ditto
130 "MenuTrackingData",
Jack Jansen2168e9d2001-12-16 20:18:40 +0000131 "void_ptr", # Don't know yet.
132 "EventRef", # For now, not exported yet.
133 "MenuItemDataPtr", # Not yet.
134 "MenuItemDataRec_ptr",
Guido van Rossum17448e21995-01-30 11:53:55 +0000135 ]
136
137 def makerepairinstructions(self):
138 return [
139 ([("Str255", "itemString", "InMode")],
140 [("*", "*", "OutMode")]),
141
142 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
143 [("InBuffer", "*", "*")]),
144
145 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
146 ("long", "*", "OutMode")],
147 [("VarVarOutBuffer", "*", "InOutMode")]),
Just van Rossum8edfc542002-01-03 12:16:18 +0000148 ([("MenuRef", 'outHierMenu', "OutMode")],
149 [("OptMenuRef", 'outHierMenu', "OutMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000150 ]
151
Jack Jansene180d991998-04-24 10:28:20 +0000152 def writeinitialdefs(self):
153 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
154
Guido van Rossum17448e21995-01-30 11:53:55 +0000155if __name__ == "__main__":
156 main()