Cleaned up various things in the toolbox modules.
#include <Carbon/Carbon.h>
#include "Python.h"
-#include "macglue.h"
#include "pymactoolbox.h"
/* ----------------------------------------------------- */
******************************************************************/
#include "Python.h"
-#include "macglue.h"
#include "pymactoolbox.h"
#include <Carbon/Carbon.h>
** by a full interface to OpenScripting.
*/
#include "Python.h"
-#include "macglue.h"
+#include "pymactoolbox.h"
#include <Carbon/Carbon.h>
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
# Wrote by hand
"InstallEventHandler",
"RemoveEventHandler",
- "RunApplicationEventLoop",
# Write by hand?
"GetEventParameter",
MouseTrackingResult = UInt16
-includestuff = r"""
+includestuff = includestuff + r"""
#include <Carbon/Carbon.h>
-#include "macglue.h"
-
-/* 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)
-
-
-#define USE_MAC_MP_MULTITHREADING 0
-
-#if USE_MAC_MP_MULTITHREADING
-static PyThreadState *_save;
-static MPCriticalRegionID reentrantLock;
-#endif /* USE_MAC_MP_MULTITHREADING */
-
extern int CFStringRef_New(CFStringRef *);
extern int CFStringRef_Convert(PyObject *, CFStringRef *);
PyObject *retValue;
int status;
-#if USE_MAC_MP_MULTITHREADING
- MPEnterCriticalRegion(reentrantLock, kDurationForever);
- PyEval_RestoreThread(_save);
-#endif /* USE_MAC_MP_MULTITHREADING */
-
retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&",
EventHandlerCallRef_New, handlerRef,
EventRef_New, event);
Py_DECREF(retValue);
}
-#if USE_MAC_MP_MULTITHREADING
- _save = PyEval_SaveThread();
- MPExitCriticalRegion(reentrantLock);
-#endif /* USE_MAC_MP_MULTITHREADING */
-
return status;
}
"""
initstuff = initstuff + """
-PyMac_PRECHECK(NewEventHandlerUPP); /* This can fail if CarbonLib is too old */
myEventHandlerUPP = NewEventHandlerUPP(myEventHandler);
"""
module = MacModule('_CarbonEvt', 'CarbonEvents', includestuff, finalstuff, initstuff)
f.docstring = lambda: "(EventParamName eventName, EventParamType eventType) -> (String eventParamData)"
EventRefobject.add(f)
-runappeventloop = """
-#if USE_MAC_MP_MULTITHREADING
-if (MPCreateCriticalRegion(&reentrantLock) != noErr) {
- PySys_WriteStderr("lock failure\\n");
- return NULL;
-}
-_save = PyEval_SaveThread();
-#endif /* USE_MAC_MP_MULTITHREADING */
-
-RunApplicationEventLoop();
-
-#if USE_MAC_MP_MULTITHREADING
-PyEval_RestoreThread(_save);
-
-MPDeleteCriticalRegion(reentrantLock);
-#endif /* USE_MAC_MP_MULTITHREADING */
-
-Py_INCREF(Py_None);
-_res = Py_None;
-return _res;
-"""
-
-f = ManualGenerator("RunApplicationEventLoop", runappeventloop);
-f.docstring = lambda: "() -> ()"
-module.add(f)
-
SetOutputFileName('_CarbonEvtmodule.c')
module.generate()
-#include <Carbon/Carbon.h>
-
-#include "macglue.h"
+#include "pymactoolbox.h"
/* 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 NULL; \
+ }} while(0)
-#define USE_MAC_MP_MULTITHREADING 0
-#if USE_MAC_MP_MULTITHREADING
-static PyThreadState *_save;
-static MPCriticalRegionID reentrantLock;
-#endif /* USE_MAC_MP_MULTITHREADING */
+#include <Carbon/Carbon.h>
extern int CFStringRef_New(CFStringRef *);
PyObject *retValue;
int status;
-#if USE_MAC_MP_MULTITHREADING
- MPEnterCriticalRegion(reentrantLock, kDurationForever);
- PyEval_RestoreThread(_save);
-#endif /* USE_MAC_MP_MULTITHREADING */
-
retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&",
EventHandlerCallRef_New, handlerRef,
EventRef_New, event);
Py_DECREF(retValue);
}
-#if USE_MAC_MP_MULTITHREADING
- _save = PyEval_SaveThread();
- MPExitCriticalRegion(reentrantLock);
-#endif /* USE_MAC_MP_MULTITHREADING */
-
return status;
}
return _res;
}
+static PyObject *CarbonEvents_RunApplicationEventLoop(PyObject *_self, PyObject *_args)
+{
+ PyObject *_res = NULL;
+ if (!PyArg_ParseTuple(_args, ""))
+ return NULL;
+ RunApplicationEventLoop();
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
static PyObject *CarbonEvents_QuitApplicationEventLoop(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
return _res;
}
-static PyObject *CarbonEvents_RunApplicationEventLoop(PyObject *_self, PyObject *_args)
-{
- PyObject *_res = NULL;
-
-#if USE_MAC_MP_MULTITHREADING
- if (MPCreateCriticalRegion(&reentrantLock) != noErr) {
- PySys_WriteStderr("lock failure\n");
- return NULL;
- }
- _save = PyEval_SaveThread();
-#endif /* USE_MAC_MP_MULTITHREADING */
-
- RunApplicationEventLoop();
-
-#if USE_MAC_MP_MULTITHREADING
- PyEval_RestoreThread(_save);
-
- MPDeleteCriticalRegion(reentrantLock);
-#endif /* USE_MAC_MP_MULTITHREADING */
-
- Py_INCREF(Py_None);
- _res = Py_None;
- return _res;
-
-}
-
static PyMethodDef CarbonEvents_methods[] = {
{"GetCurrentEventLoop", (PyCFunction)CarbonEvents_GetCurrentEventLoop, 1,
PyDoc_STR("() -> (EventLoopRef _rv)")},
PyDoc_STR("() -> (EventTargetRef _rv)")},
{"GetEventDispatcherTarget", (PyCFunction)CarbonEvents_GetEventDispatcherTarget, 1,
PyDoc_STR("() -> (EventTargetRef _rv)")},
+ {"RunApplicationEventLoop", (PyCFunction)CarbonEvents_RunApplicationEventLoop, 1,
+ PyDoc_STR("() -> None")},
{"QuitApplicationEventLoop", (PyCFunction)CarbonEvents_QuitApplicationEventLoop, 1,
PyDoc_STR("() -> None")},
{"RunAppModalLoopForWindow", (PyCFunction)CarbonEvents_RunAppModalLoopForWindow, 1,
PyDoc_STR("(WindowPtr inWindow) -> (ControlHandle outControl)")},
{"RegisterEventHotKey", (PyCFunction)CarbonEvents_RegisterEventHotKey, 1,
PyDoc_STR("(UInt32 inHotKeyCode, UInt32 inHotKeyModifiers, EventHotKeyID inHotKeyID, EventTargetRef inTarget, OptionBits inOptions) -> (EventHotKeyRef outRef)")},
- {"RunApplicationEventLoop", (PyCFunction)CarbonEvents_RunApplicationEventLoop, 1,
- PyDoc_STR("() -> ()")},
{NULL, NULL, 0}
};
- PyMac_PRECHECK(NewEventHandlerUPP); /* This can fail if CarbonLib is too old */
myEventHandlerUPP = NewEventHandlerUPP(myEventHandler);
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
#include <CoreServices/CoreServices.h>
#include "Python.h"
-#include "macglue.h"
+#include "pymactoolbox.h"
#include "pycfbridge.h"
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
/* Macintosh Gestalt interface */
#include "Python.h"
-#include "macglue.h"
+#include "pymactoolbox.h"
#include <Carbon/Carbon.h>
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
includestuff = """
#include <Carbon/Carbon.h>
-#include "macglue.h"
+#include "pymactoolbox.h"
#ifdef USE_TOOLBOX_OBJECT_GLUE
extern int _CFStringRefObj_Convert(PyObject *, CFStringRef *);
-//#define CFStringRefObj_Convert _CFStringRefObj_Convert
#endif
-//extern int CFBundleRefObj_Convert(PyObject *, CFBundleRef *); // need to wrap CFBundle
-
"""
initstuff = """
#include <Carbon/Carbon.h>
-#include "macglue.h"
+#include "pymactoolbox.h"
#ifdef USE_TOOLBOX_OBJECT_GLUE
extern int _CFStringRefObj_Convert(PyObject *, CFStringRef *);
-//#define CFStringRefObj_Convert _CFStringRefObj_Convert
#endif
-//extern int CFBundleRefObj_Convert(PyObject *, CFBundleRef *); // need to wrap CFBundle
-
static PyObject *IBCarbon_Error;
******************************************************************/
#include "Python.h"
-#include "macglue.h"
+#include "pymactoolbox.h"
extern int ResObj_Convert(PyObject *, Handle *); /* From Resmodule.c */
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
/* Macintosh OS-specific interface */
#include "Python.h"
-#include "macglue.h"
-#include "pythonresources.h"
+#include "pymactoolbox.h"
#include <Carbon/Carbon.h>
#include <ApplicationServices/ApplicationServices.h>
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifndef PyDoc_STR
-#define PyDoc_STR(x) (x)
-#endif
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* 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 NULL; \
+ PyErr_SetString(PyExc_NotImplementedError, \
+ "Not available in this shared library/OS version"); \
+ return NULL; \
}} while(0)
PyTypeObject Scrap_Type;
-#define ScrapObj_Check(x) ((x)->ob_type == &Scrap_Type)
+#define ScrapObj_Check(x) ((x)->ob_type == &Scrap_Type || PyObject_TypeCheck((x), &Scrap_Type))
typedef struct ScrapObject {
PyObject_HEAD
static void ScrapObj_dealloc(ScrapObject *self)
{
/* Cleanup of self->ob_itself goes here */
- PyObject_DEL(self);
+ self->ob_type->tp_free((PyObject *)self);
}
static PyObject *ScrapObj_GetScrapFlavorFlags(ScrapObject *_self, PyObject *_args)
static PyMethodDef ScrapObj_methods[] = {
{"GetScrapFlavorFlags", (PyCFunction)ScrapObj_GetScrapFlavorFlags, 1,
- "(ScrapFlavorType flavorType) -> (ScrapFlavorFlags flavorFlags)"},
+ PyDoc_STR("(ScrapFlavorType flavorType) -> (ScrapFlavorFlags flavorFlags)")},
{"GetScrapFlavorSize", (PyCFunction)ScrapObj_GetScrapFlavorSize, 1,
- "(ScrapFlavorType flavorType) -> (Size byteCount)"},
+ PyDoc_STR("(ScrapFlavorType flavorType) -> (Size byteCount)")},
{"GetScrapFlavorData", (PyCFunction)ScrapObj_GetScrapFlavorData, 1,
- "(ScrapFlavorType flavorType) -> string"},
+ PyDoc_STR("(ScrapFlavorType flavorType, Buffer destination) -> (Size byteCount)")},
{"PutScrapFlavor", (PyCFunction)ScrapObj_PutScrapFlavor, 1,
- "(ScrapFlavorType flavorType, ScrapFlavorFlags flavorFlags, Buffer flavorData) -> None"},
+ PyDoc_STR("(ScrapFlavorType flavorType, ScrapFlavorFlags flavorFlags, Size flavorSize, Buffer flavorData) -> None")},
{"GetScrapFlavorCount", (PyCFunction)ScrapObj_GetScrapFlavorCount, 1,
- "() -> (UInt32 infoCount)"},
+ PyDoc_STR("() -> (UInt32 infoCount)")},
{"GetScrapFlavorInfoList", (PyCFunction)ScrapObj_GetScrapFlavorInfoList, 1,
- "() -> ([(ScrapFlavorType, ScrapFlavorInfo), ...])"},
+ PyDoc_STR("() -> ([(ScrapFlavorType, ScrapFlavorInfo), ...])")},
{NULL, NULL, 0}
};
static PyMethodDef Scrap_methods[] = {
{"LoadScrap", (PyCFunction)Scrap_LoadScrap, 1,
- "() -> None"},
+ PyDoc_STR("() -> None")},
{"UnloadScrap", (PyCFunction)Scrap_UnloadScrap, 1,
- "() -> None"},
+ PyDoc_STR("() -> None")},
{"GetCurrentScrap", (PyCFunction)Scrap_GetCurrentScrap, 1,
- "() -> (ScrapRef scrap)"},
+ PyDoc_STR("() -> (ScrapRef scrap)")},
{"ClearCurrentScrap", (PyCFunction)Scrap_ClearCurrentScrap, 1,
- "() -> None"},
+ PyDoc_STR("() -> None")},
{"CallInScrapPromises", (PyCFunction)Scrap_CallInScrapPromises, 1,
- "() -> None"},
+ PyDoc_STR("() -> None")},
{NULL, NULL, 0}
};
******************************************************************/
#include "Python.h"
-#include "macglue.h"
#include "pymactoolbox.h"
#include <Sound.h>
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* 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 NULL; \
+ PyErr_SetString(PyExc_NotImplementedError, \
+ "Not available in this shared library/OS version"); \
+ return NULL; \
}} while(0)
#include <WASTE.h>
#include <WEObjectHandlers.h>
#include <WETabs.h>
-#ifndef PyDoc_STR
-#define PyDoc_STR(x) (x)
-#endif
/* Exported by Qdmodule.c: */
extern PyObject *QdRGB_New(RGBColor *);
sys.path.append(BGENDIR)
from scantools import Scanner
-WASTEDIR='/Volumes/Moes/Applications (Mac OS 9)/Metrowerks CodeWarrior 7.0/Metrowerks CodeWarrior/MacOS Support/(Third Party Support)/Waste 2.0 Distribution/C_C++ Headers/'
+WASTEDIR='/Users/jack/src/waste/C_C++ Headers/'
if not os.path.exists(WASTEDIR):
raise 'Error: not found: %s', WASTEDIR
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
#include <wchar.h>
#endif
+#if defined(__APPLE__)
+#include "pymactoolbox.h"
+#endif
+
#if defined(MS_WINDOWS)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
-#if defined(__APPLE__)
-#include "macglue.h"
-#endif
-
#ifdef RISCOS
char *strdup(const char *);
#endif
# Stuff added immediately after the system include files
includestuff = """
-#ifdef _WIN32
-#include "pywintoolbox.h"
-#else
-#include "macglue.h"
#include "pymactoolbox.h"
-#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\\
"Subclass which gets the exception initializer from macglue.c"
def exceptionInitializer(self):
return "PyMac_GetOSErrException()"
-
-_SetOutputFileName = SetOutputFileName # Save original
-def SetOutputFileName(file = None):
- "Set the output file name and set its creator&type to CWIE&TEXT"
- _SetOutputFileName(file)
- if file:
- import MacOS
- MacOS.SetCreatorAndType(file, 'CWIE', 'TEXT')