Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 1 | /* |
Jack Jansen | 94bebc0 | 2001-08-08 13:17:31 +0000 | [diff] [blame] | 2 | ** pymactoolbox.h - globals defined in mactoolboxglue.c |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 3 | */ |
Jack Jansen | 47ec141 | 2002-09-10 12:32:47 +0000 | [diff] [blame] | 4 | #ifndef Py_PYMACTOOLBOX_H |
| 5 | #define Py_PYMACTOOLBOX_H |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
| 9 | |
Jack Jansen | 9f66b4a | 2001-05-19 12:32:39 +0000 | [diff] [blame] | 10 | #include <Carbon/Carbon.h> |
Ronald Oussoren | 5640ce2 | 2008-06-05 12:58:24 +0000 | [diff] [blame] | 11 | |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 12 | /* |
| 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 Jansen | 9f66b4a | 2001-05-19 12:32:39 +0000 | [diff] [blame] | 28 | #include <QuickTime/QuickTime.h> |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 29 | #endif /* APPLE_SUPPORTS_QUICKTIME */ |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 30 | |
Jack Jansen | 94bebc0 | 2001-08-08 13:17:31 +0000 | [diff] [blame] | 31 | /* |
| 32 | ** Helper routines for error codes and such. |
| 33 | */ |
Raymond Hettinger | ec6eb36 | 2004-11-05 07:02:59 +0000 | [diff] [blame] | 34 | char *PyMac_StrError(int); /* strerror with mac errors */ |
Jack Jansen | 3305d24 | 2003-11-20 13:28:19 +0000 | [diff] [blame] | 35 | extern PyObject *PyMac_OSErrException; /* Exception for OSErr */ |
| 36 | PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */ |
Jack Jansen | 94bebc0 | 2001-08-08 13:17:31 +0000 | [diff] [blame] | 37 | PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */ |
Raymond Hettinger | ec6eb36 | 2004-11-05 07:02:59 +0000 | [diff] [blame] | 38 | PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */ |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 39 | #if APPLE_SUPPORTS_QUICKTIME |
Raymond Hettinger | ec6eb36 | 2004-11-05 07:02:59 +0000 | [diff] [blame] | 40 | extern OSErr PyMac_GetFullPathname(FSSpec *, char *, int); /* convert |
| 41 | fsspec->path */ |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 42 | #endif /* APPLE_SUPPORTS_QUICKTIME */ |
Ronald Oussoren | 5640ce2 | 2008-06-05 12:58:24 +0000 | [diff] [blame] | 43 | |
Jack Jansen | 94bebc0 | 2001-08-08 13:17:31 +0000 | [diff] [blame] | 44 | /* |
| 45 | ** These conversion routines are defined in mactoolboxglue.c itself. |
| 46 | */ |
| 47 | int PyMac_GetOSType(PyObject *, OSType *); /* argument parser for OSType */ |
| 48 | PyObject *PyMac_BuildOSType(OSType); /* Convert OSType to PyObject */ |
| 49 | |
| 50 | PyObject *PyMac_BuildNumVersion(NumVersion);/* Convert NumVersion to PyObject */ |
| 51 | |
| 52 | int PyMac_GetStr255(PyObject *, Str255); /* argument parser for Str255 */ |
| 53 | PyObject *PyMac_BuildStr255(Str255); /* Convert Str255 to PyObject */ |
Raymond Hettinger | ec6eb36 | 2004-11-05 07:02:59 +0000 | [diff] [blame] | 54 | PyObject *PyMac_BuildOptStr255(Str255); /* Convert Str255 to PyObject, |
| 55 | NULL to None */ |
Jack Jansen | 94bebc0 | 2001-08-08 13:17:31 +0000 | [diff] [blame] | 56 | |
| 57 | int PyMac_GetRect(PyObject *, Rect *); /* argument parser for Rect */ |
Raymond Hettinger | ec6eb36 | 2004-11-05 07:02:59 +0000 | [diff] [blame] | 58 | PyObject *PyMac_BuildRect(Rect *); /* Convert Rect to PyObject */ |
Jack Jansen | 94bebc0 | 2001-08-08 13:17:31 +0000 | [diff] [blame] | 59 | |
| 60 | int PyMac_GetPoint(PyObject *, Point *); /* argument parser for Point */ |
Raymond Hettinger | ec6eb36 | 2004-11-05 07:02:59 +0000 | [diff] [blame] | 61 | PyObject *PyMac_BuildPoint(Point); /* Convert Point to PyObject */ |
Jack Jansen | 94bebc0 | 2001-08-08 13:17:31 +0000 | [diff] [blame] | 62 | |
Raymond Hettinger | ec6eb36 | 2004-11-05 07:02:59 +0000 | [diff] [blame] | 63 | int PyMac_GetEventRecord(PyObject *, EventRecord *); /* argument parser for |
| 64 | EventRecord */ |
| 65 | PyObject *PyMac_BuildEventRecord(EventRecord *); /* Convert EventRecord to |
| 66 | PyObject */ |
Jack Jansen | 94bebc0 | 2001-08-08 13:17:31 +0000 | [diff] [blame] | 67 | |
| 68 | int PyMac_GetFixed(PyObject *, Fixed *); /* argument parser for Fixed */ |
Raymond Hettinger | ec6eb36 | 2004-11-05 07:02:59 +0000 | [diff] [blame] | 69 | PyObject *PyMac_BuildFixed(Fixed); /* Convert Fixed to PyObject */ |
Jack Jansen | 94bebc0 | 2001-08-08 13:17:31 +0000 | [diff] [blame] | 70 | int PyMac_Getwide(PyObject *, wide *); /* argument parser for wide */ |
Raymond Hettinger | ec6eb36 | 2004-11-05 07:02:59 +0000 | [diff] [blame] | 71 | PyObject *PyMac_Buildwide(wide *); /* Convert wide to PyObject */ |
Jack Jansen | 94bebc0 | 2001-08-08 13:17:31 +0000 | [diff] [blame] | 72 | |
| 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 Jansen | f57a4a2 | 2001-05-17 22:11:44 +0000 | [diff] [blame] | 84 | #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 Jansen | 0268ac8 | 2001-05-22 22:34:56 +0000 | [diff] [blame] | 89 | #define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) { \ |
Jack Jansen | f57a4a2 | 2001-05-17 22:11:44 +0000 | [diff] [blame] | 90 | extern PyObject *(*PyMacGluePtr_##rtn)(object); \ |
| 91 | PyMacGluePtr_##rtn = _##rtn; \ |
| 92 | } |
Jack Jansen | 0268ac8 | 2001-05-22 22:34:56 +0000 | [diff] [blame] | 93 | #define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) { \ |
| 94 | extern int (*PyMacGluePtr_##rtn)(PyObject *, object *); \ |
Jack Jansen | f57a4a2 | 2001-05-17 22:11:44 +0000 | [diff] [blame] | 95 | 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 Jansen | 0268ac8 | 2001-05-22 22:34:56 +0000 | [diff] [blame] | 102 | #define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) |
| 103 | #define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) |
Jack Jansen | f57a4a2 | 2001-05-17 22:11:44 +0000 | [diff] [blame] | 104 | #endif /* USE_TOOLBOX_OBJECT_GLUE */ |
| 105 | |
Jack Jansen | a5bca57 | 2001-08-03 15:39:27 +0000 | [diff] [blame] | 106 | /* macfs exports */ |
Ronald Oussoren | 5640ce2 | 2008-06-05 12:58:24 +0000 | [diff] [blame] | 107 | #ifndef __LP64__ |
Jack Jansen | fabd00f | 2001-09-01 23:39:58 +0000 | [diff] [blame] | 108 | int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */ |
| 109 | PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */ |
Ronald Oussoren | 5640ce2 | 2008-06-05 12:58:24 +0000 | [diff] [blame] | 110 | #endif /* !__LP64__ */ |
Jack Jansen | fabd00f | 2001-09-01 23:39:58 +0000 | [diff] [blame] | 111 | |
| 112 | int PyMac_GetFSRef(PyObject *, FSRef *); /* argument parser for FSRef */ |
| 113 | PyObject *PyMac_BuildFSRef(FSRef *); /* Convert FSRef to PyObject */ |
Jack Jansen | a5bca57 | 2001-08-03 15:39:27 +0000 | [diff] [blame] | 114 | |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 115 | /* AE exports */ |
| 116 | extern PyObject *AEDesc_New(AppleEvent *); /* XXXX Why passed by address?? */ |
Jack Jansen | b2a5772 | 2003-01-17 23:11:17 +0000 | [diff] [blame] | 117 | extern PyObject *AEDesc_NewBorrowed(AppleEvent *); |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 118 | extern int AEDesc_Convert(PyObject *, AppleEvent *); |
| 119 | |
| 120 | /* Cm exports */ |
| 121 | extern PyObject *CmpObj_New(Component); |
| 122 | extern int CmpObj_Convert(PyObject *, Component *); |
| 123 | extern PyObject *CmpInstObj_New(ComponentInstance); |
| 124 | extern int CmpInstObj_Convert(PyObject *, ComponentInstance *); |
| 125 | |
| 126 | /* Ctl exports */ |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 127 | #if APPLE_SUPPORTS_QUICKTIME |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 128 | extern PyObject *CtlObj_New(ControlHandle); |
| 129 | extern int CtlObj_Convert(PyObject *, ControlHandle *); |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 130 | #endif /* APPLE_SUPPORTS_QUICKTIME */ |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 131 | |
| 132 | /* Dlg exports */ |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 133 | #if APPLE_SUPPORTS_QUICKTIME |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 134 | extern PyObject *DlgObj_New(DialogPtr); |
| 135 | extern int DlgObj_Convert(PyObject *, DialogPtr *); |
Jack Jansen | add58f9 | 2001-02-09 15:59:18 +0000 | [diff] [blame] | 136 | extern PyObject *DlgObj_WhichDialog(DialogPtr); |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 137 | #endif /* APPLE_SUPPORTS_QUICKTIME */ |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 138 | |
| 139 | /* Drag exports */ |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 140 | #if APPLE_SUPPORTS_QUICKTIME |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 141 | extern PyObject *DragObj_New(DragReference); |
| 142 | extern int DragObj_Convert(PyObject *, DragReference *); |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 143 | #endif /* APPLE_SUPPORTS_QUICKTIME */ |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 144 | |
| 145 | /* List exports */ |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 146 | #if APPLE_SUPPORTS_QUICKTIME |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 147 | extern PyObject *ListObj_New(ListHandle); |
| 148 | extern int ListObj_Convert(PyObject *, ListHandle *); |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 149 | #endif /* APPLE_SUPPORTS_QUICKTIME */ |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 150 | |
| 151 | /* Menu exports */ |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 152 | #if APPLE_SUPPORTS_QUICKTIME |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 153 | extern PyObject *MenuObj_New(MenuHandle); |
| 154 | extern int MenuObj_Convert(PyObject *, MenuHandle *); |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 155 | #endif /* APPLE_SUPPORTS_QUICKTIME */ |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 156 | |
| 157 | /* Qd exports */ |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 158 | #if APPLE_SUPPORTS_QUICKTIME |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 159 | extern PyObject *GrafObj_New(GrafPtr); |
| 160 | extern int GrafObj_Convert(PyObject *, GrafPtr *); |
| 161 | extern PyObject *BMObj_New(BitMapPtr); |
| 162 | extern int BMObj_Convert(PyObject *, BitMapPtr *); |
| 163 | extern PyObject *QdRGB_New(RGBColor *); |
| 164 | extern int QdRGB_Convert(PyObject *, RGBColor *); |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 165 | #endif /* APPLE_SUPPORTS_QUICKTIME */ |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 166 | |
Jack Jansen | 50bf148 | 2000-12-12 22:13:03 +0000 | [diff] [blame] | 167 | /* Qdoffs exports */ |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 168 | #if APPLE_SUPPORTS_QUICKTIME |
Jack Jansen | 50bf148 | 2000-12-12 22:13:03 +0000 | [diff] [blame] | 169 | extern PyObject *GWorldObj_New(GWorldPtr); |
| 170 | extern int GWorldObj_Convert(PyObject *, GWorldPtr *); |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 171 | #endif /* APPLE_SUPPORTS_QUICKTIME */ |
Jack Jansen | 50bf148 | 2000-12-12 22:13:03 +0000 | [diff] [blame] | 172 | |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 173 | /* Qt exports */ |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 174 | #if APPLE_SUPPORTS_QUICKTIME |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 175 | extern PyObject *TrackObj_New(Track); |
| 176 | extern int TrackObj_Convert(PyObject *, Track *); |
| 177 | extern PyObject *MovieObj_New(Movie); |
| 178 | extern int MovieObj_Convert(PyObject *, Movie *); |
| 179 | extern PyObject *MovieCtlObj_New(MovieController); |
Jack Jansen | f57a4a2 | 2001-05-17 22:11:44 +0000 | [diff] [blame] | 180 | extern int MovieCtlObj_Convert(PyObject *, MovieController *); |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 181 | extern PyObject *TimeBaseObj_New(TimeBase); |
| 182 | extern int TimeBaseObj_Convert(PyObject *, TimeBase *); |
| 183 | extern PyObject *UserDataObj_New(UserData); |
| 184 | extern int UserDataObj_Convert(PyObject *, UserData *); |
| 185 | extern PyObject *MediaObj_New(Media); |
| 186 | extern int MediaObj_Convert(PyObject *, Media *); |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 187 | #endif /* APPLE_SUPPORTS_QUICKTIME */ |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 188 | |
| 189 | /* Res exports */ |
| 190 | extern PyObject *ResObj_New(Handle); |
| 191 | extern int ResObj_Convert(PyObject *, Handle *); |
| 192 | extern PyObject *OptResObj_New(Handle); |
| 193 | extern int OptResObj_Convert(PyObject *, Handle *); |
| 194 | |
| 195 | /* TE exports */ |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 196 | #if APPLE_SUPPORTS_QUICKTIME |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 197 | extern PyObject *TEObj_New(TEHandle); |
| 198 | extern int TEObj_Convert(PyObject *, TEHandle *); |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 199 | #endif /* APPLE_SUPPORTS_QUICKTIME */ |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 200 | |
| 201 | /* Win exports */ |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 202 | #if APPLE_SUPPORTS_QUICKTIME |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 203 | extern PyObject *WinObj_New(WindowPtr); |
| 204 | extern int WinObj_Convert(PyObject *, WindowPtr *); |
| 205 | extern PyObject *WinObj_WhichWindow(WindowPtr); |
sashk | fd2f85d | 2016-09-16 09:08:45 -0400 | [diff] [blame] | 206 | #endif /* APPLE_SUPPORTS_QUICKTIME */ |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 207 | |
Jack Jansen | 537a69f | 2001-11-05 14:39:22 +0000 | [diff] [blame] | 208 | /* CF exports */ |
Jack Jansen | 4eb45e7 | 2003-05-27 21:39:58 +0000 | [diff] [blame] | 209 | extern PyObject *CFObj_New(CFTypeRef); |
| 210 | extern int CFObj_Convert(PyObject *, CFTypeRef *); |
Jack Jansen | 537a69f | 2001-11-05 14:39:22 +0000 | [diff] [blame] | 211 | extern PyObject *CFTypeRefObj_New(CFTypeRef); |
| 212 | extern int CFTypeRefObj_Convert(PyObject *, CFTypeRef *); |
| 213 | extern PyObject *CFStringRefObj_New(CFStringRef); |
| 214 | extern int CFStringRefObj_Convert(PyObject *, CFStringRef *); |
| 215 | extern PyObject *CFMutableStringRefObj_New(CFMutableStringRef); |
| 216 | extern int CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *); |
| 217 | extern PyObject *CFArrayRefObj_New(CFArrayRef); |
| 218 | extern int CFArrayRefObj_Convert(PyObject *, CFArrayRef *); |
| 219 | extern PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef); |
| 220 | extern int CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *); |
| 221 | extern PyObject *CFDictionaryRefObj_New(CFDictionaryRef); |
| 222 | extern int CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *); |
| 223 | extern PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef); |
| 224 | extern int CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *); |
| 225 | extern PyObject *CFURLRefObj_New(CFURLRef); |
| 226 | extern int CFURLRefObj_Convert(PyObject *, CFURLRef *); |
| 227 | extern int OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *); |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 228 | |
| 229 | #ifdef __cplusplus |
| 230 | } |
| 231 | #endif |
Jack Jansen | 47ec141 | 2002-09-10 12:32:47 +0000 | [diff] [blame] | 232 | #endif |