Fix three PyChecker-detected gotchas.
[python/dscho.git] / Mac / Modules / menu / menuscan.py
blobc9b1b42d361dd12029d90460b359554f26049f8e
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",
47 def makegreylist(self):
48 return [
49 ('#if !TARGET_API_MAC_CARBON', [
50 'GetMenuItemRefCon2',
51 'SetMenuItemRefCon2',
52 'EnableItem',
53 'DisableItem',
54 'CheckItem',
55 'CountMItems',
56 'OpenDeskAcc',
57 'SystemEdit',
58 'SystemMenu',
59 'SetMenuFlash',
60 'InitMenus',
61 'InitProcMenu',
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',
87 ])]
89 def makeblacklisttypes(self):
90 return [
91 'MCTableHandle',
92 'MCEntryPtr',
93 'MCTablePtr',
94 'AEDesc_ptr', # For now: doable, but not easy
95 'ProcessSerialNumber', # ditto
96 "MenuDefSpecPtr", # Too difficult for now
97 "MenuDefSpec_ptr", # ditto
98 "MenuTrackingData",
101 def makerepairinstructions(self):
102 return [
103 ([("Str255", "itemString", "InMode")],
104 [("*", "*", "OutMode")]),
106 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
107 [("InBuffer", "*", "*")]),
109 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
110 ("long", "*", "OutMode")],
111 [("VarVarOutBuffer", "*", "InOutMode")]),
114 def writeinitialdefs(self):
115 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
117 if __name__ == "__main__":
118 main()