blob: c9b1b42d361dd12029d90460b359554f26049f8e [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",
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',
86
Jack Jansene79dc762000-06-02 21:35:07 +000087 ])]
88
Guido van Rossum17448e21995-01-30 11:53:55 +000089 def makeblacklisttypes(self):
90 return [
91 'MCTableHandle',
92 'MCEntryPtr',
93 'MCTablePtr',
Jack Jansen1c4e6141998-04-21 15:23:55 +000094 'AEDesc_ptr', # For now: doable, but not easy
95 'ProcessSerialNumber', # ditto
Jack Jansenf7d5aa62000-12-10 23:43:49 +000096 "MenuDefSpecPtr", # Too difficult for now
97 "MenuDefSpec_ptr", # ditto
98 "MenuTrackingData",
Guido van Rossum17448e21995-01-30 11:53:55 +000099 ]
100
101 def makerepairinstructions(self):
102 return [
103 ([("Str255", "itemString", "InMode")],
104 [("*", "*", "OutMode")]),
105
106 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
107 [("InBuffer", "*", "*")]),
108
109 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
110 ("long", "*", "OutMode")],
111 [("VarVarOutBuffer", "*", "InOutMode")]),
112 ]
113
Jack Jansene180d991998-04-24 10:28:20 +0000114 def writeinitialdefs(self):
115 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
116
Guido van Rossum17448e21995-01-30 11:53:55 +0000117if __name__ == "__main__":
118 main()