diff options
author | Tim Peters <tim.peters@gmail.com> | 2004-07-18 06:16:08 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2004-07-18 06:16:08 (GMT) |
commit | 182b5aca27d376b08a2904bed42b751496f932f3 (patch) | |
tree | df13115820dbc879c0fe2eae488c9f8c0215a7da /Mac/Modules/drag | |
parent | e6ddc8b20b493fef2e7cffb2e1351fe1d238857e (diff) | |
download | cpython-182b5aca27d376b08a2904bed42b751496f932f3.zip cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.gz cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.bz2 |
Whitespace normalization, via reindent.py.
Diffstat (limited to 'Mac/Modules/drag')
-rw-r--r-- | Mac/Modules/drag/dragscan.py | 114 | ||||
-rw-r--r-- | Mac/Modules/drag/dragsupport.py | 246 |
2 files changed, 180 insertions, 180 deletions
diff --git a/Mac/Modules/drag/dragscan.py b/Mac/Modules/drag/dragscan.py index 282728e..923a56b 100644 --- a/Mac/Modules/drag/dragscan.py +++ b/Mac/Modules/drag/dragscan.py @@ -7,74 +7,74 @@ sys.path.append(BGENDIR) from scantools import Scanner MISSING_DEFINES=""" -kDragHasLeftSenderWindow = (1 << 0) +kDragHasLeftSenderWindow = (1 << 0) kDragInsideSenderApplication = (1 << 1) -kDragInsideSenderWindow = (1 << 2) -kDragRegionAndImage = (1 << 4) -flavorSenderOnly = (1 << 0) -flavorSenderTranslated = (1 << 1) -flavorNotSaved = (1 << 2) -flavorSystemTranslated = (1 << 8) +kDragInsideSenderWindow = (1 << 2) +kDragRegionAndImage = (1 << 4) +flavorSenderOnly = (1 << 0) +flavorSenderTranslated = (1 << 1) +flavorNotSaved = (1 << 2) +flavorSystemTranslated = (1 << 8) """ def main(): - input = INCLUDEDIR + "Drag.h" - output = "draggen.py" - defsoutput = TOOLBOXDIR + "Dragconst.py" - scanner = MyScanner(input, output, defsoutput) - scanner.scan() - scanner.close() - print "=== Testing definitions output code ===" - execfile(defsoutput, {}, {}) - print "=== Done scanning and generating, now doing 'import dragsupport' ===" - import dragsupport - print "=== Done. It's up to you to compile Dragmodule.c ===" + input = INCLUDEDIR + "Drag.h" + output = "draggen.py" + defsoutput = TOOLBOXDIR + "Dragconst.py" + scanner = MyScanner(input, output, defsoutput) + scanner.scan() + scanner.close() + print "=== Testing definitions output code ===" + execfile(defsoutput, {}, {}) + print "=== Done scanning and generating, now doing 'import dragsupport' ===" + import dragsupport + print "=== Done. It's up to you to compile Dragmodule.c ===" class MyScanner(Scanner): - def destination(self, type, name, arglist): - classname = "Function" - listname = "functions" - if arglist: - t, n, m = arglist[0] - if t in ('DragReference', 'DragRef') and m == "InMode": - classname = "Method" - listname = "methods" - return classname, listname + def destination(self, type, name, arglist): + classname = "Function" + listname = "functions" + if arglist: + t, n, m = arglist[0] + if t in ('DragReference', 'DragRef') and m == "InMode": + classname = "Method" + listname = "methods" + return classname, listname - def writeinitialdefs(self): - self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") - self.defsfile.write("from Carbon.TextEdit import *\n") - self.defsfile.write("from Carbon.QuickDraw import *\n") - self.defsfile.write("fkDragActionAll = -1\n") - self.defsfile.write("\n") - # Defines unparseable in Drag.h - self.defsfile.write(MISSING_DEFINES) + def writeinitialdefs(self): + self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") + self.defsfile.write("from Carbon.TextEdit import *\n") + self.defsfile.write("from Carbon.QuickDraw import *\n") + self.defsfile.write("fkDragActionAll = -1\n") + self.defsfile.write("\n") + # Defines unparseable in Drag.h + self.defsfile.write(MISSING_DEFINES) - def makeblacklistnames(self): - return [ - "kDragActionAll", - ] + def makeblacklistnames(self): + return [ + "kDragActionAll", + ] - def makeblacklisttypes(self): - return [ - "DragTrackingHandlerUPP", - "DragReceiveHandlerUPP", - "DragSendDataUPP", - "DragInputUPP", - "DragDrawingUPP", - ] + def makeblacklisttypes(self): + return [ + "DragTrackingHandlerUPP", + "DragReceiveHandlerUPP", + "DragSendDataUPP", + "DragInputUPP", + "DragDrawingUPP", + ] - def makerepairinstructions(self): - return [ - ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")], - [("OptionalInBuffer", "*", "*")]), - - ([("void", "*", "OutMode"), ("Size", "*", "OutMode")], - [("VarOutBuffer", "*", "InOutMode")]), - - ] + def makerepairinstructions(self): + return [ + ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")], + [("OptionalInBuffer", "*", "*")]), + + ([("void", "*", "OutMode"), ("Size", "*", "OutMode")], + [("VarOutBuffer", "*", "InOutMode")]), + + ] if __name__ == "__main__": - main() + main() diff --git a/Mac/Modules/drag/dragsupport.py b/Mac/Modules/drag/dragsupport.py index c200950..45838ef 100644 --- a/Mac/Modules/drag/dragsupport.py +++ b/Mac/Modules/drag/dragsupport.py @@ -6,16 +6,16 @@ import string # Declarations that change for each manager -MACHEADERFILE = 'Drag.h' # The Apple header file -MODNAME = '_Drag' # The name of the module -OBJECTNAME = 'DragObj' # The basic name of the objects used here +MACHEADERFILE = 'Drag.h' # The Apple header file +MODNAME = '_Drag' # The name of the module +OBJECTNAME = 'DragObj' # The basic name of the objects used here # The following is *usually* unchanged but may still require tuning -MODPREFIX = 'Drag' # The prefix for module-wide routines -OBJECTTYPE = 'DragRef' # The C type used to represent them -OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods +MODPREFIX = 'Drag' # The prefix for module-wide routines +OBJECTTYPE = 'DragRef' # The C type used to represent them +OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner -OUTPUTFILE = MODNAME + "module.c" # The file generated by this program +OUTPUTFILE = MODNAME + "module.c" # The file generated by this program from macsupport import * @@ -69,81 +69,81 @@ static pascal OSErr dragglue_TrackingHandler(DragTrackingMessage theMessage, WindowPtr theWindow, void *handlerRefCon, DragReference theDrag) { - PyObject *args, *rv; - int i; - - args = Py_BuildValue("hO&O&", theMessage, DragObj_New, theDrag, WinObj_WhichWindow, theWindow); - if ( args == NULL ) - return -1; - rv = PyEval_CallObject((PyObject *)handlerRefCon, args); - Py_DECREF(args); - if ( rv == NULL ) { - PySys_WriteStderr("Drag: Exception in TrackingHandler\\n"); - PyErr_Print(); - return -1; - } - i = -1; - if ( rv == Py_None ) - i = 0; - else - PyArg_Parse(rv, "l", &i); - Py_DECREF(rv); - return i; + PyObject *args, *rv; + int i; + + args = Py_BuildValue("hO&O&", theMessage, DragObj_New, theDrag, WinObj_WhichWindow, theWindow); + if ( args == NULL ) + return -1; + rv = PyEval_CallObject((PyObject *)handlerRefCon, args); + Py_DECREF(args); + if ( rv == NULL ) { + PySys_WriteStderr("Drag: Exception in TrackingHandler\\n"); + PyErr_Print(); + return -1; + } + i = -1; + if ( rv == Py_None ) + i = 0; + else + PyArg_Parse(rv, "l", &i); + Py_DECREF(rv); + return i; } static pascal OSErr dragglue_ReceiveHandler(WindowPtr theWindow, void *handlerRefCon, DragReference theDrag) { - PyObject *args, *rv; - int i; - - args = Py_BuildValue("O&O&", DragObj_New, theDrag, WinObj_WhichWindow, theWindow); - if ( args == NULL ) - return -1; - rv = PyEval_CallObject((PyObject *)handlerRefCon, args); - Py_DECREF(args); - if ( rv == NULL ) { - PySys_WriteStderr("Drag: Exception in ReceiveHandler\\n"); - PyErr_Print(); - return -1; - } - i = -1; - if ( rv == Py_None ) - i = 0; - else - PyArg_Parse(rv, "l", &i); - Py_DECREF(rv); - return i; + PyObject *args, *rv; + int i; + + args = Py_BuildValue("O&O&", DragObj_New, theDrag, WinObj_WhichWindow, theWindow); + if ( args == NULL ) + return -1; + rv = PyEval_CallObject((PyObject *)handlerRefCon, args); + Py_DECREF(args); + if ( rv == NULL ) { + PySys_WriteStderr("Drag: Exception in ReceiveHandler\\n"); + PyErr_Print(); + return -1; + } + i = -1; + if ( rv == Py_None ) + i = 0; + else + PyArg_Parse(rv, "l", &i); + Py_DECREF(rv); + return i; } static pascal OSErr dragglue_SendData(FlavorType theType, void *dragSendRefCon, ItemReference theItem, DragReference theDrag) { - DragObjObject *self = (DragObjObject *)dragSendRefCon; - PyObject *args, *rv; - int i; - - if ( self->sendproc == NULL ) - return -1; - args = Py_BuildValue("O&l", PyMac_BuildOSType, theType, theItem); - if ( args == NULL ) - return -1; - rv = PyEval_CallObject(self->sendproc, args); - Py_DECREF(args); - if ( rv == NULL ) { - PySys_WriteStderr("Drag: Exception in SendDataHandler\\n"); - PyErr_Print(); - return -1; - } - i = -1; - if ( rv == Py_None ) - i = 0; - else - PyArg_Parse(rv, "l", &i); - Py_DECREF(rv); - return i; + DragObjObject *self = (DragObjObject *)dragSendRefCon; + PyObject *args, *rv; + int i; + + if ( self->sendproc == NULL ) + return -1; + args = Py_BuildValue("O&l", PyMac_BuildOSType, theType, theItem); + if ( args == NULL ) + return -1; + rv = PyEval_CallObject(self->sendproc, args); + Py_DECREF(args); + if ( rv == NULL ) { + PySys_WriteStderr("Drag: Exception in SendDataHandler\\n"); + PyErr_Print(); + return -1; + } + i = -1; + if ( rv == Py_None ) + i = 0; + else + PyArg_Parse(rv, "l", &i); + Py_DECREF(rv); + return i; } #if 0 @@ -165,8 +165,8 @@ dragglue_Drawing(xxxx """ initstuff = initstuff + """ - PyMac_INIT_TOOLBOX_OBJECT_NEW(DragRef, DragObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DragRef, DragObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(DragRef, DragObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DragRef, DragObj_Convert); """ variablestuff = """ @@ -177,33 +177,33 @@ dragglue_SendDataUPP = NewDragSendDataUPP(dragglue_SendData); dragglue_InputUPP = NewDragInputUPP(dragglue_Input); dragglue_DrawingUPP = NewDragDrawingUPP(dragglue_Drawing); #endif -""" +""" class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("""if (itself == NULL) { - PyErr_SetString(Drag_Error,"Cannot create null Drag"); - return NULL; - }""") - def outputFreeIt(self, itselfname): - ## Output("DisposeDrag(%s);", itselfname) - Output("Py_XDECREF(self->sendproc);") - ## Output("Py_XDECREF(self->inputproc);") - ## Output("Py_XDECREF(self->drawingproc);") - - def outputStructMembers(self): - GlobalObjectDefinition.outputStructMembers(self) - Output("PyObject *sendproc;") - ## Output("PyObject *inputproc;") - ## Output("PyObject *drawingproc;") - - def outputInitStructMembers(self): - GlobalObjectDefinition.outputInitStructMembers(self) - Output("it->sendproc = NULL;") - ## Output("it->inputproc = NULL;") - ## Output("it->drawingproc = NULL;") - - + def outputCheckNewArg(self): + Output("""if (itself == NULL) { + PyErr_SetString(Drag_Error,"Cannot create null Drag"); + return NULL; + }""") + def outputFreeIt(self, itselfname): + ## Output("DisposeDrag(%s);", itselfname) + Output("Py_XDECREF(self->sendproc);") + ## Output("Py_XDECREF(self->inputproc);") + ## Output("Py_XDECREF(self->drawingproc);") + + def outputStructMembers(self): + GlobalObjectDefinition.outputStructMembers(self) + Output("PyObject *sendproc;") + ## Output("PyObject *inputproc;") + ## Output("PyObject *drawingproc;") + + def outputInitStructMembers(self): + GlobalObjectDefinition.outputInitStructMembers(self) + Output("it->sendproc = NULL;") + ## Output("it->inputproc = NULL;") + ## Output("it->drawingproc = NULL;") + + # Create the generator groups and link them module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff, variablestuff) object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE) @@ -228,15 +228,15 @@ installtracking_body = """ PyObject *callback; WindowPtr theWindow = NULL; OSErr _err; - + if ( !PyArg_ParseTuple(_args, "O|O&", &callback, WinObj_Convert, &theWindow) ) - return NULL; - Py_INCREF(callback); /* Cannot decref later, too bad */ + return NULL; + Py_INCREF(callback); /* Cannot decref later, too bad */ _err = InstallTrackingHandler(dragglue_TrackingHandlerUPP, theWindow, (void *)callback); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; """ installtracking = ManualGenerator("InstallTrackingHandler", installtracking_body) module.add(installtracking) @@ -245,15 +245,15 @@ installreceive_body = """ PyObject *callback; WindowPtr theWindow = NULL; OSErr _err; - + if ( !PyArg_ParseTuple(_args, "O|O&", &callback, WinObj_Convert, &theWindow) ) - return NULL; - Py_INCREF(callback); /* Cannot decref later, too bad */ + return NULL; + Py_INCREF(callback); /* Cannot decref later, too bad */ _err = InstallReceiveHandler(dragglue_ReceiveHandlerUPP, theWindow, (void *)callback); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; """ installreceive = ManualGenerator("InstallReceiveHandler", installreceive_body) module.add(installreceive) @@ -261,14 +261,14 @@ module.add(installreceive) removetracking_body = """ WindowPtr theWindow = NULL; OSErr _err; - + if ( !PyArg_ParseTuple(_args, "|O&", WinObj_Convert, &theWindow) ) - return NULL; + return NULL; _err = RemoveTrackingHandler(dragglue_TrackingHandlerUPP, theWindow); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; """ removetracking = ManualGenerator("RemoveTrackingHandler", removetracking_body) module.add(removetracking) @@ -276,14 +276,14 @@ module.add(removetracking) removereceive_body = """ WindowPtr theWindow = NULL; OSErr _err; - + if ( !PyArg_ParseTuple(_args, "|O&", WinObj_Convert, &theWindow) ) - return NULL; + return NULL; _err = RemoveReceiveHandler(dragglue_ReceiveHandlerUPP, theWindow); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; """ removereceive = ManualGenerator("RemoveReceiveHandler", removereceive_body) module.add(removereceive) |