Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5050199

Browse files
committed
Fixed incorrect call to InstallHandler and a few other things
1 parent 21eb0b5 commit 5050199

6 files changed

Lines changed: 61 additions & 21 deletions

File tree

Mac/Lib/toolbox/AEObjects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated from 'Moes:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AEObjects.h'
1+
# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AEObjects.h'
22

33
kAEAND = 'AND '
44
kAEOR = 'OR '

Mac/Lib/toolbox/AERegistry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated from 'Moes:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AERegistry.h'
1+
# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AERegistry.h'
22

33
cAEList = 'list'
44
cApplication = 'capp'

Mac/Lib/toolbox/AppleEvents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated from 'Moes:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AppleEvents.h'
1+
# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AppleEvents.h'
22

33
typeBoolean = 'bool'
44
typeChar = 'TEXT'

Mac/Modules/ae/AEmodule.c

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -667,18 +667,19 @@ static PyObject *AEDesc_AEResumeTheCurrentEvent(_self, _args)
667667
PyObject *_res = NULL;
668668
OSErr _err;
669669
AppleEvent reply;
670-
long handlerRefcon;
671-
if (!PyArg_ParseTuple(_args, "O&l",
670+
AEEventHandlerUPP dispatcher__proc__ = upp_GenericEventHandler;
671+
PyObject *dispatcher;
672+
if (!PyArg_ParseTuple(_args, "O&O",
672673
AEDesc_Convert, &reply,
673-
&handlerRefcon))
674+
&dispatcher))
674675
return NULL;
675676
_err = AEResumeTheCurrentEvent(&_self->ob_itself,
676677
&reply,
677-
upp_GenericEventHandler,
678-
handlerRefcon);
678+
dispatcher__proc__, (long)dispatcher);
679679
if (_err != noErr) return PyMac_Error(_err);
680680
Py_INCREF(Py_None);
681681
_res = Py_None;
682+
Py_INCREF(dispatcher); /* XXX leak, but needed */
682683
return _res;
683684
}
684685

@@ -760,7 +761,7 @@ static PyMethodDef AEDesc_methods[] = {
760761
{"AESuspendTheCurrentEvent", (PyCFunction)AEDesc_AESuspendTheCurrentEvent, 1,
761762
"() -> None"},
762763
{"AEResumeTheCurrentEvent", (PyCFunction)AEDesc_AEResumeTheCurrentEvent, 1,
763-
"(AppleEvent reply, long handlerRefcon) -> None"},
764+
"(AppleEvent reply, EventHandler dispatcher) -> None"},
764765
{"AEGetTheCurrentEvent", (PyCFunction)AEDesc_AEGetTheCurrentEvent, 1,
765766
"() -> None"},
766767
{"AESetTheCurrentEvent", (PyCFunction)AEDesc_AESetTheCurrentEvent, 1,
@@ -1002,20 +1003,21 @@ static PyObject *AE_AEInstallEventHandler(_self, _args)
10021003
OSErr _err;
10031004
AEEventClass theAEEventClass;
10041005
AEEventID theAEEventID;
1005-
long handlerRefcon;
1006-
if (!PyArg_ParseTuple(_args, "O&O&l",
1006+
AEEventHandlerUPP handler__proc__ = upp_GenericEventHandler;
1007+
PyObject *handler;
1008+
if (!PyArg_ParseTuple(_args, "O&O&O",
10071009
PyMac_GetOSType, &theAEEventClass,
10081010
PyMac_GetOSType, &theAEEventID,
1009-
&handlerRefcon))
1011+
&handler))
10101012
return NULL;
10111013
_err = AEInstallEventHandler(theAEEventClass,
10121014
theAEEventID,
1013-
upp_GenericEventHandler,
1014-
handlerRefcon,
1015+
handler__proc__, (long)handler,
10151016
0);
10161017
if (_err != noErr) return PyMac_Error(_err);
10171018
Py_INCREF(Py_None);
10181019
_res = Py_None;
1020+
Py_INCREF(handler); /* XXX leak, but needed */
10191021
return _res;
10201022
}
10211023

@@ -1041,6 +1043,30 @@ static PyObject *AE_AERemoveEventHandler(_self, _args)
10411043
return _res;
10421044
}
10431045

1046+
static PyObject *AE_AEGetEventHandler(_self, _args)
1047+
PyObject *_self;
1048+
PyObject *_args;
1049+
{
1050+
PyObject *_res = NULL;
1051+
OSErr _err;
1052+
AEEventClass theAEEventClass;
1053+
AEEventID theAEEventID;
1054+
long procptr, handlerptr;
1055+
1056+
if (!PyArg_ParseTuple(_args, "O&O&",
1057+
PyMac_GetOSType, &theAEEventClass,
1058+
PyMac_GetOSType, &theAEEventID))
1059+
return NULL;
1060+
_err = AEGetEventHandler(theAEEventClass,
1061+
theAEEventID,
1062+
(AEEventHandlerUPP *)&procptr, &handlerptr,
1063+
0);
1064+
if (_err != noErr) return PyMac_Error(_err);
1065+
_res = Py_BuildValue("ll",
1066+
(long)procptr, (long)handlerptr);
1067+
return _res;
1068+
}
1069+
10441070
static PyObject *AE_AEManagerInfo(_self, _args)
10451071
PyObject *_self;
10461072
PyObject *_args;
@@ -1078,9 +1104,11 @@ static PyMethodDef AE_methods[] = {
10781104
{"AEInteractWithUser", (PyCFunction)AE_AEInteractWithUser, 1,
10791105
"(long timeOutInTicks) -> None"},
10801106
{"AEInstallEventHandler", (PyCFunction)AE_AEInstallEventHandler, 1,
1081-
"(AEEventClass theAEEventClass, AEEventID theAEEventID, long handlerRefcon) -> None"},
1107+
"(AEEventClass theAEEventClass, AEEventID theAEEventID, EventHandler handler) -> None"},
10821108
{"AERemoveEventHandler", (PyCFunction)AE_AERemoveEventHandler, 1,
10831109
"(AEEventClass theAEEventClass, AEEventID theAEEventID) -> None"},
1110+
{"AEGetEventHandler", (PyCFunction)AE_AEGetEventHandler, 1,
1111+
"(AEEventClass theAEEventClass, AEEventID theAEEventID) -> (EventHandler handler)"},
10841112
{"AEManagerInfo", (PyCFunction)AE_AEManagerInfo, 1,
10851113
"(AEKeyword keyWord) -> (long result)"},
10861114
{NULL, NULL, 0}

Mac/Modules/ae/aegen.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated from 'Moes:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AppleEvents.h'
1+
# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AppleEvents.h'
22

33
f = AEFunction(OSErr, 'AECreateDesc',
44
(DescType, 'typeCode', InMode),
@@ -214,8 +214,7 @@
214214
f = AEMethod(OSErr, 'AEResumeTheCurrentEvent',
215215
(AppleEvent_ptr, 'theAppleEvent', InMode),
216216
(AppleEvent_ptr, 'reply', InMode),
217-
(AEEventHandlerUPP, 'dispatcher', InMode),
218-
(long, 'handlerRefcon', InMode),
217+
(EventHandler, 'dispatcher', InMode),
219218
)
220219
aedescmethods.append(f)
221220

@@ -249,8 +248,7 @@
249248
f = AEFunction(OSErr, 'AEInstallEventHandler',
250249
(AEEventClass, 'theAEEventClass', InMode),
251250
(AEEventID, 'theAEEventID', InMode),
252-
(AEEventHandlerUPP, 'handler', InMode),
253-
(long, 'handlerRefcon', InMode),
251+
(EventHandler, 'handler', InMode),
254252
(AlwaysFalse, 'isSysHandler', InMode),
255253
)
256254
functions.append(f)
@@ -263,6 +261,14 @@
263261
)
264262
functions.append(f)
265263

264+
f = AEFunction(OSErr, 'AEGetEventHandler',
265+
(AEEventClass, 'theAEEventClass', InMode),
266+
(AEEventID, 'theAEEventID', InMode),
267+
(EventHandler, 'handler', OutMode),
268+
(AlwaysFalse, 'isSysHandler', InMode),
269+
)
270+
functions.append(f)
271+
266272
f = AEFunction(OSErr, 'AEManagerInfo',
267273
(AEKeyword, 'keyWord', InMode),
268274
(long, 'result', OutMode),

Mac/Modules/ae/aescan.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def destination(self, type, name, arglist):
5959
def makeblacklistnames(self):
6060
return [
6161
"AEDisposeDesc",
62-
"AEGetEventHandler",
62+
# "AEGetEventHandler",
6363
]
6464

6565
def makeblacklisttypes(self):
@@ -84,6 +84,12 @@ def makerepairinstructions(self):
8484
([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
8585
[("EventHandler", "*", "*")]),
8686

87+
([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
88+
[("EventHandler", "*", "*")]),
89+
90+
([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
91+
[("EventHandler", "*", "*")]),
92+
8793
([("void", "*", "OutMode"), ("Size", "*", "InMode"),
8894
("Size", "*", "OutMode")],
8995
[("VarVarOutBuffer", "*", "InOutMode")]),

0 commit comments

Comments
 (0)