1 /* 2 ** pymactoolbox.h - globals defined in mactoolboxglue.c 3 */ 4 #ifndef Py_PYMACTOOLBOX_H 5 #define Py_PYMACTOOLBOX_H 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 #include <Carbon/Carbon.h> 11 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 28 #include <QuickTime/QuickTime.h> 29 #endif /* APPLE_SUPPORTS_QUICKTIME */ 30 31 /* 32 ** Helper routines for error codes and such. 33 */ 34 char *PyMac_StrError(int); /* strerror with mac errors */ 35 extern PyObject *PyMac_OSErrException; /* Exception for OSErr */ 36 PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */ 37 PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */ 38 PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */ 39 #if APPLE_SUPPORTS_QUICKTIME 40 extern OSErr PyMac_GetFullPathname(FSSpec *, char *, int); /* convert 41 fsspec->path */ 42 #endif /* APPLE_SUPPORTS_QUICKTIME */ 43 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 */ 54 PyObject *PyMac_BuildOptStr255(Str255); /* Convert Str255 to PyObject, 55 NULL to None */ 56 57 int PyMac_GetRect(PyObject *, Rect *); /* argument parser for Rect */ 58 PyObject *PyMac_BuildRect(Rect *); /* Convert Rect to PyObject */ 59 60 int PyMac_GetPoint(PyObject *, Point *); /* argument parser for Point */ 61 PyObject *PyMac_BuildPoint(Point); /* Convert Point to PyObject */ 62 63 int PyMac_GetEventRecord(PyObject *, EventRecord *); /* argument parser for 64 EventRecord */ 65 PyObject *PyMac_BuildEventRecord(EventRecord *); /* Convert EventRecord to 66 PyObject */ 67 68 int PyMac_GetFixed(PyObject *, Fixed *); /* argument parser for Fixed */ 69 PyObject *PyMac_BuildFixed(Fixed); /* Convert Fixed to PyObject */ 70 int PyMac_Getwide(PyObject *, wide *); /* argument parser for wide */ 71 PyObject *PyMac_Buildwide(wide *); /* Convert wide to PyObject */ 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 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 */ 89 #define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) { \ 90 extern PyObject *(*PyMacGluePtr_##rtn)(object); \ 91 PyMacGluePtr_##rtn = _##rtn; \ 92 } 93 #define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) { \ 94 extern int (*PyMacGluePtr_##rtn)(PyObject *, object *); \ 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 */ 102 #define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) 103 #define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) 104 #endif /* USE_TOOLBOX_OBJECT_GLUE */ 105 106 /* macfs exports */ 107 #ifndef __LP64__ 108 int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */ 109 PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */ 110 #endif /* !__LP64__ */ 111 112 int PyMac_GetFSRef(PyObject *, FSRef *); /* argument parser for FSRef */ 113 PyObject *PyMac_BuildFSRef(FSRef *); /* Convert FSRef to PyObject */ 114 115 /* AE exports */ 116 extern PyObject *AEDesc_New(AppleEvent *); /* XXXX Why passed by address?? */ 117 extern PyObject *AEDesc_NewBorrowed(AppleEvent *); 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 */ 127 #if APPLE_SUPPORTS_QUICKTIME 128 extern PyObject *CtlObj_New(ControlHandle); 129 extern int CtlObj_Convert(PyObject *, ControlHandle *); 130 #endif /* APPLE_SUPPORTS_QUICKTIME */ 131 132 /* Dlg exports */ 133 #if APPLE_SUPPORTS_QUICKTIME 134 extern PyObject *DlgObj_New(DialogPtr); 135 extern int DlgObj_Convert(PyObject *, DialogPtr *); 136 extern PyObject *DlgObj_WhichDialog(DialogPtr); 137 #endif /* APPLE_SUPPORTS_QUICKTIME */ 138 139 /* Drag exports */ 140 #if APPLE_SUPPORTS_QUICKTIME 141 extern PyObject *DragObj_New(DragReference); 142 extern int DragObj_Convert(PyObject *, DragReference *); 143 #endif /* APPLE_SUPPORTS_QUICKTIME */ 144 145 /* List exports */ 146 #if APPLE_SUPPORTS_QUICKTIME 147 extern PyObject *ListObj_New(ListHandle); 148 extern int ListObj_Convert(PyObject *, ListHandle *); 149 #endif /* APPLE_SUPPORTS_QUICKTIME */ 150 151 /* Menu exports */ 152 #if APPLE_SUPPORTS_QUICKTIME 153 extern PyObject *MenuObj_New(MenuHandle); 154 extern int MenuObj_Convert(PyObject *, MenuHandle *); 155 #endif /* APPLE_SUPPORTS_QUICKTIME */ 156 157 /* Qd exports */ 158 #if APPLE_SUPPORTS_QUICKTIME 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 *); 165 #endif /* APPLE_SUPPORTS_QUICKTIME */ 166 167 /* Qdoffs exports */ 168 #if APPLE_SUPPORTS_QUICKTIME 169 extern PyObject *GWorldObj_New(GWorldPtr); 170 extern int GWorldObj_Convert(PyObject *, GWorldPtr *); 171 #endif /* APPLE_SUPPORTS_QUICKTIME */ 172 173 /* Qt exports */ 174 #if APPLE_SUPPORTS_QUICKTIME 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); 180 extern int MovieCtlObj_Convert(PyObject *, MovieController *); 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 *); 187 #endif /* APPLE_SUPPORTS_QUICKTIME */ 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 */ 196 #if APPLE_SUPPORTS_QUICKTIME 197 extern PyObject *TEObj_New(TEHandle); 198 extern int TEObj_Convert(PyObject *, TEHandle *); 199 #endif /* APPLE_SUPPORTS_QUICKTIME */ 200 201 /* Win exports */ 202 #if APPLE_SUPPORTS_QUICKTIME 203 extern PyObject *WinObj_New(WindowPtr); 204 extern int WinObj_Convert(PyObject *, WindowPtr *); 205 extern PyObject *WinObj_WhichWindow(WindowPtr); 206 #endif /* APPLE_SUPPORTS_QUICKTIME */ 207 208 /* CF exports */ 209 extern PyObject *CFObj_New(CFTypeRef); 210 extern int CFObj_Convert(PyObject *, CFTypeRef *); 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 *); 228 229 #ifdef __cplusplus 230 } 231 #endif 232 #endif 233