pymactoolbox.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. #include <Carbon/Carbon.h>
  10. /*
  11. ** Issue #27806: Workaround for gcc 4.x which does not have _has_include.
  12. */
  13. #ifndef __has_include
  14. #define __has_include(x) 0
  15. #endif
  16. /* Workaround */
  17. #if __has_include(<Availability.h>)
  18. #include <Availability.h>
  19. #define APPLE_SUPPORTS_QUICKTIME (__MAC_OS_X_VERSION_MAX_ALLOWED < 101200) && !__LP64__
  20. #else
  21. #define APPLE_SUPPORTS_QUICKTIME !__LP64__
  22. #endif
  23. #if APPLE_SUPPORTS_QUICKTIME
  24. #include <QuickTime/QuickTime.h>
  25. #endif /* APPLE_SUPPORTS_QUICKTIME */
  26. /*
  27. ** Helper routines for error codes and such.
  28. */
  29. char *PyMac_StrError(int); /* strerror with mac errors */
  30. extern PyObject *PyMac_OSErrException; /* Exception for OSErr */
  31. PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */
  32. PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */
  33. PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */
  34. #if APPLE_SUPPORTS_QUICKTIME
  35. extern OSErr PyMac_GetFullPathname(FSSpec *, char *, int); /* convert
  36. fsspec->path */
  37. #endif /* APPLE_SUPPORTS_QUICKTIME */
  38. /*
  39. ** These conversion routines are defined in mactoolboxglue.c itself.
  40. */
  41. int PyMac_GetOSType(PyObject *, OSType *); /* argument parser for OSType */
  42. PyObject *PyMac_BuildOSType(OSType); /* Convert OSType to PyObject */
  43. PyObject *PyMac_BuildNumVersion(NumVersion);/* Convert NumVersion to PyObject */
  44. int PyMac_GetStr255(PyObject *, Str255); /* argument parser for Str255 */
  45. PyObject *PyMac_BuildStr255(Str255); /* Convert Str255 to PyObject */
  46. PyObject *PyMac_BuildOptStr255(Str255); /* Convert Str255 to PyObject,
  47. NULL to None */
  48. int PyMac_GetRect(PyObject *, Rect *); /* argument parser for Rect */
  49. PyObject *PyMac_BuildRect(Rect *); /* Convert Rect to PyObject */
  50. int PyMac_GetPoint(PyObject *, Point *); /* argument parser for Point */
  51. PyObject *PyMac_BuildPoint(Point); /* Convert Point to PyObject */
  52. int PyMac_GetEventRecord(PyObject *, EventRecord *); /* argument parser for
  53. EventRecord */
  54. PyObject *PyMac_BuildEventRecord(EventRecord *); /* Convert EventRecord to
  55. PyObject */
  56. int PyMac_GetFixed(PyObject *, Fixed *); /* argument parser for Fixed */
  57. PyObject *PyMac_BuildFixed(Fixed); /* Convert Fixed to PyObject */
  58. int PyMac_Getwide(PyObject *, wide *); /* argument parser for wide */
  59. PyObject *PyMac_Buildwide(wide *); /* Convert wide to PyObject */
  60. /*
  61. ** The rest of the routines are implemented by extension modules. If they are
  62. ** dynamically loaded mactoolboxglue will contain a stub implementation of the
  63. ** routine, which imports the module, whereupon the module's init routine will
  64. ** communicate the routine pointer back to the stub.
  65. ** If USE_TOOLBOX_OBJECT_GLUE is not defined there is no glue code, and the
  66. ** extension modules simply declare the routine. This is the case for static
  67. ** builds (and could be the case for MacPython CFM builds, because CFM extension
  68. ** modules can reference each other without problems).
  69. */
  70. #ifdef USE_TOOLBOX_OBJECT_GLUE
  71. /*
  72. ** These macros are used in the module init code. If we use toolbox object glue
  73. ** it sets the function pointer to point to the real function.
  74. */
  75. #define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) { \
  76. extern PyObject *(*PyMacGluePtr_##rtn)(object); \
  77. PyMacGluePtr_##rtn = _##rtn; \
  78. }
  79. #define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) { \
  80. extern int (*PyMacGluePtr_##rtn)(PyObject *, object *); \
  81. PyMacGluePtr_##rtn = _##rtn; \
  82. }
  83. #else
  84. /*
  85. ** If we don't use toolbox object glue the init macros are empty. Moreover, we define
  86. ** _xxx_New to be the same as xxx_New, and the code in mactoolboxglue isn't included.
  87. */
  88. #define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn)
  89. #define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn)
  90. #endif /* USE_TOOLBOX_OBJECT_GLUE */
  91. /* macfs exports */
  92. #ifndef __LP64__
  93. int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */
  94. PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */
  95. #endif /* !__LP64__ */
  96. int PyMac_GetFSRef(PyObject *, FSRef *); /* argument parser for FSRef */
  97. PyObject *PyMac_BuildFSRef(FSRef *); /* Convert FSRef to PyObject */
  98. /* AE exports */
  99. extern PyObject *AEDesc_New(AppleEvent *); /* XXXX Why passed by address?? */
  100. extern PyObject *AEDesc_NewBorrowed(AppleEvent *);
  101. extern int AEDesc_Convert(PyObject *, AppleEvent *);
  102. /* Cm exports */
  103. extern PyObject *CmpObj_New(Component);
  104. extern int CmpObj_Convert(PyObject *, Component *);
  105. extern PyObject *CmpInstObj_New(ComponentInstance);
  106. extern int CmpInstObj_Convert(PyObject *, ComponentInstance *);
  107. /* Ctl exports */
  108. #if APPLE_SUPPORTS_QUICKTIME
  109. extern PyObject *CtlObj_New(ControlHandle);
  110. extern int CtlObj_Convert(PyObject *, ControlHandle *);
  111. #endif /* APPLE_SUPPORTS_QUICKTIME */
  112. /* Dlg exports */
  113. #if APPLE_SUPPORTS_QUICKTIME
  114. extern PyObject *DlgObj_New(DialogPtr);
  115. extern int DlgObj_Convert(PyObject *, DialogPtr *);
  116. extern PyObject *DlgObj_WhichDialog(DialogPtr);
  117. #endif /* APPLE_SUPPORTS_QUICKTIME */
  118. /* Drag exports */
  119. #if APPLE_SUPPORTS_QUICKTIME
  120. extern PyObject *DragObj_New(DragReference);
  121. extern int DragObj_Convert(PyObject *, DragReference *);
  122. #endif /* APPLE_SUPPORTS_QUICKTIME */
  123. /* List exports */
  124. #if APPLE_SUPPORTS_QUICKTIME
  125. extern PyObject *ListObj_New(ListHandle);
  126. extern int ListObj_Convert(PyObject *, ListHandle *);
  127. #endif /* APPLE_SUPPORTS_QUICKTIME */
  128. /* Menu exports */
  129. #if APPLE_SUPPORTS_QUICKTIME
  130. extern PyObject *MenuObj_New(MenuHandle);
  131. extern int MenuObj_Convert(PyObject *, MenuHandle *);
  132. #endif /* APPLE_SUPPORTS_QUICKTIME */
  133. /* Qd exports */
  134. #if APPLE_SUPPORTS_QUICKTIME
  135. extern PyObject *GrafObj_New(GrafPtr);
  136. extern int GrafObj_Convert(PyObject *, GrafPtr *);
  137. extern PyObject *BMObj_New(BitMapPtr);
  138. extern int BMObj_Convert(PyObject *, BitMapPtr *);
  139. extern PyObject *QdRGB_New(RGBColor *);
  140. extern int QdRGB_Convert(PyObject *, RGBColor *);
  141. #endif /* APPLE_SUPPORTS_QUICKTIME */
  142. /* Qdoffs exports */
  143. #if APPLE_SUPPORTS_QUICKTIME
  144. extern PyObject *GWorldObj_New(GWorldPtr);
  145. extern int GWorldObj_Convert(PyObject *, GWorldPtr *);
  146. #endif /* APPLE_SUPPORTS_QUICKTIME */
  147. /* Qt exports */
  148. #if APPLE_SUPPORTS_QUICKTIME
  149. extern PyObject *TrackObj_New(Track);
  150. extern int TrackObj_Convert(PyObject *, Track *);
  151. extern PyObject *MovieObj_New(Movie);
  152. extern int MovieObj_Convert(PyObject *, Movie *);
  153. extern PyObject *MovieCtlObj_New(MovieController);
  154. extern int MovieCtlObj_Convert(PyObject *, MovieController *);
  155. extern PyObject *TimeBaseObj_New(TimeBase);
  156. extern int TimeBaseObj_Convert(PyObject *, TimeBase *);
  157. extern PyObject *UserDataObj_New(UserData);
  158. extern int UserDataObj_Convert(PyObject *, UserData *);
  159. extern PyObject *MediaObj_New(Media);
  160. extern int MediaObj_Convert(PyObject *, Media *);
  161. #endif /* APPLE_SUPPORTS_QUICKTIME */
  162. /* Res exports */
  163. extern PyObject *ResObj_New(Handle);
  164. extern int ResObj_Convert(PyObject *, Handle *);
  165. extern PyObject *OptResObj_New(Handle);
  166. extern int OptResObj_Convert(PyObject *, Handle *);
  167. /* TE exports */
  168. #if APPLE_SUPPORTS_QUICKTIME
  169. extern PyObject *TEObj_New(TEHandle);
  170. extern int TEObj_Convert(PyObject *, TEHandle *);
  171. #endif /* APPLE_SUPPORTS_QUICKTIME */
  172. /* Win exports */
  173. #if APPLE_SUPPORTS_QUICKTIME
  174. extern PyObject *WinObj_New(WindowPtr);
  175. extern int WinObj_Convert(PyObject *, WindowPtr *);
  176. extern PyObject *WinObj_WhichWindow(WindowPtr);
  177. #endif /* APPLE_SUPPORTS_QUICKTIME */
  178. /* CF exports */
  179. extern PyObject *CFObj_New(CFTypeRef);
  180. extern int CFObj_Convert(PyObject *, CFTypeRef *);
  181. extern PyObject *CFTypeRefObj_New(CFTypeRef);
  182. extern int CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
  183. extern PyObject *CFStringRefObj_New(CFStringRef);
  184. extern int CFStringRefObj_Convert(PyObject *, CFStringRef *);
  185. extern PyObject *CFMutableStringRefObj_New(CFMutableStringRef);
  186. extern int CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *);
  187. extern PyObject *CFArrayRefObj_New(CFArrayRef);
  188. extern int CFArrayRefObj_Convert(PyObject *, CFArrayRef *);
  189. extern PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef);
  190. extern int CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *);
  191. extern PyObject *CFDictionaryRefObj_New(CFDictionaryRef);
  192. extern int CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *);
  193. extern PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef);
  194. extern int CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *);
  195. extern PyObject *CFURLRefObj_New(CFURLRef);
  196. extern int CFURLRefObj_Convert(PyObject *, CFURLRef *);
  197. extern int OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *);
  198. #ifdef __cplusplus
  199. }
  200. #endif
  201. #endif