blob: fa87ba33dff60588fd656dff351bd86c9ed31dd8 [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
43 def makeblacklisttypes(self):
44 return [
45 'MCTableHandle',
46 'MCEntryPtr',
47 'MCTablePtr',
Jack Jansen1c4e6141998-04-21 15:23:55 +000048 'AEDesc_ptr', # For now: doable, but not easy
49 'ProcessSerialNumber', # ditto
Guido van Rossum17448e21995-01-30 11:53:55 +000050 ]
51
52 def makerepairinstructions(self):
53 return [
54 ([("Str255", "itemString", "InMode")],
55 [("*", "*", "OutMode")]),
56
57 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
58 [("InBuffer", "*", "*")]),
59
60 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
61 ("long", "*", "OutMode")],
62 [("VarVarOutBuffer", "*", "InOutMode")]),
63 ]
64
Jack Jansene180d991998-04-24 10:28:20 +000065 def writeinitialdefs(self):
66 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
67
Guido van Rossum17448e21995-01-30 11:53:55 +000068if __name__ == "__main__":
69 main()