blob: 282728e288affbb68ece51e31f45194d283d2d0d [file] [log] [blame]
Jack Jansenc4f63311999-06-21 15:14:26 +00001# Scan <Drag.h>, generating draggen.py.
2import sys
3import os
Jack Jansenc4ff1942002-08-05 21:13:07 +00004from bgenlocations import TOOLBOXDIR, BGENDIR, INCLUDEDIR
Jack Jansenc4f63311999-06-21 15:14:26 +00005sys.path.append(BGENDIR)
6
7from scantools import Scanner
Jack Jansenc4f63311999-06-21 15:14:26 +00008
9MISSING_DEFINES="""
10kDragHasLeftSenderWindow = (1 << 0)
11kDragInsideSenderApplication = (1 << 1)
12kDragInsideSenderWindow = (1 << 2)
13kDragRegionAndImage = (1 << 4)
14flavorSenderOnly = (1 << 0)
15flavorSenderTranslated = (1 << 1)
16flavorNotSaved = (1 << 2)
17flavorSystemTranslated = (1 << 8)
18"""
19
20
21def main():
22 input = INCLUDEDIR + "Drag.h"
23 output = "draggen.py"
24 defsoutput = TOOLBOXDIR + "Dragconst.py"
25 scanner = MyScanner(input, output, defsoutput)
26 scanner.scan()
27 scanner.close()
Jack Jansen87eea882002-08-15 21:48:16 +000028 print "=== Testing definitions output code ==="
29 execfile(defsoutput, {}, {})
Jack Jansenc4f63311999-06-21 15:14:26 +000030 print "=== Done scanning and generating, now doing 'import dragsupport' ==="
31 import dragsupport
32 print "=== Done. It's up to you to compile Dragmodule.c ==="
33
34class MyScanner(Scanner):
35
36 def destination(self, type, name, arglist):
37 classname = "Function"
38 listname = "functions"
39 if arglist:
40 t, n, m = arglist[0]
Jack Jansenecdaadb2001-02-05 13:47:13 +000041 if t in ('DragReference', 'DragRef') and m == "InMode":
Jack Jansenc4f63311999-06-21 15:14:26 +000042 classname = "Method"
43 listname = "methods"
44 return classname, listname
45
46 def writeinitialdefs(self):
47 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
Jack Jansen7ca993e2002-08-15 22:05:58 +000048 self.defsfile.write("from Carbon.TextEdit import *\n")
49 self.defsfile.write("from Carbon.QuickDraw import *\n")
Jack Jansenda6081f2003-12-03 23:20:13 +000050 self.defsfile.write("fkDragActionAll = -1\n")
Jack Jansenc4f63311999-06-21 15:14:26 +000051 self.defsfile.write("\n")
52 # Defines unparseable in Drag.h
53 self.defsfile.write(MISSING_DEFINES)
54
55 def makeblacklistnames(self):
56 return [
Jack Jansenda6081f2003-12-03 23:20:13 +000057 "kDragActionAll",
Jack Jansenc4f63311999-06-21 15:14:26 +000058 ]
59
60 def makeblacklisttypes(self):
61 return [
62 "DragTrackingHandlerUPP",
63 "DragReceiveHandlerUPP",
64 "DragSendDataUPP",
65 "DragInputUPP",
66 "DragDrawingUPP",
67 ]
68
69 def makerepairinstructions(self):
70 return [
71 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
72 [("OptionalInBuffer", "*", "*")]),
73
74 ([("void", "*", "OutMode"), ("Size", "*", "OutMode")],
75 [("VarOutBuffer", "*", "InOutMode")]),
76
77 ]
78
79if __name__ == "__main__":
80 main()