blob: 965172a96399a00a76672b594e8f9beae2a77c72 [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",
Guido van Rossum17448e21995-01-30 11:53:55 +000041 ]
42
Jack Jansene79dc762000-06-02 21:35:07 +000043 def makegreylist(self):
44 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000045 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansene79dc762000-06-02 21:35:07 +000046 'GetMenuItemRefCon2',
47 'SetMenuItemRefCon2',
48 'EnableItem',
49 'DisableItem',
50 'CheckItem',
51 'CountMItems',
52 'OpenDeskAcc',
53 'SystemEdit',
54 'SystemMenu',
55 'SetMenuFlash',
56 'InitMenus',
57 'InitProcMenu',
58 ])]
59
Guido van Rossum17448e21995-01-30 11:53:55 +000060 def makeblacklisttypes(self):
61 return [
62 'MCTableHandle',
63 'MCEntryPtr',
64 'MCTablePtr',
Jack Jansen1c4e6141998-04-21 15:23:55 +000065 'AEDesc_ptr', # For now: doable, but not easy
66 'ProcessSerialNumber', # ditto
Guido van Rossum17448e21995-01-30 11:53:55 +000067 ]
68
69 def makerepairinstructions(self):
70 return [
71 ([("Str255", "itemString", "InMode")],
72 [("*", "*", "OutMode")]),
73
74 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
75 [("InBuffer", "*", "*")]),
76
77 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
78 ("long", "*", "OutMode")],
79 [("VarVarOutBuffer", "*", "InOutMode")]),
80 ]
81
Jack Jansene180d991998-04-24 10:28:20 +000082 def writeinitialdefs(self):
83 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
84
Guido van Rossum17448e21995-01-30 11:53:55 +000085if __name__ == "__main__":
86 main()