blob: 6e48ca36a269a009d90bd62b30f2889e27c1708a [file] [log] [blame]
Jack Jansen9d8b96c2000-07-14 22:16:45 +00001/*
Jack Jansen94bebc02001-08-08 13:17:31 +00002** pymactoolbox.h - globals defined in mactoolboxglue.c
Jack Jansen9d8b96c2000-07-14 22:16:45 +00003*/
Jack Jansen47ec1412002-09-10 12:32:47 +00004#ifndef Py_PYMACTOOLBOX_H
5#define Py_PYMACTOOLBOX_H
Jack Jansen9d8b96c2000-07-14 22:16:45 +00006#ifdef __cplusplus
7 extern "C" {
8#endif
9
Jack Jansen9f66b4a2001-05-19 12:32:39 +000010#include <Carbon/Carbon.h>
Ronald Oussoren5640ce22008-06-05 12:58:24 +000011
sashkfd2f85d2016-09-16 09:08:45 -040012/*
13** Issue #27806: Workaround for gcc 4.x which does not have _has_include.
14*/
15#ifndef __has_include
16#define __has_include(x) 0
17#endif
18/* Workaround */
19
20#if __has_include(<Availability.h>)
21#include <Availability.h>
22#define APPLE_SUPPORTS_QUICKTIME (__MAC_OS_X_VERSION_MAX_ALLOWED < 101200) && !__LP64__
23#else
24#define APPLE_SUPPORTS_QUICKTIME !__LP64__
25#endif
26
27#if APPLE_SUPPORTS_QUICKTIME
Jack Jansen9f66b4a2001-05-19 12:32:39 +000028#include <QuickTime/QuickTime.h>
sashkfd2f85d2016-09-16 09:08:45 -040029#endif /* APPLE_SUPPORTS_QUICKTIME */
Jack Jansen9d8b96c2000-07-14 22:16:45 +000030
Jack Jansen94bebc02001-08-08 13:17:31 +000031/*
32** Helper routines for error codes and such.
33*/
Raymond Hettingerec6eb362004-11-05 07:02:59 +000034char *PyMac_StrError(int); /* strerror with mac errors */
Jack Jansen3305d242003-11-20 13:28:19 +000035extern PyObject *PyMac_OSErrException; /* Exception for OSErr */
36PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */
Jack Jansen94bebc02001-08-08 13:17:31 +000037PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */
Raymond Hettingerec6eb362004-11-05 07:02:59 +000038PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */
sashkfd2f85d2016-09-16 09:08:45 -040039#if APPLE_SUPPORTS_QUICKTIME
Raymond Hettingerec6eb362004-11-05 07:02:59 +000040extern OSErr PyMac_GetFullPathname(FSSpec *, char *, int); /* convert
41 fsspec->path */
sashkfd2f85d2016-09-16 09:08:45 -040042#endif /* APPLE_SUPPORTS_QUICKTIME */
Ronald Oussoren5640ce22008-06-05 12:58:24 +000043
Jack Jansen94bebc02001-08-08 13:17:31 +000044/*
45** These conversion routines are defined in mactoolboxglue.c itself.
46*/
47int PyMac_GetOSType(PyObject *, OSType *); /* argument parser for OSType */
48PyObject *PyMac_BuildOSType(OSType); /* Convert OSType to PyObject */
49
50PyObject *PyMac_BuildNumVersion(NumVersion);/* Convert NumVersion to PyObject */
51
52int PyMac_GetStr255(PyObject *, Str255); /* argument parser for Str255 */
53PyObject *PyMac_BuildStr255(Str255); /* Convert Str255 to PyObject */
Raymond Hettingerec6eb362004-11-05 07:02:59 +000054PyObject *PyMac_BuildOptStr255(Str255); /* Convert Str255 to PyObject,
55 NULL to None */
Jack Jansen94bebc02001-08-08 13:17:31 +000056
57int PyMac_GetRect(PyObject *, Rect *); /* argument parser for Rect */
Raymond Hettingerec6eb362004-11-05 07:02:59 +000058PyObject *PyMac_BuildRect(Rect *); /* Convert Rect to PyObject */
Jack Jansen94bebc02001-08-08 13:17:31 +000059
60int PyMac_GetPoint(PyObject *, Point *); /* argument parser for Point */
Raymond Hettingerec6eb362004-11-05 07:02:59 +000061PyObject *PyMac_BuildPoint(Point); /* Convert Point to PyObject */
Jack Jansen94bebc02001-08-08 13:17:31 +000062
Raymond Hettingerec6eb362004-11-05 07:02:59 +000063int PyMac_GetEventRecord(PyObject *, EventRecord *); /* argument parser for
64 EventRecord */
65PyObject *PyMac_BuildEventRecord(EventRecord *); /* Convert EventRecord to
66 PyObject */
Jack Jansen94bebc02001-08-08 13:17:31 +000067
68int PyMac_GetFixed(PyObject *, Fixed *); /* argument parser for Fixed */
Raymond Hettingerec6eb362004-11-05 07:02:59 +000069PyObject *PyMac_BuildFixed(Fixed); /* Convert Fixed to PyObject */
Jack Jansen94bebc02001-08-08 13:17:31 +000070int PyMac_Getwide(PyObject *, wide *); /* argument parser for wide */
Raymond Hettingerec6eb362004-11-05 07:02:59 +000071PyObject *PyMac_Buildwide(wide *); /* Convert wide to PyObject */
Jack Jansen94bebc02001-08-08 13:17:31 +000072
73/*
74** The rest of the routines are implemented by extension modules. If they are
75** dynamically loaded mactoolboxglue will contain a stub implementation of the
76** routine, which imports the module, whereupon the module's init routine will
77** communicate the routine pointer back to the stub.
78** If USE_TOOLBOX_OBJECT_GLUE is not defined there is no glue code, and the
79** extension modules simply declare the routine. This is the case for static
80** builds (and could be the case for MacPython CFM builds, because CFM extension
81** modules can reference each other without problems).
82*/
83
Jack Jansenf57a4a22001-05-17 22:11:44 +000084#ifdef USE_TOOLBOX_OBJECT_GLUE
85/*
86** These macros are used in the module init code. If we use toolbox object glue
87** it sets the function pointer to point to the real function.
88*/
Jack Jansen0268ac82001-05-22 22:34:56 +000089#define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) { \
Jack Jansenf57a4a22001-05-17 22:11:44 +000090 extern PyObject *(*PyMacGluePtr_##rtn)(object); \
91 PyMacGluePtr_##rtn = _##rtn; \
92}
Jack Jansen0268ac82001-05-22 22:34:56 +000093#define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) { \
94 extern int (*PyMacGluePtr_##rtn)(PyObject *, object *); \
Jack Jansenf57a4a22001-05-17 22:11:44 +000095 PyMacGluePtr_##rtn = _##rtn; \
96}
97#else
98/*
99** If we don't use toolbox object glue the init macros are empty. Moreover, we define
100** _xxx_New to be the same as xxx_New, and the code in mactoolboxglue isn't included.
101*/
Jack Jansen0268ac82001-05-22 22:34:56 +0000102#define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn)
103#define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn)
Jack Jansenf57a4a22001-05-17 22:11:44 +0000104#endif /* USE_TOOLBOX_OBJECT_GLUE */
105
Jack Jansena5bca572001-08-03 15:39:27 +0000106/* macfs exports */
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000107#ifndef __LP64__
Jack Jansenfabd00f2001-09-01 23:39:58 +0000108int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */
109PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000110#endif /* !__LP64__ */
Jack Jansenfabd00f2001-09-01 23:39:58 +0000111
112int PyMac_GetFSRef(PyObject *, FSRef *); /* argument parser for FSRef */
113PyObject *PyMac_BuildFSRef(FSRef *); /* Convert FSRef to PyObject */
Jack Jansena5bca572001-08-03 15:39:27 +0000114
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000115/* AE exports */
116extern PyObject *AEDesc_New(AppleEvent *); /* XXXX Why passed by address?? */
Jack Jansenb2a57722003-01-17 23:11:17 +0000117extern PyObject *AEDesc_NewBorrowed(AppleEvent *);
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000118extern int AEDesc_Convert(PyObject *, AppleEvent *);
119
120/* Cm exports */
121extern PyObject *CmpObj_New(Component);
122extern int CmpObj_Convert(PyObject *, Component *);
123extern PyObject *CmpInstObj_New(ComponentInstance);
124extern int CmpInstObj_Convert(PyObject *, ComponentInstance *);
125
126/* Ctl exports */
sashkfd2f85d2016-09-16 09:08:45 -0400127#if APPLE_SUPPORTS_QUICKTIME
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000128extern PyObject *CtlObj_New(ControlHandle);
129extern int CtlObj_Convert(PyObject *, ControlHandle *);
sashkfd2f85d2016-09-16 09:08:45 -0400130#endif /* APPLE_SUPPORTS_QUICKTIME */
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000131
132/* Dlg exports */
sashkfd2f85d2016-09-16 09:08:45 -0400133#if APPLE_SUPPORTS_QUICKTIME
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000134extern PyObject *DlgObj_New(DialogPtr);
135extern int DlgObj_Convert(PyObject *, DialogPtr *);
Jack Jansenadd58f92001-02-09 15:59:18 +0000136extern PyObject *DlgObj_WhichDialog(DialogPtr);
sashkfd2f85d2016-09-16 09:08:45 -0400137#endif /* APPLE_SUPPORTS_QUICKTIME */
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000138
139/* Drag exports */
sashkfd2f85d2016-09-16 09:08:45 -0400140#if APPLE_SUPPORTS_QUICKTIME
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000141extern PyObject *DragObj_New(DragReference);
142extern int DragObj_Convert(PyObject *, DragReference *);
sashkfd2f85d2016-09-16 09:08:45 -0400143#endif /* APPLE_SUPPORTS_QUICKTIME */
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000144
145/* List exports */
sashkfd2f85d2016-09-16 09:08:45 -0400146#if APPLE_SUPPORTS_QUICKTIME
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000147extern PyObject *ListObj_New(ListHandle);
148extern int ListObj_Convert(PyObject *, ListHandle *);
sashkfd2f85d2016-09-16 09:08:45 -0400149#endif /* APPLE_SUPPORTS_QUICKTIME */
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000150
151/* Menu exports */
sashkfd2f85d2016-09-16 09:08:45 -0400152#if APPLE_SUPPORTS_QUICKTIME
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000153extern PyObject *MenuObj_New(MenuHandle);
154extern int MenuObj_Convert(PyObject *, MenuHandle *);
sashkfd2f85d2016-09-16 09:08:45 -0400155#endif /* APPLE_SUPPORTS_QUICKTIME */
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000156
157/* Qd exports */
sashkfd2f85d2016-09-16 09:08:45 -0400158#if APPLE_SUPPORTS_QUICKTIME
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000159extern PyObject *GrafObj_New(GrafPtr);
160extern int GrafObj_Convert(PyObject *, GrafPtr *);
161extern PyObject *BMObj_New(BitMapPtr);
162extern int BMObj_Convert(PyObject *, BitMapPtr *);
163extern PyObject *QdRGB_New(RGBColor *);
164extern int QdRGB_Convert(PyObject *, RGBColor *);
sashkfd2f85d2016-09-16 09:08:45 -0400165#endif /* APPLE_SUPPORTS_QUICKTIME */
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000166
Jack Jansen50bf1482000-12-12 22:13:03 +0000167/* Qdoffs exports */
sashkfd2f85d2016-09-16 09:08:45 -0400168#if APPLE_SUPPORTS_QUICKTIME
Jack Jansen50bf1482000-12-12 22:13:03 +0000169extern PyObject *GWorldObj_New(GWorldPtr);
170extern int GWorldObj_Convert(PyObject *, GWorldPtr *);
sashkfd2f85d2016-09-16 09:08:45 -0400171#endif /* APPLE_SUPPORTS_QUICKTIME */
Jack Jansen50bf1482000-12-12 22:13:03 +0000172
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000173/* Qt exports */
sashkfd2f85d2016-09-16 09:08:45 -0400174#if APPLE_SUPPORTS_QUICKTIME
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000175extern PyObject *TrackObj_New(Track);
176extern int TrackObj_Convert(PyObject *, Track *);
177extern PyObject *MovieObj_New(Movie);
178extern int MovieObj_Convert(PyObject *, Movie *);
179extern PyObject *MovieCtlObj_New(MovieController);
Jack Jansenf57a4a22001-05-17 22:11:44 +0000180extern int MovieCtlObj_Convert(PyObject *, MovieController *);
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000181extern PyObject *TimeBaseObj_New(TimeBase);
182extern int TimeBaseObj_Convert(PyObject *, TimeBase *);
183extern PyObject *UserDataObj_New(UserData);
184extern int UserDataObj_Convert(PyObject *, UserData *);
185extern PyObject *MediaObj_New(Media);
186extern int MediaObj_Convert(PyObject *, Media *);
sashkfd2f85d2016-09-16 09:08:45 -0400187#endif /* APPLE_SUPPORTS_QUICKTIME */
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000188
189/* Res exports */
190extern PyObject *ResObj_New(Handle);
191extern int ResObj_Convert(PyObject *, Handle *);
192extern PyObject *OptResObj_New(Handle);
193extern int OptResObj_Convert(PyObject *, Handle *);
194
195/* TE exports */
sashkfd2f85d2016-09-16 09:08:45 -0400196#if APPLE_SUPPORTS_QUICKTIME
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000197extern PyObject *TEObj_New(TEHandle);
198extern int TEObj_Convert(PyObject *, TEHandle *);
sashkfd2f85d2016-09-16 09:08:45 -0400199#endif /* APPLE_SUPPORTS_QUICKTIME */
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000200
201/* Win exports */
sashkfd2f85d2016-09-16 09:08:45 -0400202#if APPLE_SUPPORTS_QUICKTIME
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000203extern PyObject *WinObj_New(WindowPtr);
204extern int WinObj_Convert(PyObject *, WindowPtr *);
205extern PyObject *WinObj_WhichWindow(WindowPtr);
sashkfd2f85d2016-09-16 09:08:45 -0400206#endif /* APPLE_SUPPORTS_QUICKTIME */
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000207
Jack Jansen537a69f2001-11-05 14:39:22 +0000208/* CF exports */
Jack Jansen4eb45e72003-05-27 21:39:58 +0000209extern PyObject *CFObj_New(CFTypeRef);
210extern int CFObj_Convert(PyObject *, CFTypeRef *);
Jack Jansen537a69f2001-11-05 14:39:22 +0000211extern PyObject *CFTypeRefObj_New(CFTypeRef);
212extern int CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
213extern PyObject *CFStringRefObj_New(CFStringRef);
214extern int CFStringRefObj_Convert(PyObject *, CFStringRef *);
215extern PyObject *CFMutableStringRefObj_New(CFMutableStringRef);
216extern int CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *);
217extern PyObject *CFArrayRefObj_New(CFArrayRef);
218extern int CFArrayRefObj_Convert(PyObject *, CFArrayRef *);
219extern PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef);
220extern int CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *);
221extern PyObject *CFDictionaryRefObj_New(CFDictionaryRef);
222extern int CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *);
223extern PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef);
224extern int CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *);
225extern PyObject *CFURLRefObj_New(CFURLRef);
226extern int CFURLRefObj_Convert(PyObject *, CFURLRef *);
227extern int OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *);
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000228
229#ifdef __cplusplus
230 }
231#endif
Jack Jansen47ec1412002-09-10 12:32:47 +0000232#endif