|
1 # Scan <Menus.h>, generating menugen.py. |
|
2 import sys |
|
3 from bgenlocations import TOOLBOXDIR, BGENDIR |
|
4 sys.path.append(BGENDIR) |
|
5 |
|
6 from scantools import Scanner |
|
7 |
|
8 def main(): |
|
9 input = "Menus.h" |
|
10 output = "menugen.py" |
|
11 defsoutput = TOOLBOXDIR + "Menus.py" |
|
12 scanner = MyScanner(input, output, defsoutput) |
|
13 scanner.scan() |
|
14 scanner.close() |
|
15 print "=== Testing definitions output code ===" |
|
16 execfile(defsoutput, {}, {}) |
|
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 |
|
21 class 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] |
|
28 if t in ("MenuHandle", "MenuRef") and m == "InMode": |
|
29 classname = "Method" |
|
30 listname = "methods" |
|
31 return classname, listname |
|
32 |
|
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* |
|
46 # OS8 calls: |
|
47 'GetMenuItemRefCon2', |
|
48 'SetMenuItemRefCon2', |
|
49 'EnableItem', |
|
50 'DisableItem', |
|
51 'CheckItem', |
|
52 'CountMItems', |
|
53 'OpenDeskAcc', |
|
54 'SystemEdit', |
|
55 'SystemMenu', |
|
56 'SetMenuFlash', |
|
57 'InitMenus', |
|
58 'InitProcMenu', |
|
59 ] |
|
60 |
|
61 def makeblacklisttypes(self): |
|
62 return [ |
|
63 'MCTableHandle', |
|
64 'MCEntryPtr', |
|
65 'MCTablePtr', |
|
66 'AEDesc_ptr', # For now: doable, but not easy |
|
67 'ProcessSerialNumber', # ditto |
|
68 "MenuDefSpecPtr", # Too difficult for now |
|
69 "MenuDefSpec_ptr", # ditto |
|
70 "MenuTrackingData", |
|
71 "void_ptr", # Don't know yet. |
|
72 "EventRef", # For now, not exported yet. |
|
73 "MenuItemDataPtr", # Not yet. |
|
74 "MenuItemDataRec_ptr", |
|
75 ] |
|
76 |
|
77 def makerepairinstructions(self): |
|
78 return [ |
|
79 ([("Str255", "itemString", "InMode")], |
|
80 [("*", "*", "OutMode")]), |
|
81 |
|
82 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], |
|
83 [("InBuffer", "*", "*")]), |
|
84 |
|
85 ([("void", "*", "OutMode"), ("long", "*", "InMode"), |
|
86 ("long", "*", "OutMode")], |
|
87 [("VarVarOutBuffer", "*", "InOutMode")]), |
|
88 ([("MenuRef", 'outHierMenu', "OutMode")], |
|
89 [("OptMenuRef", 'outHierMenu', "OutMode")]), |
|
90 ] |
|
91 |
|
92 def writeinitialdefs(self): |
|
93 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") |
|
94 |
|
95 if __name__ == "__main__": |
|
96 main() |