static PyObject *AE_AEInstallCoercionHandler(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; OSErr _err; DescType fromType, toType; AECoercionHandlerUPP handler__proc__ = upp_GenericCoercionHandler; PyObject *handler; #ifndef AEInstallCoercionHandler PyMac_PRECHECK(AEInstallCoercionHandler); #endif if (!PyArg_ParseTuple(_args, "O&O&O", PyMac_GetOSType, &fromType, PyMac_GetOSType, &toType, &handler)) return NULL; _err = AEInstallCoercionHandler(fromType, toType, handler__proc__, (long)handler, 1, 0); if (_err != noErr) return PyMac_Error(_err); Py_INCREF(Py_None); _res = Py_None; Py_INCREF(handler); /* XXX leak, but needed */ return _res; }
Boolean IACinstallcoercionhandler (DescType fromtype, DescType totype, ProcPtr handler) { OSErr ec; #if TARGET_API_MAC_CARBON == 1 AECoercePtrUPP theHandler = NewAECoercePtrUPP((AECoercePtrProcPtr) handler); ec = AEInstallCoercionHandler (fromtype, totype, (AECoercionHandlerUPP) theHandler, (long) 0, false, false); //should we delete this, my gut feeling is no, not until the app ends #else ec = AEInstallCoercionHandler (fromtype, totype, (AECoercionHandlerUPP) NewAECoercePtrProc (handler), (long) 0, false, false); #endif IACglobals.errorcode = ec; return (ec == noErr); } /*IACinstallcoercionhandler*/