This commit was manufactured by cvs2svn to create tag 'r221'.
[python/dscho.git] / Mac / Modules / menu / menuscan.py
blob11be8f219092b4d56f4dc8326ceaf4e947398ccd
1 # Scan <Menus.h>, generating menugen.py.
2 import sys
3 import os
4 BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
5 sys.path.append(BGENDIR)
7 from scantools import Scanner
8 from bgenlocations import TOOLBOXDIR
10 def main():
11 input = "Menus.h"
12 output = "menugen.py"
13 defsoutput = TOOLBOXDIR + "Menus.py"
14 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 ==="
21 class MyScanner(Scanner):
23 def destination(self, type, name, arglist):
24 classname = "Function"
25 listname = "functions"
26 if arglist:
27 t, n, m = arglist[0]
28 if t in ("MenuHandle", "MenuRef") and m == "InMode":
29 classname = "Method"
30 listname = "methods"
31 return classname, listname
33 def makeblacklistnames(self):
34 return [
35 ## "IsShowContextualMenuClick", # Can't find it in the library
36 ## "InitContextualMenus", # ditto
37 "GetMenuItemProperty", # difficult for the moment
38 "GetMenuItemPropertySize",
39 "SetMenuItemProperty",
40 "RemoveMenuItemProperty",
41 "SetMenuCommandProperty",
42 "GetMenuCommandProperty",
43 "GetMenuTitle", # Funny arg/returnvalue
44 "SetMenuTitle",
45 "SetMenuTitleIcon", # void*
48 def makegreylist(self):
49 return [
50 ('#if !TARGET_API_MAC_CARBON', [
51 'GetMenuItemRefCon2',
52 'SetMenuItemRefCon2',
53 'EnableItem',
54 'DisableItem',
55 'CheckItem',
56 'CountMItems',
57 'OpenDeskAcc',
58 'SystemEdit',
59 'SystemMenu',
60 'SetMenuFlash',
61 'InitMenus',
62 'InitProcMenu',
63 ]),
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',
87 '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',
120 def makeblacklisttypes(self):
121 return [
122 'MCTableHandle',
123 'MCEntryPtr',
124 'MCTablePtr',
125 'AEDesc_ptr', # For now: doable, but not easy
126 'ProcessSerialNumber', # ditto
127 "MenuDefSpecPtr", # Too difficult for now
128 "MenuDefSpec_ptr", # ditto
129 "MenuTrackingData",
130 "void_ptr", # Don't know yet.
131 "EventRef", # For now, not exported yet.
132 "MenuItemDataPtr", # Not yet.
133 "MenuItemDataRec_ptr",
136 def makerepairinstructions(self):
137 return [
138 ([("Str255", "itemString", "InMode")],
139 [("*", "*", "OutMode")]),
141 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
142 [("InBuffer", "*", "*")]),
144 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
145 ("long", "*", "OutMode")],
146 [("VarVarOutBuffer", "*", "InOutMode")]),
147 ([("MenuRef", 'outHierMenu', "OutMode")],
148 [("OptMenuRef", 'outHierMenu', "OutMode")]),
151 def writeinitialdefs(self):
152 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
154 if __name__ == "__main__":
155 main()