source: trunk/essentials/dev-lang/python/Mac/Modules/drag/dragscan.py@ 3397

Last change on this file since 3397 was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 2.5 KB
Line 
1# Scan <Drag.h>, generating draggen.py.
2import sys
3import os
4from bgenlocations import TOOLBOXDIR, BGENDIR, INCLUDEDIR
5sys.path.append(BGENDIR)
6
7from scantools import Scanner
8
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()
28 print "=== Testing definitions output code ==="
29 execfile(defsoutput, {}, {})
30 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]
41 if t in ('DragReference', 'DragRef') and m == "InMode":
42 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")
48 self.defsfile.write("from Carbon.TextEdit import *\n")
49 self.defsfile.write("from Carbon.QuickDraw import *\n")
50 self.defsfile.write("fkDragActionAll = -1\n")
51 self.defsfile.write("\n")
52 # Defines unparseable in Drag.h
53 self.defsfile.write(MISSING_DEFINES)
54
55 def makeblacklistnames(self):
56 return [
57 "kDragActionAll",
58 ]
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()
Note: See TracBrowser for help on using the repository browser.