summaryrefslogtreecommitdiffstats
path: root/Mac/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-02-05 16:58:33 (GMT)
committerGuido van Rossum <guido@python.org>1995-02-05 16:58:33 (GMT)
commitb19a645b69355bd4ccd6d6618cd00e4047996bbc (patch)
tree25be524663875e6e3ad2d0c4749cc65f300a2ac8 /Mac/Modules
parentd9ff26b1a039a1c92dacf67ebfd08449fdc18232 (diff)
downloadcpython-b19a645b69355bd4ccd6d6618cd00e4047996bbc.zip
cpython-b19a645b69355bd4ccd6d6618cd00e4047996bbc.tar.gz
cpython-b19a645b69355bd4ccd6d6618cd00e4047996bbc.tar.bz2
more think/mw changes
Diffstat (limited to 'Mac/Modules')
-rw-r--r--Mac/Modules/ae/AEmodule.c41
-rw-r--r--Mac/Modules/ae/aesupport.py42
2 files changed, 71 insertions, 12 deletions
diff --git a/Mac/Modules/ae/AEmodule.c b/Mac/Modules/ae/AEmodule.c
index 544c4e2..f8c3c91 100644
--- a/Mac/Modules/ae/AEmodule.c
+++ b/Mac/Modules/ae/AEmodule.c
@@ -30,21 +30,45 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
extern PyObject *CtlObj_New(ControlHandle);
extern int CtlObj_Convert(PyObject *, ControlHandle *);
+extern PyObject *WinObj_WhichWindow(WindowPtr);
+
#include <AppleEvents.h>
#ifdef THINK_C
+#define AEIdleProcPtr IdleProcPtr
#define AEFilterProcPtr EventFilterProcPtr
#define AEEventHandlerProcPtr EventHandlerProcPtr
#endif
+#ifndef __MWERKS__
+/* Actually, this is "if not universal headers".
+** I'm trying to setup the code here so that is easily automated,
+** as follows:
+** - Use the UPP in the source
+** - for pre-universal headers, #define each UPP as the corresponding ProcPtr
+** - for each routine we pass we declare a upp_xxx that
+** we initialize to the correct value in the init routine.
+*/
+#define AEIdleUPP AEIdleProcPtr
+#define AEFilterUPP AEFilterProcPtr
+#define AEEventHandlerUPP AEEventHandlerProcPtr
+#define NewAEIdleProc(x) (x)
+#define NewAEFilterProc(x) (x)
+#define NewAEEventHandlerProc(x) (x)
+#endif
+
static pascal OSErr GenericEventHandler(); /* Forward */
+AEEventHandlerUPP upp_GenericEventHandler;
+
static pascal Boolean AEIdleProc(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn)
{
(void) PyMac_Idle();
return 0;
}
+AEIdleUPP upp_AEIdleProc;
+
static PyObject *AE_Error;
/* ----------------------- Object type AEDesc ----------------------- */
@@ -733,8 +757,8 @@ static PyObject *AEDesc_AESend(_self, _args)
sendMode,
sendPriority,
timeOutInTicks,
- AEIdleProc,
- (AEFilterProcPtr)0);
+ upp_AEIdleProc,
+ (AEFilterUPP)0);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
AEDesc_New, &reply);
@@ -778,7 +802,7 @@ static PyObject *AEDesc_AEResumeTheCurrentEvent(_self, _args)
PyObject *_res = NULL;
OSErr _err;
AppleEvent reply;
- AEEventHandlerProcPtr dispatcher__proc__ = GenericEventHandler;
+ AEEventHandlerUPP dispatcher__proc__ = upp_GenericEventHandler;
PyObject *dispatcher;
if (!PyArg_ParseTuple(_args, "O&O",
AEDesc_Convert, &reply,
@@ -790,6 +814,7 @@ static PyObject *AEDesc_AEResumeTheCurrentEvent(_self, _args)
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
+ Py_INCREF(dispatcher); /* XXX leak, but needed */
return _res;
}
@@ -1103,7 +1128,7 @@ static PyObject *AE_AEInteractWithUser(_self, _args)
return NULL;
_err = AEInteractWithUser(timeOutInTicks,
(NMRecPtr)0,
- AEIdleProc);
+ upp_AEIdleProc);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
@@ -1118,7 +1143,7 @@ static PyObject *AE_AEInstallEventHandler(_self, _args)
OSErr _err;
AEEventClass theAEEventClass;
AEEventID theAEEventID;
- AEEventHandlerProcPtr handler__proc__ = GenericEventHandler;
+ AEEventHandlerUPP handler__proc__ = upp_GenericEventHandler;
PyObject *handler;
if (!PyArg_ParseTuple(_args, "O&O&O",
PyMac_GetOSType, &theAEEventClass,
@@ -1132,6 +1157,7 @@ static PyObject *AE_AEInstallEventHandler(_self, _args)
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
+ Py_INCREF(handler); /* XXX leak, but needed */
return _res;
}
@@ -1149,7 +1175,7 @@ static PyObject *AE_AERemoveEventHandler(_self, _args)
return NULL;
_err = AERemoveEventHandler(theAEEventClass,
theAEEventID,
- GenericEventHandler,
+ upp_GenericEventHandler,
0);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
@@ -1244,6 +1270,9 @@ void initAE()
+ upp_AEIdleProc = NewAEIdleProc(AEIdleProc);
+ upp_GenericEventHandler = NewAEEventHandlerProc(GenericEventHandler);
+
m = Py_InitModule("AE", AE_methods);
d = PyModule_GetDict(m);
diff --git a/Mac/Modules/ae/aesupport.py b/Mac/Modules/ae/aesupport.py
index 49f072b..eb18956 100644
--- a/Mac/Modules/ae/aesupport.py
+++ b/Mac/Modules/ae/aesupport.py
@@ -39,7 +39,7 @@ class EHType(Type):
def __init__(self, name = 'EventHandler', format = ''):
Type.__init__(self, name, format)
def declare(self, name):
- Output("AEEventHandlerProcPtr %s__proc__ = GenericEventHandler;", name)
+ Output("AEEventHandlerUPP %s__proc__ = upp_GenericEventHandler;", name)
Output("PyObject *%s;", name)
def getargsFormat(self):
return "O"
@@ -53,19 +53,21 @@ class EHType(Type):
return "O"
def mkvalueArgs(self, name):
return name
+ def cleanup(self, name):
+ Output("Py_INCREF(%s); /* XXX leak, but needed */", name)
class EHNoRefConType(EHType):
def passInput(self, name):
- return "GenericEventHandler"
+ return "upp_GenericEventHandler"
EventHandler = EHType()
EventHandlerNoRefCon = EHNoRefConType()
-IdleProcPtr = FakeType("AEIdleProc")
-EventFilterProcPtr = FakeType("(AEFilterProcPtr)0")
+IdleProcPtr = FakeType("upp_AEIdleProc")
+EventFilterProcPtr = FakeType("(AEFilterUPP)0")
NMRecPtr = FakeType("(NMRecPtr)0")
-EventHandlerProcPtr = FakeType("GenericEventHandler")
+EventHandlerProcPtr = FakeType("upp_GenericEventHandler")
AlwaysFalse = FakeType("0")
@@ -77,16 +79,39 @@ includestuff = includestuff + """
#include <AppleEvents.h>
#ifdef THINK_C
+#define AEIdleProcPtr IdleProcPtr
#define AEFilterProcPtr EventFilterProcPtr
#define AEEventHandlerProcPtr EventHandlerProcPtr
#endif
+#ifndef __MWERKS__
+/* Actually, this is "if not universal headers".
+** I'm trying to setup the code here so that is easily automated,
+** as follows:
+** - Use the UPP in the source
+** - for pre-universal headers, #define each UPP as the corresponding ProcPtr
+** - for each routine we pass we declare a upp_xxx that
+** we initialize to the correct value in the init routine.
+*/
+#define AEIdleUPP AEIdleProcPtr
+#define AEFilterUPP AEFilterProcPtr
+#define AEEventHandlerUPP AEEventHandlerProcPtr
+#define NewAEIdleProc(x) (x)
+#define NewAEFilterProc(x) (x)
+#define NewAEEventHandlerProc(x) (x)
+#endif
+
static pascal OSErr GenericEventHandler(); /* Forward */
+AEEventHandlerUPP upp_GenericEventHandler;
+
static pascal Boolean AEIdleProc(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn)
{
- return !PyMac_Idle();
+ (void) PyMac_Idle();
+ return 0;
}
+
+AEIdleUPP upp_AEIdleProc;
"""
finalstuff = finalstuff + """
@@ -121,6 +146,11 @@ GenericEventHandler(const AppleEvent *request, AppleEvent *reply, long refcon)
}
"""
+initstuff = initstuff + """
+ upp_AEIdleProc = NewAEIdleProc(AEIdleProc);
+ upp_GenericEventHandler = NewAEEventHandlerProc(GenericEventHandler);
+"""
+
module = MacModule('AE', 'AE', includestuff, finalstuff, initstuff)
class AEDescDefiniton(ObjectDefinition):