blob: 5313d91282bf6945dc4666dadd395b28d892c8d7 [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*/
4
5#ifdef __cplusplus
6 extern "C" {
7#endif
8
Jack Jansen9f66b4a2001-05-19 12:32:39 +00009#ifdef WITHOUT_FRAMEWORKS
Jack Jansen9d8b96c2000-07-14 22:16:45 +000010#include <Memory.h>
11#include <Dialogs.h>
12#include <Menus.h>
13#include <Controls.h>
14#include <Components.h>
15#include <Lists.h>
16#include <Movies.h>
17#include <Errors.h>
Jack Jansen537a69f2001-11-05 14:39:22 +000018#include <CFBase.h>
19#include <CFArray.h>
20#include <CFData.h>
21#include <CFDictionary.h>
22#include <CFString.h>
23#include <CFURL.h>
Jack Jansen9f66b4a2001-05-19 12:32:39 +000024#else
25#include <Carbon/Carbon.h>
26#include <QuickTime/QuickTime.h>
27#endif
Jack Jansen9d8b96c2000-07-14 22:16:45 +000028
Jack Jansen94bebc02001-08-08 13:17:31 +000029/*
30** Helper routines for error codes and such.
31*/
32char *PyMac_getscript(void); /* Get the default encoding for our 8bit character set */
33char *PyMac_StrError(int); /* strerror with mac errors */
34PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */
35PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */
Jack Jansen7b049462001-09-10 22:09:30 +000036extern OSErr PyMac_GetFullPathname(FSSpec *, char *, int); /* convert fsspec->path */
Jack Jansen94bebc02001-08-08 13:17:31 +000037
38/*
39** These conversion routines are defined in mactoolboxglue.c itself.
40*/
41int PyMac_GetOSType(PyObject *, OSType *); /* argument parser for OSType */
42PyObject *PyMac_BuildOSType(OSType); /* Convert OSType to PyObject */
43
44PyObject *PyMac_BuildNumVersion(NumVersion);/* Convert NumVersion to PyObject */
45
46int PyMac_GetStr255(PyObject *, Str255); /* argument parser for Str255 */
47PyObject *PyMac_BuildStr255(Str255); /* Convert Str255 to PyObject */
48PyObject *PyMac_BuildOptStr255(Str255); /* Convert Str255 to PyObject, NULL to None */
49
50int PyMac_GetRect(PyObject *, Rect *); /* argument parser for Rect */
51PyObject *PyMac_BuildRect(Rect *); /* Convert Rect to PyObject */
52
53int PyMac_GetPoint(PyObject *, Point *); /* argument parser for Point */
54PyObject *PyMac_BuildPoint(Point); /* Convert Point to PyObject */
55
56int PyMac_GetEventRecord(PyObject *, EventRecord *); /* argument parser for EventRecord */
57PyObject *PyMac_BuildEventRecord(EventRecord *); /* Convert EventRecord to PyObject */
58
59int PyMac_GetFixed(PyObject *, Fixed *); /* argument parser for Fixed */
60PyObject *PyMac_BuildFixed(Fixed); /* Convert Fixed to PyObject */
61int PyMac_Getwide(PyObject *, wide *); /* argument parser for wide */
62PyObject *PyMac_Buildwide(wide *); /* Convert wide to PyObject */
63
64/*
65** The rest of the routines are implemented by extension modules. If they are
66** dynamically loaded mactoolboxglue will contain a stub implementation of the
67** routine, which imports the module, whereupon the module's init routine will
68** communicate the routine pointer back to the stub.
69** If USE_TOOLBOX_OBJECT_GLUE is not defined there is no glue code, and the
70** extension modules simply declare the routine. This is the case for static
71** builds (and could be the case for MacPython CFM builds, because CFM extension
72** modules can reference each other without problems).
73*/
74
Jack Jansenf57a4a22001-05-17 22:11:44 +000075#ifdef USE_TOOLBOX_OBJECT_GLUE
76/*
77** These macros are used in the module init code. If we use toolbox object glue
78** it sets the function pointer to point to the real function.
79*/
Jack Jansen0268ac82001-05-22 22:34:56 +000080#define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) { \
Jack Jansenf57a4a22001-05-17 22:11:44 +000081 extern PyObject *(*PyMacGluePtr_##rtn)(object); \
82 PyMacGluePtr_##rtn = _##rtn; \
83}
Jack Jansen0268ac82001-05-22 22:34:56 +000084#define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) { \
85 extern int (*PyMacGluePtr_##rtn)(PyObject *, object *); \
Jack Jansenf57a4a22001-05-17 22:11:44 +000086 PyMacGluePtr_##rtn = _##rtn; \
87}
88#else
89/*
90** If we don't use toolbox object glue the init macros are empty. Moreover, we define
91** _xxx_New to be the same as xxx_New, and the code in mactoolboxglue isn't included.
92*/
Jack Jansen0268ac82001-05-22 22:34:56 +000093#define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn)
94#define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn)
Jack Jansenf57a4a22001-05-17 22:11:44 +000095#endif /* USE_TOOLBOX_OBJECT_GLUE */
96
Jack Jansena5bca572001-08-03 15:39:27 +000097/* macfs exports */
Jack Jansenfabd00f2001-09-01 23:39:58 +000098int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */
99PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */
100
101int PyMac_GetFSRef(PyObject *, FSRef *); /* argument parser for FSRef */
102PyObject *PyMac_BuildFSRef(FSRef *); /* Convert FSRef to PyObject */
Jack Jansena5bca572001-08-03 15:39:27 +0000103
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000104/* AE exports */
105extern PyObject *AEDesc_New(AppleEvent *); /* XXXX Why passed by address?? */
106extern int AEDesc_Convert(PyObject *, AppleEvent *);
107
108/* Cm exports */
109extern PyObject *CmpObj_New(Component);
110extern int CmpObj_Convert(PyObject *, Component *);
111extern PyObject *CmpInstObj_New(ComponentInstance);
112extern int CmpInstObj_Convert(PyObject *, ComponentInstance *);
113
114/* Ctl exports */
115extern PyObject *CtlObj_New(ControlHandle);
116extern int CtlObj_Convert(PyObject *, ControlHandle *);
117
118/* Dlg exports */
119extern PyObject *DlgObj_New(DialogPtr);
120extern int DlgObj_Convert(PyObject *, DialogPtr *);
Jack Jansenadd58f92001-02-09 15:59:18 +0000121extern PyObject *DlgObj_WhichDialog(DialogPtr);
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000122
123/* Drag exports */
124extern PyObject *DragObj_New(DragReference);
125extern int DragObj_Convert(PyObject *, DragReference *);
126
127/* List exports */
128extern PyObject *ListObj_New(ListHandle);
129extern int ListObj_Convert(PyObject *, ListHandle *);
130
131/* Menu exports */
132extern PyObject *MenuObj_New(MenuHandle);
133extern int MenuObj_Convert(PyObject *, MenuHandle *);
134
135/* Qd exports */
136extern PyObject *GrafObj_New(GrafPtr);
137extern int GrafObj_Convert(PyObject *, GrafPtr *);
138extern PyObject *BMObj_New(BitMapPtr);
139extern int BMObj_Convert(PyObject *, BitMapPtr *);
140extern PyObject *QdRGB_New(RGBColor *);
141extern int QdRGB_Convert(PyObject *, RGBColor *);
142
Jack Jansen50bf1482000-12-12 22:13:03 +0000143/* Qdoffs exports */
144extern PyObject *GWorldObj_New(GWorldPtr);
145extern int GWorldObj_Convert(PyObject *, GWorldPtr *);
146
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000147/* Qt exports */
148extern PyObject *TrackObj_New(Track);
149extern int TrackObj_Convert(PyObject *, Track *);
150extern PyObject *MovieObj_New(Movie);
151extern int MovieObj_Convert(PyObject *, Movie *);
152extern PyObject *MovieCtlObj_New(MovieController);
Jack Jansenf57a4a22001-05-17 22:11:44 +0000153extern int MovieCtlObj_Convert(PyObject *, MovieController *);
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000154extern PyObject *TimeBaseObj_New(TimeBase);
155extern int TimeBaseObj_Convert(PyObject *, TimeBase *);
156extern PyObject *UserDataObj_New(UserData);
157extern int UserDataObj_Convert(PyObject *, UserData *);
158extern PyObject *MediaObj_New(Media);
159extern int MediaObj_Convert(PyObject *, Media *);
160
161/* Res exports */
162extern PyObject *ResObj_New(Handle);
163extern int ResObj_Convert(PyObject *, Handle *);
164extern PyObject *OptResObj_New(Handle);
165extern int OptResObj_Convert(PyObject *, Handle *);
166
167/* TE exports */
168extern PyObject *TEObj_New(TEHandle);
169extern int TEObj_Convert(PyObject *, TEHandle *);
170
171/* Win exports */
172extern PyObject *WinObj_New(WindowPtr);
173extern int WinObj_Convert(PyObject *, WindowPtr *);
174extern PyObject *WinObj_WhichWindow(WindowPtr);
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000175
Jack Jansen537a69f2001-11-05 14:39:22 +0000176/* CF exports */
177extern PyObject *CFTypeRefObj_New(CFTypeRef);
178extern int CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
179extern PyObject *CFStringRefObj_New(CFStringRef);
180extern int CFStringRefObj_Convert(PyObject *, CFStringRef *);
181extern PyObject *CFMutableStringRefObj_New(CFMutableStringRef);
182extern int CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *);
183extern PyObject *CFArrayRefObj_New(CFArrayRef);
184extern int CFArrayRefObj_Convert(PyObject *, CFArrayRef *);
185extern PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef);
186extern int CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *);
187extern PyObject *CFDictionaryRefObj_New(CFDictionaryRef);
188extern int CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *);
189extern PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef);
190extern int CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *);
191extern PyObject *CFURLRefObj_New(CFURLRef);
192extern int CFURLRefObj_Convert(PyObject *, CFURLRef *);
193extern int OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *);
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000194
195#ifdef __cplusplus
196 }
197#endif