Jack Jansen | c4f6331 | 1999-06-21 15:14:26 +0000 | [diff] [blame^] | 1 | # Scan <Drag.h>, generating draggen.py. |
| 2 | import sys |
| 3 | import os |
| 4 | BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen') |
| 5 | sys.path.append(BGENDIR) |
| 6 | |
| 7 | from scantools import Scanner |
| 8 | from bgenlocations import TOOLBOXDIR, INCLUDEDIR |
| 9 | |
| 10 | MISSING_DEFINES=""" |
| 11 | kDragHasLeftSenderWindow = (1 << 0) |
| 12 | kDragInsideSenderApplication = (1 << 1) |
| 13 | kDragInsideSenderWindow = (1 << 2) |
| 14 | kDragRegionAndImage = (1 << 4) |
| 15 | flavorSenderOnly = (1 << 0) |
| 16 | flavorSenderTranslated = (1 << 1) |
| 17 | flavorNotSaved = (1 << 2) |
| 18 | flavorSystemTranslated = (1 << 8) |
| 19 | """ |
| 20 | |
| 21 | |
| 22 | def main(): |
| 23 | input = INCLUDEDIR + "Drag.h" |
| 24 | output = "draggen.py" |
| 25 | defsoutput = TOOLBOXDIR + "Dragconst.py" |
| 26 | scanner = MyScanner(input, output, defsoutput) |
| 27 | scanner.scan() |
| 28 | scanner.close() |
| 29 | print "=== Done scanning and generating, now doing 'import dragsupport' ===" |
| 30 | import dragsupport |
| 31 | print "=== Done. It's up to you to compile Dragmodule.c ===" |
| 32 | |
| 33 | class MyScanner(Scanner): |
| 34 | |
| 35 | def destination(self, type, name, arglist): |
| 36 | classname = "Function" |
| 37 | listname = "functions" |
| 38 | if arglist: |
| 39 | t, n, m = arglist[0] |
| 40 | if t == 'DragReference' and m == "InMode": |
| 41 | classname = "Method" |
| 42 | listname = "methods" |
| 43 | return classname, listname |
| 44 | |
| 45 | def writeinitialdefs(self): |
| 46 | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") |
| 47 | self.defsfile.write("from TextEdit import *\n") |
| 48 | self.defsfile.write("from QuickDraw import *\n") |
| 49 | self.defsfile.write("\n") |
| 50 | # Defines unparseable in Drag.h |
| 51 | self.defsfile.write(MISSING_DEFINES) |
| 52 | |
| 53 | def makeblacklistnames(self): |
| 54 | return [ |
| 55 | ] |
| 56 | |
| 57 | def makeblacklisttypes(self): |
| 58 | return [ |
| 59 | "DragTrackingHandlerUPP", |
| 60 | "DragReceiveHandlerUPP", |
| 61 | "DragSendDataUPP", |
| 62 | "DragInputUPP", |
| 63 | "DragDrawingUPP", |
| 64 | ] |
| 65 | |
| 66 | def makerepairinstructions(self): |
| 67 | return [ |
| 68 | ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")], |
| 69 | [("OptionalInBuffer", "*", "*")]), |
| 70 | |
| 71 | ([("void", "*", "OutMode"), ("Size", "*", "OutMode")], |
| 72 | [("VarOutBuffer", "*", "InOutMode")]), |
| 73 | |
| 74 | ] |
| 75 | |
| 76 | if __name__ == "__main__": |
| 77 | main() |