| 1 | # Scan <Drag.h>, generating draggen.py.
|
|---|
| 2 | import sys
|
|---|
| 3 | import os
|
|---|
| 4 | from bgenlocations import TOOLBOXDIR, BGENDIR, INCLUDEDIR
|
|---|
| 5 | sys.path.append(BGENDIR)
|
|---|
| 6 |
|
|---|
| 7 | from scantools import Scanner
|
|---|
| 8 |
|
|---|
| 9 | MISSING_DEFINES="""
|
|---|
| 10 | kDragHasLeftSenderWindow = (1 << 0)
|
|---|
| 11 | kDragInsideSenderApplication = (1 << 1)
|
|---|
| 12 | kDragInsideSenderWindow = (1 << 2)
|
|---|
| 13 | kDragRegionAndImage = (1 << 4)
|
|---|
| 14 | flavorSenderOnly = (1 << 0)
|
|---|
| 15 | flavorSenderTranslated = (1 << 1)
|
|---|
| 16 | flavorNotSaved = (1 << 2)
|
|---|
| 17 | flavorSystemTranslated = (1 << 8)
|
|---|
| 18 | """
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | def 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 |
|
|---|
| 34 | class 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 |
|
|---|
| 79 | if __name__ == "__main__":
|
|---|
| 80 | main()
|
|---|