blob: ef2d2f80757cb64b754f0bb11d01f76ba2477fab [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
4BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
5sys.path.append(BGENDIR)
Guido van Rossum17448e21995-01-30 11:53:55 +00006
7from scantools import Scanner
Jack Jansen46d9e791996-04-12 16:29:23 +00008from bgenlocations import TOOLBOXDIR
Guido van Rossum17448e21995-01-30 11:53:55 +00009
10def main():
11 input = "Menus.h"
12 output = "menugen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000013 defsoutput = TOOLBOXDIR + "Menus.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000014 scanner = MyScanner(input, output, defsoutput)
15 scanner.scan()
16 scanner.close()
17 print "=== Done scanning and generating, now doing 'import menusupport' ==="
18 import menusupport
19 print "=== Done. It's up to you to compile Menumodule.c ==="
20
21class MyScanner(Scanner):
22
23 def destination(self, type, name, arglist):
24 classname = "Function"
25 listname = "functions"
26 if arglist:
27 t, n, m = arglist[0]
Jack Jansenb81cf9d1995-06-06 13:08:40 +000028 if t in ("MenuHandle", "MenuRef") and m == "InMode":
Guido van Rossum17448e21995-01-30 11:53:55 +000029 classname = "Method"
30 listname = "methods"
31 return classname, listname
32
33 def makeblacklistnames(self):
34 return [
Jack Jansena05ac601999-12-12 21:41:51 +000035## "IsShowContextualMenuClick", # Can't find it in the library
36## "InitContextualMenus", # ditto
37 "GetMenuItemProperty", # difficult for the moment
38 "GetMenuItemPropertySize",
39 "SetMenuItemProperty",
40 "RemoveMenuItemProperty",
Jack Jansenf7d5aa62000-12-10 23:43:49 +000041 "SetMenuCommandProperty",
42 "GetMenuCommandProperty",
43 "GetMenuTitle", # Funny arg/returnvalue
44 "SetMenuTitle",
Jack Jansen2168e9d2001-12-16 20:18:40 +000045 "SetMenuTitleIcon", # void*
Guido van Rossum17448e21995-01-30 11:53:55 +000046 ]
47
Jack Jansene79dc762000-06-02 21:35:07 +000048 def makegreylist(self):
49 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000050 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansene79dc762000-06-02 21:35:07 +000051 'GetMenuItemRefCon2',
52 'SetMenuItemRefCon2',
53 'EnableItem',
54 'DisableItem',
55 'CheckItem',
56 'CountMItems',
57 'OpenDeskAcc',
58 'SystemEdit',
59 'SystemMenu',
60 'SetMenuFlash',
61 'InitMenus',
62 'InitProcMenu',
Jack Jansenf7d5aa62000-12-10 23:43:49 +000063 ]),
64 ('#if TARGET_API_MAC_CARBON', [
65 'DisposeMenuBar',
66 'DuplicateMenuBar',
67 'CreateNewMenu',
68 'GetFontFamilyFromMenuSelection',
69 'UpdateStandardFontMenu',
70 'CreateStandardFontMenu',
71 'RemoveMenuCommandProperty',
72 'GetMenuCommandPropertySize',
73 'IsMenuCommandEnabled',
74 'DisableMenuCommand',
75 'EnableMenuCommand',
76 'GetIndMenuItemWithCommandID',
77 'CountMenuItemsWithCommandID',
78 'MenuHasEnabledItems',
79 'EnableAllMenuItems',
80 'DisableAllMenuItems',
81 'ChangeMenuItemAttributes',
82 'GetMenuItemAttributes',
83 'ChangeMenuAttributes',
84 'GetMenuAttributes',
85 'ChangeMenuItemPropertyAttributes',
86 'GetMenuItemPropertyAttributes',
Jack Jansen2168e9d2001-12-16 20:18:40 +000087 'AcquireRootMenu',
88 'UpdateInvalidMenuItems',
89 'InvalidateMenuItems',
90 'IsMenuItemInvalid',
91 'GetMenuCommandMark',
92 'SetMenuCommandMark',
93 'GetMenuType',
94 'SetMenuItemCommandKey',
95 'GetMenuItemCommandKey',
96 'SetMenuItemIndent',
97 'GetMenuItemIndent',
98 'SetMenuItemTextWithCFString',
99 'CopyMenuItemTextAsCFString',
100 'GetMenuItemHierarchicalMenu',
101 'SetMenuItemHierarchicalMenu',
102 'SetRootMenu',
103 'IsMenuBarInvalid',
104 'InvalidateMenuEnabling',
105 'InsertMenuItemTextWithCFString',
106 'AppendMenuItemTextWithCFString',
107 'DeleteMenuItems',
108 'CopyMenuItems',
109 'IsMenuSizeInvalid',
110 'InvalidateMenuSize',
111 'SetMenuTitleWithCFString',
112 'CopyMenuTitleAsCFString',
113 'DuplicateMenu',
114 'ReleaseMenu',
115 'RetainMenu',
116 'GetMenuRetainCount',
117 'IsValidMenu',
Jack Jansene79dc762000-06-02 21:35:07 +0000118 ])]
119
Guido van Rossum17448e21995-01-30 11:53:55 +0000120 def makeblacklisttypes(self):
121 return [
122 'MCTableHandle',
123 'MCEntryPtr',
124 'MCTablePtr',
Jack Jansen1c4e6141998-04-21 15:23:55 +0000125 'AEDesc_ptr', # For now: doable, but not easy
126 'ProcessSerialNumber', # ditto
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000127 "MenuDefSpecPtr", # Too difficult for now
128 "MenuDefSpec_ptr", # ditto
129 "MenuTrackingData",
Jack Jansen2168e9d2001-12-16 20:18:40 +0000130 "void_ptr", # Don't know yet.
131 "EventRef", # For now, not exported yet.
132 "MenuItemDataPtr", # Not yet.
133 "MenuItemDataRec_ptr",
Guido van Rossum17448e21995-01-30 11:53:55 +0000134 ]
135
136 def makerepairinstructions(self):
137 return [
138 ([("Str255", "itemString", "InMode")],
139 [("*", "*", "OutMode")]),
140
141 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
142 [("InBuffer", "*", "*")]),
143
144 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
145 ("long", "*", "OutMode")],
146 [("VarVarOutBuffer", "*", "InOutMode")]),
147 ]
148
Jack Jansene180d991998-04-24 10:28:20 +0000149 def writeinitialdefs(self):
150 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
151
Guido van Rossum17448e21995-01-30 11:53:55 +0000152if __name__ == "__main__":
153 main()