Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
cddfc873
Kaydet (Commit)
cddfc873
authored
Ara 12, 2001
tarafından
Just van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added proper error checking in event callback handler
üst
ff3a69c4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
24 deletions
+50
-24
CarbonEvtsupport.py
Mac/Modules/carbonevt/CarbonEvtsupport.py
+25
-12
_CarbonEvtmodule.c
Mac/Modules/carbonevt/_CarbonEvtmodule.c
+25
-12
No files found.
Mac/Modules/carbonevt/CarbonEvtsupport.py
Dosyayı görüntüle @
cddfc873
...
...
@@ -64,10 +64,10 @@ includestuff = r"""
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {
\
PyErr_SetString(PyExc_NotImplementedError,
\
"Not available in this shared library/OS version");
\
return;
\
}} while(0)
PyErr_SetString(PyExc_NotImplementedError,
\
"Not available in this shared library/OS version");
\
return;
\
}} while(0)
#define USE_MAC_MP_MULTITHREADING 0
...
...
@@ -145,24 +145,37 @@ EventHotKeyID_Convert(PyObject *v, EventHotKeyID *out)
static EventHandlerUPP myEventHandlerUPP;
pascal OSStatus myEventHandler(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) {
static pascal OSStatus
myEventHandler(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) {
PyObject *retValue;
int status;
#if USE_MAC_MP_MULTITHREADING
MPEnterCriticalRegion(reentrantLock, kDurationForever);
PyEval_RestoreThread(_save);
MPEnterCriticalRegion(reentrantLock, kDurationForever);
PyEval_RestoreThread(_save);
#endif /* USE_MAC_MP_MULTITHREADING */
retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", EventHandlerCallRef_New, handlerRef, EventRef_New, event);
status = PyInt_AsLong(retValue);
retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", EventHandlerCallRef_New, handlerRef, EventRef_New, event);
if (retValue == NULL) {
PySys_WriteStderr("Error in event handler callback:\n");
PyErr_Print(); /* this also clears the error */
status = noErr; /* complain? how? */
} else {
if (retValue == Py_None)
status = noErr;
else if (PyInt_Check(retValue)) {
status = PyInt_AsLong(retValue);
} else
status = noErr; /* wrong object type, complain? */
Py_DECREF(retValue);
}
#if USE_MAC_MP_MULTITHREADING
_save = PyEval_SaveThread();
MPExitCriticalRegion(reentrantLock);
_save = PyEval_SaveThread();
MPExitCriticalRegion(reentrantLock);
#endif /* USE_MAC_MP_MULTITHREADING */
return status;
return status;
}
/******** end myEventHandler ***********/
...
...
Mac/Modules/carbonevt/_CarbonEvtmodule.c
Dosyayı görüntüle @
cddfc873
...
...
@@ -15,10 +15,10 @@
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
PyErr_SetString(PyExc_NotImplementedError, \
"Not available in this shared library/OS version"); \
return; \
}} while(0)
PyErr_SetString(PyExc_NotImplementedError, \
"Not available in this shared library/OS version"); \
return; \
}} while(0)
#define USE_MAC_MP_MULTITHREADING 0
...
...
@@ -96,24 +96,37 @@ EventHotKeyID_Convert(PyObject *v, EventHotKeyID *out)
static
EventHandlerUPP
myEventHandlerUPP
;
pascal
OSStatus
myEventHandler
(
EventHandlerCallRef
handlerRef
,
EventRef
event
,
void
*
outPyObject
)
{
static
pascal
OSStatus
myEventHandler
(
EventHandlerCallRef
handlerRef
,
EventRef
event
,
void
*
outPyObject
)
{
PyObject
*
retValue
;
int
status
;
#if USE_MAC_MP_MULTITHREADING
MPEnterCriticalRegion
(
reentrantLock
,
kDurationForever
);
PyEval_RestoreThread
(
_save
);
MPEnterCriticalRegion
(
reentrantLock
,
kDurationForever
);
PyEval_RestoreThread
(
_save
);
#endif
/* USE_MAC_MP_MULTITHREADING */
retValue
=
PyObject_CallFunction
((
PyObject
*
)
outPyObject
,
"O&O&"
,
EventHandlerCallRef_New
,
handlerRef
,
EventRef_New
,
event
);
status
=
PyInt_AsLong
(
retValue
);
retValue
=
PyObject_CallFunction
((
PyObject
*
)
outPyObject
,
"O&O&"
,
EventHandlerCallRef_New
,
handlerRef
,
EventRef_New
,
event
);
if
(
retValue
==
NULL
)
{
PySys_WriteStderr
(
"Error in event handler callback:
\n
"
);
PyErr_Print
();
/* this also clears the error */
status
=
noErr
;
/* complain? how? */
}
else
{
if
(
retValue
==
Py_None
)
status
=
noErr
;
else
if
(
PyInt_Check
(
retValue
))
{
status
=
PyInt_AsLong
(
retValue
);
}
else
status
=
noErr
;
/* wrong object type, complain? */
Py_DECREF
(
retValue
);
}
#if USE_MAC_MP_MULTITHREADING
_save
=
PyEval_SaveThread
();
MPExitCriticalRegion
(
reentrantLock
);
_save
=
PyEval_SaveThread
();
MPExitCriticalRegion
(
reentrantLock
);
#endif
/* USE_MAC_MP_MULTITHREADING */
return
status
;
return
status
;
}
/******** end myEventHandler ***********/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment