summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/waste
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-07-18 06:16:08 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-07-18 06:16:08 (GMT)
commit182b5aca27d376b08a2904bed42b751496f932f3 (patch)
treedf13115820dbc879c0fe2eae488c9f8c0215a7da /Mac/Modules/waste
parente6ddc8b20b493fef2e7cffb2e1351fe1d238857e (diff)
downloadcpython-182b5aca27d376b08a2904bed42b751496f932f3.zip
cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.gz
cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.bz2
Whitespace normalization, via reindent.py.
Diffstat (limited to 'Mac/Modules/waste')
-rw-r--r--Mac/Modules/waste/wastescan.py260
-rw-r--r--Mac/Modules/waste/wastesupport.py441
2 files changed, 350 insertions, 351 deletions
diff --git a/Mac/Modules/waste/wastescan.py b/Mac/Modules/waste/wastescan.py
index 8298f26..b5a2b43 100644
--- a/Mac/Modules/waste/wastescan.py
+++ b/Mac/Modules/waste/wastescan.py
@@ -7,9 +7,9 @@ sys.path.append(BGENDIR)
from scantools import Scanner
WASTEDIR='/Users/jack/src/waste/C_C++ Headers/'
-
+
if not os.path.exists(WASTEDIR):
- raise 'Error: not found: %s', WASTEDIR
+ raise 'Error: not found: %s', WASTEDIR
OBJECT = "TEHandle"
SHORT = "waste"
@@ -17,136 +17,136 @@ OBJECT = "WEReference"
OBJECT2 = "WEObjectReference"
def main():
- input = WASTEDIR + "WASTE.h"
- output = SHORT + "gen.py"
- defsoutput = os.path.join(os.path.split(TOOLBOXDIR)[0], "WASTEconst.py")
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
-## scanner.gentypetest(SHORT+"typetest.py")
- scanner.close()
- print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
- print "=== Done scanning and generating, now importing the generated code... ==="
- exec "import " + SHORT + "support"
- print "=== Done. It's up to you to compile it now! ==="
+ input = WASTEDIR + "WASTE.h"
+ output = SHORT + "gen.py"
+ defsoutput = os.path.join(os.path.split(TOOLBOXDIR)[0], "WASTEconst.py")
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+## scanner.gentypetest(SHORT+"typetest.py")
+ scanner.close()
+ print "=== Testing definitions output code ==="
+ execfile(defsoutput, {}, {})
+ print "=== Done scanning and generating, now importing the generated code... ==="
+ exec "import " + SHORT + "support"
+ print "=== Done. It's up to you to compile it now! ==="
#class MyScanner(Scanner_PreUH3):
class MyScanner(Scanner):
- def destination(self, type, name, arglist):
- classname = "Function"
- listname = "functions"
- if arglist:
- t, n, m = arglist[-1]
- # This is non-functional today
- if t == OBJECT and m == "InMode":
- classname = "Method"
- listname = "methods"
- else:
- t, n, m = arglist[0]
- if t == OBJECT2 and m == "InMode":
- classname = "Method2"
- listname = "methods2"
- return classname, listname
-
- def writeinitialdefs(self):
- self.defsfile.write("kPascalStackBased = None # workaround for header parsing\n")
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
-
- def makeblacklistnames(self):
- return [
- "WEDispose",
- "WESetInfo", # Argument type unknown...
- "WEGetInfo",
- "WEVersion", # Unfortunately...
- "WEPut", # XXXX TBD: needs array of flavortypes.
- "WEGetOneAttribute", # XXXX TBD: output buffer
- # Incompatible constant definitions
- "weDoAutoScroll",
- "weDoOutlineHilite",
- "weDoReadOnly",
- "weDoUndo",
- "weDoIntCutAndPaste",
- "weDoDragAndDrop",
- "weDoInhibitRecal",
- "weDoUseTempMem",
- "weDoDrawOffscreen",
- "weDoInhibitRedraw",
- "weDoMonoStyled",
- "weDoMultipleUndo",
- "weDoNoKeyboardSync",
- "weDoInhibitICSupport",
- "weDoInhibitColor",
- ]
-
- def makeblacklisttypes(self):
- return [
- "DragReference", # For now...
- "UniversalProcPtr",
- "WEFontIDToNameUPP",
- "WEFontNameToIDUPP",
- "WEClickLoopUPP",
- "WEScrollUPP",
- "WETSMPreUpdateUPP",
- "WETSMPostUpdateUPP",
- "WEPreTrackDragUPP",
- "WETranslateDragUPP",
- "WEHiliteDropAreaUPP",
- "WEDrawTextUPP",
- "WEDrawTSMHiliteUPP",
- "WEPixelToCharUPP",
- "WECharToPixelUPP",
- "WELineBreakUPP",
- "WEWordBreakUPP",
- "WECharByteUPP",
- "WECharTypeUPP",
- "WEEraseUPP",
- "WEFluxUPP",
- "WENewObjectUPP",
- "WEDisposeObjectUPP",
- "WEDrawObjectUPP",
- "WEClickObjectUPP",
- "WEStreamObjectUPP",
- "WEHoverObjectUPP",
- "WERuler", # XXXX To be done
- "WERuler_ptr", # ditto
- "WEParaInfo", # XXXX To be done
- "WEPrintSession", # XXXX To be done
- "WEPrintOptions_ptr", # XXXX To be done
- ]
-
- def makerepairinstructions(self):
- return [
- ([("void_ptr", "*", "InMode"), ("SInt32", "*", "InMode")],
- [("InBuffer", "*", "*")]),
-
- # WEContinuousStyle
- ([("WEStyleMode", "ioMode", "OutMode"), ("TextStyle", "outTextStyle", "OutMode")],
- [("WEStyleMode", "*", "InOutMode"), ("TextStyle", "*", "*")]),
-
- # WECopyRange
- ([('Handle', 'outText', 'InMode'), ('StScrpHandle', 'outStyles', 'InMode'),
- ('WESoupHandle', 'outSoup', 'InMode')],
- [('OptHandle', '*', '*'), ('OptStScrpHandle', '*', '*'),
- ('OptSoupHandle', '*', '*')]),
-
- # WEInsert
- ([('StScrpHandle', 'inStyles', 'InMode'), ('WESoupHandle', 'inSoup', 'InMode')],
- [('OptStScrpHandle', '*', '*'), ('OptSoupHandle', '*', '*')]),
-
- # WEGetObjectOwner
- ("WEGetObjectOwner",
- [('WEReference', '*', 'ReturnMode')],
- [('ExistingWEReference', '*', 'ReturnMode')]),
-
- # WEFindParagraph
- ([("char_ptr", "inKey", "InMode")],
- [("stringptr", "*", "*")]),
-
- # WESetOneAttribute
- ([("void_ptr", "*", "InMode"), ("ByteCount", "*", "InMode")],
- [("InBuffer", "*", "*")]),
- ]
-
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[-1]
+ # This is non-functional today
+ if t == OBJECT and m == "InMode":
+ classname = "Method"
+ listname = "methods"
+ else:
+ t, n, m = arglist[0]
+ if t == OBJECT2 and m == "InMode":
+ classname = "Method2"
+ listname = "methods2"
+ return classname, listname
+
+ def writeinitialdefs(self):
+ self.defsfile.write("kPascalStackBased = None # workaround for header parsing\n")
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+
+ def makeblacklistnames(self):
+ return [
+ "WEDispose",
+ "WESetInfo", # Argument type unknown...
+ "WEGetInfo",
+ "WEVersion", # Unfortunately...
+ "WEPut", # XXXX TBD: needs array of flavortypes.
+ "WEGetOneAttribute", # XXXX TBD: output buffer
+ # Incompatible constant definitions
+ "weDoAutoScroll",
+ "weDoOutlineHilite",
+ "weDoReadOnly",
+ "weDoUndo",
+ "weDoIntCutAndPaste",
+ "weDoDragAndDrop",
+ "weDoInhibitRecal",
+ "weDoUseTempMem",
+ "weDoDrawOffscreen",
+ "weDoInhibitRedraw",
+ "weDoMonoStyled",
+ "weDoMultipleUndo",
+ "weDoNoKeyboardSync",
+ "weDoInhibitICSupport",
+ "weDoInhibitColor",
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ "DragReference", # For now...
+ "UniversalProcPtr",
+ "WEFontIDToNameUPP",
+ "WEFontNameToIDUPP",
+ "WEClickLoopUPP",
+ "WEScrollUPP",
+ "WETSMPreUpdateUPP",
+ "WETSMPostUpdateUPP",
+ "WEPreTrackDragUPP",
+ "WETranslateDragUPP",
+ "WEHiliteDropAreaUPP",
+ "WEDrawTextUPP",
+ "WEDrawTSMHiliteUPP",
+ "WEPixelToCharUPP",
+ "WECharToPixelUPP",
+ "WELineBreakUPP",
+ "WEWordBreakUPP",
+ "WECharByteUPP",
+ "WECharTypeUPP",
+ "WEEraseUPP",
+ "WEFluxUPP",
+ "WENewObjectUPP",
+ "WEDisposeObjectUPP",
+ "WEDrawObjectUPP",
+ "WEClickObjectUPP",
+ "WEStreamObjectUPP",
+ "WEHoverObjectUPP",
+ "WERuler", # XXXX To be done
+ "WERuler_ptr", # ditto
+ "WEParaInfo", # XXXX To be done
+ "WEPrintSession", # XXXX To be done
+ "WEPrintOptions_ptr", # XXXX To be done
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([("void_ptr", "*", "InMode"), ("SInt32", "*", "InMode")],
+ [("InBuffer", "*", "*")]),
+
+ # WEContinuousStyle
+ ([("WEStyleMode", "ioMode", "OutMode"), ("TextStyle", "outTextStyle", "OutMode")],
+ [("WEStyleMode", "*", "InOutMode"), ("TextStyle", "*", "*")]),
+
+ # WECopyRange
+ ([('Handle', 'outText', 'InMode'), ('StScrpHandle', 'outStyles', 'InMode'),
+ ('WESoupHandle', 'outSoup', 'InMode')],
+ [('OptHandle', '*', '*'), ('OptStScrpHandle', '*', '*'),
+ ('OptSoupHandle', '*', '*')]),
+
+ # WEInsert
+ ([('StScrpHandle', 'inStyles', 'InMode'), ('WESoupHandle', 'inSoup', 'InMode')],
+ [('OptStScrpHandle', '*', '*'), ('OptSoupHandle', '*', '*')]),
+
+ # WEGetObjectOwner
+ ("WEGetObjectOwner",
+ [('WEReference', '*', 'ReturnMode')],
+ [('ExistingWEReference', '*', 'ReturnMode')]),
+
+ # WEFindParagraph
+ ([("char_ptr", "inKey", "InMode")],
+ [("stringptr", "*", "*")]),
+
+ # WESetOneAttribute
+ ([("void_ptr", "*", "InMode"), ("ByteCount", "*", "InMode")],
+ [("InBuffer", "*", "*")]),
+ ]
+
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/waste/wastesupport.py b/Mac/Modules/waste/wastesupport.py
index c669fa1..13ddc40 100644
--- a/Mac/Modules/waste/wastesupport.py
+++ b/Mac/Modules/waste/wastesupport.py
@@ -6,18 +6,18 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'WASTE.h' # The Apple header file
-MODNAME = 'waste' # The name of the module
-OBJECTNAME = 'waste' # The basic name of the objects used here
-KIND = 'Ptr' # Usually 'Ptr' or 'Handle'
+MACHEADERFILE = 'WASTE.h' # The Apple header file
+MODNAME = 'waste' # The name of the module
+OBJECTNAME = 'waste' # The basic name of the objects used here
+KIND = 'Ptr' # Usually 'Ptr' or 'Handle'
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = MODNAME # The prefix for module-wide routines
-OBJECTTYPE = "WEReference" # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = MODNAME # The prefix for module-wide routines
+OBJECTTYPE = "WEReference" # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
INPUTFILE = 'wastegen.py' # The file generated by the scanner
-TYPETESTFILE = 'wastetypetest.py' # Another file generated by the scanner
-OUTPUTFILE = "wastemodule.c" # The file generated by this program
+TYPETESTFILE = 'wastetypetest.py' # Another file generated by the scanner
+OUTPUTFILE = "wastemodule.c" # The file generated by this program
from macsupport import *
@@ -83,21 +83,21 @@ static PyObject *
TextStyle_New(TextStylePtr itself)
{
- return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
- &itself->tsColor);
+ return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
+ &itself->tsColor);
}
static int
TextStyle_Convert(PyObject *v, TextStylePtr p_itself)
{
- long font, face, size;
-
- if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
- return 0;
- p_itself->tsFont = (short)font;
- p_itself->tsFace = (Style)face;
- p_itself->tsSize = (short)size;
- return 1;
+ long font, face, size;
+
+ if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
+ return 0;
+ p_itself->tsFont = (short)font;
+ p_itself->tsFace = (Style)face;
+ p_itself->tsSize = (short)size;
+ return 1;
}
/*
@@ -107,33 +107,33 @@ static PyObject *
RunInfo_New(WERunInfo *itself)
{
- return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight,
- itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject);
+ return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight,
+ itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject);
}
/* Conversion of long points and rects */
int
LongRect_Convert(PyObject *v, LongRect *r)
{
- return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom);
+ return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom);
}
PyObject *
LongRect_New(LongRect *r)
{
- return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom);
+ return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom);
}
int
LongPt_Convert(PyObject *v, LongPt *p)
{
- return PyArg_Parse(v, "(ll)", &p->h, &p->v);
+ return PyArg_Parse(v, "(ll)", &p->h, &p->v);
}
PyObject *
LongPt_New(LongPt *p)
{
- return Py_BuildValue("(ll)", p->h, p->v);
+ return Py_BuildValue("(ll)", p->h, p->v);
}
/* Stuff for the callbacks: */
@@ -146,110 +146,110 @@ WEClickObjectUPP upp_click_handler;
static OSErr
any_handler(WESelector what, WEObjectReference who, PyObject *args, PyObject **rv)
{
- FlavorType tp;
- PyObject *key, *func;
-
- if ( args == NULL ) return errAECorruptData;
-
- tp = WEGetObjectType(who);
-
- if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL)
- return errAECorruptData;
- if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) {
- Py_DECREF(key);
- return errAEHandlerNotFound;
- }
- Py_INCREF(func);
- *rv = PyEval_CallObject(func, args);
- Py_DECREF(func);
- Py_DECREF(key);
- if ( *rv == NULL ) {
- PySys_WriteStderr("--Exception in callback: ");
- PyErr_Print();
- return errAEReplyNotArrived;
- }
- return 0;
+ FlavorType tp;
+ PyObject *key, *func;
+
+ if ( args == NULL ) return errAECorruptData;
+
+ tp = WEGetObjectType(who);
+
+ if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL)
+ return errAECorruptData;
+ if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) {
+ Py_DECREF(key);
+ return errAEHandlerNotFound;
+ }
+ Py_INCREF(func);
+ *rv = PyEval_CallObject(func, args);
+ Py_DECREF(func);
+ Py_DECREF(key);
+ if ( *rv == NULL ) {
+ PySys_WriteStderr("--Exception in callback: ");
+ PyErr_Print();
+ return errAEReplyNotArrived;
+ }
+ return 0;
}
static pascal OSErr
my_new_handler(Point *objectSize, WEObjectReference objref)
{
- PyObject *args=NULL, *rv=NULL;
- OSErr err;
-
- args=Py_BuildValue("(O&)", WEOObj_New, objref);
- err = any_handler(weNewHandler, objref, args, &rv);
- if (!err) {
- if (!PyMac_GetPoint(rv, objectSize) )
- err = errAECoercionFail;
- }
- if ( args ) {
- Py_DECREF(args);
- }
- if ( rv ) {
- Py_DECREF(rv);
- }
- return err;
+ PyObject *args=NULL, *rv=NULL;
+ OSErr err;
+
+ args=Py_BuildValue("(O&)", WEOObj_New, objref);
+ err = any_handler(weNewHandler, objref, args, &rv);
+ if (!err) {
+ if (!PyMac_GetPoint(rv, objectSize) )
+ err = errAECoercionFail;
+ }
+ if ( args ) {
+ Py_DECREF(args);
+ }
+ if ( rv ) {
+ Py_DECREF(rv);
+ }
+ return err;
}
static pascal OSErr
my_dispose_handler(WEObjectReference objref)
{
- PyObject *args=NULL, *rv=NULL;
- OSErr err;
-
- args=Py_BuildValue("(O&)", WEOObj_New, objref);
- err = any_handler(weDisposeHandler, objref, args, &rv);
- if ( args ) {
- Py_DECREF(args);
- }
- if ( rv ) {
- Py_DECREF(rv);
- }
- return err;
+ PyObject *args=NULL, *rv=NULL;
+ OSErr err;
+
+ args=Py_BuildValue("(O&)", WEOObj_New, objref);
+ err = any_handler(weDisposeHandler, objref, args, &rv);
+ if ( args ) {
+ Py_DECREF(args);
+ }
+ if ( rv ) {
+ Py_DECREF(rv);
+ }
+ return err;
}
static pascal OSErr
my_draw_handler(const Rect *destRect, WEObjectReference objref)
{
- PyObject *args=NULL, *rv=NULL;
- OSErr err;
-
- args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref);
- err = any_handler(weDrawHandler, objref, args, &rv);
- if ( args ) {
- Py_DECREF(args);
- }
- if ( rv ) {
- Py_DECREF(rv);
- }
- return err;
+ PyObject *args=NULL, *rv=NULL;
+ OSErr err;
+
+ args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref);
+ err = any_handler(weDrawHandler, objref, args, &rv);
+ if ( args ) {
+ Py_DECREF(args);
+ }
+ if ( rv ) {
+ Py_DECREF(rv);
+ }
+ return err;
}
static pascal Boolean
my_click_handler(Point hitPt, EventModifiers modifiers,
- unsigned long clickTime, WEObjectReference objref)
+ unsigned long clickTime, WEObjectReference objref)
{
- PyObject *args=NULL, *rv=NULL;
- int retvalue;
- OSErr err;
-
- args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt,
- (long)modifiers, (long)clickTime, WEOObj_New, objref);
- err = any_handler(weClickHandler, objref, args, &rv);
- if (!err)
- retvalue = PyInt_AsLong(rv);
- else
- retvalue = 0;
- if ( args ) {
- Py_DECREF(args);
- }
- if ( rv ) {
- Py_DECREF(rv);
- }
- return retvalue;
+ PyObject *args=NULL, *rv=NULL;
+ int retvalue;
+ OSErr err;
+
+ args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt,
+ (long)modifiers, (long)clickTime, WEOObj_New, objref);
+ err = any_handler(weClickHandler, objref, args, &rv);
+ if (!err)
+ retvalue = PyInt_AsLong(rv);
+ else
+ retvalue = 0;
+ if ( args ) {
+ Py_DECREF(args);
+ }
+ if ( rv ) {
+ Py_DECREF(rv);
+ }
+ return retvalue;
}
-
+
"""
finalstuff = finalstuff + """
@@ -257,62 +257,62 @@ finalstuff = finalstuff + """
PyObject *
ExistingwasteObj_New(w)
- WEReference w;
+ WEReference w;
{
- PyObject *it = NULL;
-
- if (w == NULL)
- it = NULL;
- else
- WEGetInfo(weRefCon, (void *)&it, w);
- if (it == NULL || ((wasteObject *)it)->ob_itself != w)
- it = Py_None;
- Py_INCREF(it);
- return it;
+ PyObject *it = NULL;
+
+ if (w == NULL)
+ it = NULL;
+ else
+ WEGetInfo(weRefCon, (void *)&it, w);
+ if (it == NULL || ((wasteObject *)it)->ob_itself != w)
+ it = Py_None;
+ Py_INCREF(it);
+ return it;
}
"""
class WEMethodGenerator(OSErrMethodGenerator):
- """Similar to MethodGenerator, but has self as last argument"""
+ """Similar to MethodGenerator, but has self as last argument"""
- def parseArgumentList(self, args):
- args, a0 = args[:-1], args[-1]
- t0, n0, m0 = a0
- if m0 != InMode:
- raise ValueError, "method's 'self' must be 'InMode'"
- self.itself = Variable(t0, "_self->ob_itself", SelfMode)
- FunctionGenerator.parseArgumentList(self, args)
- self.argumentList.append(self.itself)
+ def parseArgumentList(self, args):
+ args, a0 = args[:-1], args[-1]
+ t0, n0, m0 = a0
+ if m0 != InMode:
+ raise ValueError, "method's 'self' must be 'InMode'"
+ self.itself = Variable(t0, "_self->ob_itself", SelfMode)
+ FunctionGenerator.parseArgumentList(self, args)
+ self.argumentList.append(self.itself)
class WEObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputCheckNewArg(self):
- Output("""if (itself == NULL) {
- PyErr_SetString(waste_Error,"Cannot create null WE");
- return NULL;
- }""")
- def outputInitStructMembers(self):
- GlobalObjectDefinition.outputInitStructMembers(self)
- Output("WESetInfo(weRefCon, (void *)&it, itself);")
- def outputFreeIt(self, itselfname):
- Output("WEDispose(%s);", itselfname)
-
+ def outputCheckNewArg(self):
+ Output("""if (itself == NULL) {
+ PyErr_SetString(waste_Error,"Cannot create null WE");
+ return NULL;
+ }""")
+ def outputInitStructMembers(self):
+ GlobalObjectDefinition.outputInitStructMembers(self)
+ Output("WESetInfo(weRefCon, (void *)&it, itself);")
+ def outputFreeIt(self, itselfname):
+ Output("WEDispose(%s);", itselfname)
+
class WEOObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputCheckNewArg(self):
- Output("""if (itself == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }""")
-
+ def outputCheckNewArg(self):
+ Output("""if (itself == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }""")
+
variablestuff = """
- callbackdict = PyDict_New();
- if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0)
- return;
- upp_new_handler = NewWENewObjectProc(my_new_handler);
- upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler);
- upp_draw_handler = NewWEDrawObjectProc(my_draw_handler);
- upp_click_handler = NewWEClickObjectProc(my_click_handler);
+ callbackdict = PyDict_New();
+ if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0)
+ return;
+ upp_new_handler = NewWENewObjectProc(my_new_handler);
+ upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler);
+ upp_draw_handler = NewWEDrawObjectProc(my_draw_handler);
+ upp_click_handler = NewWEClickObjectProc(my_click_handler);
"""
@@ -341,78 +341,78 @@ execfile(INPUTFILE)
# A function written by hand:
stdhandlers_body = """
- OSErr err;
- // install the sample object handlers for pictures and sounds
-#define kTypePicture 'PICT'
-#define kTypeSound 'snd '
-
- if ( !PyArg_ParseTuple(_args, "") ) return NULL;
-
- if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler,
- (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr)
- goto cleanup;
-
- if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler,
- (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr)
- goto cleanup;
-
- if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler,
- (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr)
- goto cleanup;
-
- if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler,
- (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr)
- goto cleanup;
-
- if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler,
- (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr)
- goto cleanup;
-
- if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler,
- (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr)
- goto cleanup;
- Py_INCREF(Py_None);
- _res = Py_None;
- return _res;
-
+ OSErr err;
+ // install the sample object handlers for pictures and sounds
+#define kTypePicture 'PICT'
+#define kTypeSound 'snd '
+
+ if ( !PyArg_ParseTuple(_args, "") ) return NULL;
+
+ if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler,
+ (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr)
+ goto cleanup;
+
+ if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler,
+ (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr)
+ goto cleanup;
+
+ if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler,
+ (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr)
+ goto cleanup;
+
+ if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler,
+ (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr)
+ goto cleanup;
+
+ if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler,
+ (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr)
+ goto cleanup;
+
+ if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler,
+ (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr)
+ goto cleanup;
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+
cleanup:
- return PyMac_Error(err);
+ return PyMac_Error(err);
"""
inshandler_body = """
- OSErr err;
- FlavorType objectType;
- WESelector selector;
- PyObject *py_handler;
- UniversalProcPtr handler;
- WEReference we = NULL;
- PyObject *key;
-
-
- if ( !PyArg_ParseTuple(_args, "O&O&O|O&",
- PyMac_GetOSType, &objectType,
- PyMac_GetOSType, &selector,
- &py_handler,
- WEOObj_Convert, &we) ) return NULL;
-
- if ( selector == weNewHandler ) handler = (UniversalProcPtr)upp_new_handler;
- else if ( selector == weDisposeHandler ) handler = (UniversalProcPtr)upp_dispose_handler;
- else if ( selector == weDrawHandler ) handler = (UniversalProcPtr)upp_draw_handler;
- else if ( selector == weClickHandler ) handler = (UniversalProcPtr)upp_click_handler;
- else return PyMac_Error(weUndefinedSelectorErr);
-
- if ((key = Py_BuildValue("O&O&",
- PyMac_BuildOSType, objectType,
- PyMac_BuildOSType, selector)) == NULL )
- return NULL;
-
- PyDict_SetItem(callbackdict, key, py_handler);
-
- err = WEInstallObjectHandler(objectType, selector, handler, we);
- if ( err ) return PyMac_Error(err);
- Py_INCREF(Py_None);
- _res = Py_None;
- return _res;
+ OSErr err;
+ FlavorType objectType;
+ WESelector selector;
+ PyObject *py_handler;
+ UniversalProcPtr handler;
+ WEReference we = NULL;
+ PyObject *key;
+
+
+ if ( !PyArg_ParseTuple(_args, "O&O&O|O&",
+ PyMac_GetOSType, &objectType,
+ PyMac_GetOSType, &selector,
+ &py_handler,
+ WEOObj_Convert, &we) ) return NULL;
+
+ if ( selector == weNewHandler ) handler = (UniversalProcPtr)upp_new_handler;
+ else if ( selector == weDisposeHandler ) handler = (UniversalProcPtr)upp_dispose_handler;
+ else if ( selector == weDrawHandler ) handler = (UniversalProcPtr)upp_draw_handler;
+ else if ( selector == weClickHandler ) handler = (UniversalProcPtr)upp_click_handler;
+ else return PyMac_Error(weUndefinedSelectorErr);
+
+ if ((key = Py_BuildValue("O&O&",
+ PyMac_BuildOSType, objectType,
+ PyMac_BuildOSType, selector)) == NULL )
+ return NULL;
+
+ PyDict_SetItem(callbackdict, key, py_handler);
+
+ err = WEInstallObjectHandler(objectType, selector, handler, we);
+ if ( err ) return PyMac_Error(err);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
"""
stdhand = ManualGenerator("STDObjectHandlers", stdhandlers_body)
@@ -442,4 +442,3 @@ for f in methods2: object2.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-