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

Skip to content

Commit 7107c1a

Browse files
committed
Got rid of macglue.h, replacing it by pymactoolbox.h where relevant.
Cleaned up various things in the toolbox modules.
1 parent 3305d24 commit 7107c1a

43 files changed

Lines changed: 51 additions & 303 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Mac/Modules/ColorPickermodule.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ PERFORMANCE OF THIS SOFTWARE.
2323

2424
#include <Carbon/Carbon.h>
2525
#include "Python.h"
26-
#include "macglue.h"
2726
#include "pymactoolbox.h"
2827

2928
/* ----------------------------------------------------- */

Mac/Modules/Nav.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ PERFORMANCE OF THIS SOFTWARE.
3030
******************************************************************/
3131

3232
#include "Python.h"
33-
#include "macglue.h"
3433
#include "pymactoolbox.h"
3534
#include <Carbon/Carbon.h>
3635

Mac/Modules/OSATerminology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
** by a full interface to OpenScripting.
88
*/
99
#include "Python.h"
10-
#include "macglue.h"
10+
#include "pymactoolbox.h"
1111

1212
#include <Carbon/Carbon.h>
1313

Mac/Modules/ae/_AEmodule.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55

66

77

8-
#ifdef _WIN32
9-
#include "pywintoolbox.h"
10-
#else
11-
#include "macglue.h"
128
#include "pymactoolbox.h"
13-
#endif
149

1510
/* Macro to test whether a weak-loaded CFM function exists */
1611
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\

Mac/Modules/ah/_AHmodule.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55

66

77

8-
#ifdef _WIN32
9-
#include "pywintoolbox.h"
10-
#else
11-
#include "macglue.h"
128
#include "pymactoolbox.h"
13-
#endif
149

1510
/* Macro to test whether a weak-loaded CFM function exists */
1611
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\

Mac/Modules/app/_Appmodule.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55

66

77

8-
#ifdef _WIN32
9-
#include "pywintoolbox.h"
10-
#else
11-
#include "macglue.h"
128
#include "pymactoolbox.h"
13-
#endif
149

1510
/* Macro to test whether a weak-loaded CFM function exists */
1611
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\

Mac/Modules/carbonevt/CarbonEvtscan.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ def makeblacklistnames(self):
8484
# Wrote by hand
8585
"InstallEventHandler",
8686
"RemoveEventHandler",
87-
"RunApplicationEventLoop",
8887

8988
# Write by hand?
9089
"GetEventParameter",

Mac/Modules/carbonevt/CarbonEvtsupport.py

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,9 @@ def precheck(self):
7373
MouseTrackingResult = UInt16
7474

7575

76-
includestuff = r"""
76+
includestuff = includestuff + r"""
7777
#include <Carbon/Carbon.h>
7878
79-
#include "macglue.h"
80-
81-
/* Macro to test whether a weak-loaded CFM function exists */
82-
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
83-
PyErr_SetString(PyExc_NotImplementedError, \
84-
"Not available in this shared library/OS version"); \
85-
return; \
86-
}} while(0)
87-
88-
89-
#define USE_MAC_MP_MULTITHREADING 0
90-
91-
#if USE_MAC_MP_MULTITHREADING
92-
static PyThreadState *_save;
93-
static MPCriticalRegionID reentrantLock;
94-
#endif /* USE_MAC_MP_MULTITHREADING */
95-
9679
extern int CFStringRef_New(CFStringRef *);
9780
9881
extern int CFStringRef_Convert(PyObject *, CFStringRef *);
@@ -168,11 +151,6 @@ def precheck(self):
168151
PyObject *retValue;
169152
int status;
170153
171-
#if USE_MAC_MP_MULTITHREADING
172-
MPEnterCriticalRegion(reentrantLock, kDurationForever);
173-
PyEval_RestoreThread(_save);
174-
#endif /* USE_MAC_MP_MULTITHREADING */
175-
176154
retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&",
177155
EventHandlerCallRef_New, handlerRef,
178156
EventRef_New, event);
@@ -190,11 +168,6 @@ def precheck(self):
190168
Py_DECREF(retValue);
191169
}
192170
193-
#if USE_MAC_MP_MULTITHREADING
194-
_save = PyEval_SaveThread();
195-
MPExitCriticalRegion(reentrantLock);
196-
#endif /* USE_MAC_MP_MULTITHREADING */
197-
198171
return status;
199172
}
200173
@@ -203,7 +176,6 @@ def precheck(self):
203176
"""
204177

205178
initstuff = initstuff + """
206-
PyMac_PRECHECK(NewEventHandlerUPP); /* This can fail if CarbonLib is too old */
207179
myEventHandlerUPP = NewEventHandlerUPP(myEventHandler);
208180
"""
209181
module = MacModule('_CarbonEvt', 'CarbonEvents', includestuff, finalstuff, initstuff)
@@ -335,32 +307,6 @@ class MyGlobalObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
335307
f.docstring = lambda: "(EventParamName eventName, EventParamType eventType) -> (String eventParamData)"
336308
EventRefobject.add(f)
337309

338-
runappeventloop = """
339-
#if USE_MAC_MP_MULTITHREADING
340-
if (MPCreateCriticalRegion(&reentrantLock) != noErr) {
341-
PySys_WriteStderr("lock failure\\n");
342-
return NULL;
343-
}
344-
_save = PyEval_SaveThread();
345-
#endif /* USE_MAC_MP_MULTITHREADING */
346-
347-
RunApplicationEventLoop();
348-
349-
#if USE_MAC_MP_MULTITHREADING
350-
PyEval_RestoreThread(_save);
351-
352-
MPDeleteCriticalRegion(reentrantLock);
353-
#endif /* USE_MAC_MP_MULTITHREADING */
354-
355-
Py_INCREF(Py_None);
356-
_res = Py_None;
357-
return _res;
358-
"""
359-
360-
f = ManualGenerator("RunApplicationEventLoop", runappeventloop);
361-
f.docstring = lambda: "() -> ()"
362-
module.add(f)
363-
364310
SetOutputFileName('_CarbonEvtmodule.c')
365311
module.generate()
366312

Mac/Modules/carbonevt/_CarbonEvtmodule.c

Lines changed: 19 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,17 @@
55

66

77

8-
#include <Carbon/Carbon.h>
9-
10-
#include "macglue.h"
8+
#include "pymactoolbox.h"
119

1210
/* Macro to test whether a weak-loaded CFM function exists */
1311
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
14-
PyErr_SetString(PyExc_NotImplementedError, \
15-
"Not available in this shared library/OS version"); \
16-
return; \
17-
}} while(0)
18-
12+
PyErr_SetString(PyExc_NotImplementedError, \
13+
"Not available in this shared library/OS version"); \
14+
return NULL; \
15+
}} while(0)
1916

20-
#define USE_MAC_MP_MULTITHREADING 0
2117

22-
#if USE_MAC_MP_MULTITHREADING
23-
static PyThreadState *_save;
24-
static MPCriticalRegionID reentrantLock;
25-
#endif /* USE_MAC_MP_MULTITHREADING */
18+
#include <Carbon/Carbon.h>
2619

2720
extern int CFStringRef_New(CFStringRef *);
2821

@@ -99,11 +92,6 @@ myEventHandler(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject
9992
PyObject *retValue;
10093
int status;
10194

102-
#if USE_MAC_MP_MULTITHREADING
103-
MPEnterCriticalRegion(reentrantLock, kDurationForever);
104-
PyEval_RestoreThread(_save);
105-
#endif /* USE_MAC_MP_MULTITHREADING */
106-
10795
retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&",
10896
EventHandlerCallRef_New, handlerRef,
10997
EventRef_New, event);
@@ -121,11 +109,6 @@ myEventHandler(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject
121109
Py_DECREF(retValue);
122110
}
123111

124-
#if USE_MAC_MP_MULTITHREADING
125-
_save = PyEval_SaveThread();
126-
MPExitCriticalRegion(reentrantLock);
127-
#endif /* USE_MAC_MP_MULTITHREADING */
128-
129112
return status;
130113
}
131114

@@ -1845,6 +1828,17 @@ static PyObject *CarbonEvents_GetEventDispatcherTarget(PyObject *_self, PyObject
18451828
return _res;
18461829
}
18471830

1831+
static PyObject *CarbonEvents_RunApplicationEventLoop(PyObject *_self, PyObject *_args)
1832+
{
1833+
PyObject *_res = NULL;
1834+
if (!PyArg_ParseTuple(_args, ""))
1835+
return NULL;
1836+
RunApplicationEventLoop();
1837+
Py_INCREF(Py_None);
1838+
_res = Py_None;
1839+
return _res;
1840+
}
1841+
18481842
static PyObject *CarbonEvents_QuitApplicationEventLoop(PyObject *_self, PyObject *_args)
18491843
{
18501844
PyObject *_res = NULL;
@@ -2042,32 +2036,6 @@ static PyObject *CarbonEvents_RegisterEventHotKey(PyObject *_self, PyObject *_ar
20422036
return _res;
20432037
}
20442038

2045-
static PyObject *CarbonEvents_RunApplicationEventLoop(PyObject *_self, PyObject *_args)
2046-
{
2047-
PyObject *_res = NULL;
2048-
2049-
#if USE_MAC_MP_MULTITHREADING
2050-
if (MPCreateCriticalRegion(&reentrantLock) != noErr) {
2051-
PySys_WriteStderr("lock failure\n");
2052-
return NULL;
2053-
}
2054-
_save = PyEval_SaveThread();
2055-
#endif /* USE_MAC_MP_MULTITHREADING */
2056-
2057-
RunApplicationEventLoop();
2058-
2059-
#if USE_MAC_MP_MULTITHREADING
2060-
PyEval_RestoreThread(_save);
2061-
2062-
MPDeleteCriticalRegion(reentrantLock);
2063-
#endif /* USE_MAC_MP_MULTITHREADING */
2064-
2065-
Py_INCREF(Py_None);
2066-
_res = Py_None;
2067-
return _res;
2068-
2069-
}
2070-
20712039
static PyMethodDef CarbonEvents_methods[] = {
20722040
{"GetCurrentEventLoop", (PyCFunction)CarbonEvents_GetCurrentEventLoop, 1,
20732041
PyDoc_STR("() -> (EventLoopRef _rv)")},
@@ -2103,6 +2071,8 @@ static PyMethodDef CarbonEvents_methods[] = {
21032071
PyDoc_STR("() -> (EventTargetRef _rv)")},
21042072
{"GetEventDispatcherTarget", (PyCFunction)CarbonEvents_GetEventDispatcherTarget, 1,
21052073
PyDoc_STR("() -> (EventTargetRef _rv)")},
2074+
{"RunApplicationEventLoop", (PyCFunction)CarbonEvents_RunApplicationEventLoop, 1,
2075+
PyDoc_STR("() -> None")},
21062076
{"QuitApplicationEventLoop", (PyCFunction)CarbonEvents_QuitApplicationEventLoop, 1,
21072077
PyDoc_STR("() -> None")},
21082078
{"RunAppModalLoopForWindow", (PyCFunction)CarbonEvents_RunAppModalLoopForWindow, 1,
@@ -2127,8 +2097,6 @@ static PyMethodDef CarbonEvents_methods[] = {
21272097
PyDoc_STR("(WindowPtr inWindow) -> (ControlHandle outControl)")},
21282098
{"RegisterEventHotKey", (PyCFunction)CarbonEvents_RegisterEventHotKey, 1,
21292099
PyDoc_STR("(UInt32 inHotKeyCode, UInt32 inHotKeyModifiers, EventHotKeyID inHotKeyID, EventTargetRef inTarget, OptionBits inOptions) -> (EventHotKeyRef outRef)")},
2130-
{"RunApplicationEventLoop", (PyCFunction)CarbonEvents_RunApplicationEventLoop, 1,
2131-
PyDoc_STR("() -> ()")},
21322100
{NULL, NULL, 0}
21332101
};
21342102

@@ -2142,7 +2110,6 @@ void init_CarbonEvt(void)
21422110

21432111

21442112

2145-
PyMac_PRECHECK(NewEventHandlerUPP); /* This can fail if CarbonLib is too old */
21462113
myEventHandlerUPP = NewEventHandlerUPP(myEventHandler);
21472114

21482115

Mac/Modules/cf/_CFmodule.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55

66

77

8-
#ifdef _WIN32
9-
#include "pywintoolbox.h"
10-
#else
11-
#include "macglue.h"
128
#include "pymactoolbox.h"
13-
#endif
149

1510
/* Macro to test whether a weak-loaded CFM function exists */
1611
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\

0 commit comments

Comments
 (0)