blob: 170de35d5863f88b850bdb06836b0a7b395ebc31 [file] [log] [blame]
Guido van Rossumb3404661995-01-22 18:36:13 +00001/***********************************************************
Jack Jansen42218ce1997-01-31 16:15:11 +00002Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam,
Guido van Rossumb3404661995-01-22 18:36:13 +00003The Netherlands.
4
5 All Rights Reserved
6
7Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
9provided that the above copyright notice appear in all copies and that
10both that copyright notice and this permission notice appear in
11supporting documentation, and that the names of Stichting Mathematisch
12Centrum or CWI not be used in advertising or publicity pertaining to
13distribution of the software without specific, written prior permission.
14
15STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
16THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
18FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
23******************************************************************/
Jack Jansen47ec1412002-09-10 12:32:47 +000024#ifndef Py_MACGLUE_H
25#define Py_MACGLUE_H
Jack Jansen0194ad52001-05-12 22:46:35 +000026#ifdef WITHOUT_FRAMEWORKS
Jack Jansen5f653091995-01-18 13:53:49 +000027#include <Types.h>
Guido van Rossumb3404661995-01-22 18:36:13 +000028#include <Files.h>
Guido van Rossumcf27c2d1995-01-25 23:06:44 +000029#include <Events.h>
Jack Jansen32486f51995-08-14 12:36:37 +000030#include <StandardFile.h>
Jack Jansen0194ad52001-05-12 22:46:35 +000031#else
32#include <Carbon/Carbon.h>
33#endif
Jack Jansen5f653091995-01-18 13:53:49 +000034
Jack Jansen94bebc02001-08-08 13:17:31 +000035#include "pymactoolbox.h"
36
Jack Jansenc7fda7e1999-09-30 11:14:49 +000037#ifdef __cplusplus
38 extern "C" {
39#endif
40
Jack Jansen4a79a4b1997-06-03 15:27:31 +000041/* Scheduler parameters */
42typedef struct {
43 int check_interrupt; /* if true check for command-dot */
44 int process_events; /* if nonzero enable evt processing, this mask */
45 int besocial; /* Be social, give up CPU now and again */
46 double check_interval; /* how often to check */
47 double bg_yield; /* yield at most so long when in background */
48} PyMacSchedParams;
49
Jack Jansenf22e67d1998-07-13 13:39:34 +000050unsigned char *Pstring(char *str); /* Convert c-string to pascal-string in static buffer */
Guido van Rossumf71a9a91995-02-18 14:59:48 +000051
Jack Jansenf6865f71996-09-04 15:24:59 +000052#ifdef USE_GUSI
53extern int PyMac_ConsoleIsDead; /* True when exiting */
Jack Jansen570e4b71997-05-23 15:33:20 +000054extern void PyMac_StopGUSISpin(void); /* Stop eventprocessing during exit() */
Jack Jansenf6865f71996-09-04 15:24:59 +000055#endif
Jack Jansenee23d6e1995-01-27 14:43:25 +000056
Jack Jansen3d228871996-09-06 22:18:40 +000057extern short PyMac_AppRefNum; /* RefNum of application rsrcfork (from macmain.c) */
Jack Jansen570e4b71997-05-23 15:33:20 +000058extern FSSpec PyMac_ApplicationFSSpec; /* Application location (from macargv.c) */
59extern char PyMac_ApplicationPath[]; /* Application location (from macargv.c) */
Jack Jansend88296d2000-07-11 19:51:05 +000060extern OSErr PyMac_init_application_location(void); /* Init the above */
Jack Jansend88296d2000-07-11 19:51:05 +000061extern int PyMac_GetArgv(char ***, int); /* Get argc, argv (from macargv.c) */
Jack Jansen3d228871996-09-06 22:18:40 +000062
Guido van Rossumcf27c2d1995-01-25 23:06:44 +000063extern PyObject *PyMac_OSErrException; /* Exception for OSErr */
64PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */
Guido van Rossumb3404661995-01-22 18:36:13 +000065
Jack Jansen0194ad52001-05-12 22:46:35 +000066#if !TARGET_API_MAC_OSX
Jack Jansend88296d2000-07-11 19:51:05 +000067void PyMac_GetSchedParams(PyMacSchedParams *); /* Get schedulers params */
68void PyMac_SetSchedParams(PyMacSchedParams *); /* Set schedulers params */
Jack Jansend88296d2000-07-11 19:51:05 +000069int PyMac_DoYield(int, int); /* Yield cpu. First arg is maxtime, second ok to call python */
Jack Jansen0194ad52001-05-12 22:46:35 +000070#endif
Jack Jansend88296d2000-07-11 19:51:05 +000071int PyMac_HandleEvent(EventRecord *); /* Handle one event, possibly in Python */
72void PyMac_HandleEventIntern(EventRecord *); /* Handle one event internal only */
73int PyMac_SetEventHandler(PyObject *); /* set python-coded event handler */
Guido van Rossumb3404661995-01-22 18:36:13 +000074
Jack Jansen0194ad52001-05-12 22:46:35 +000075#if !TARGET_API_MAC_OSX
Jack Jansen3469e991996-09-06 00:30:45 +000076void PyMac_InitMenuBar(void); /* Setup menu bar as we want it */
Jack Jansen0130f0f1997-06-12 10:51:39 +000077void PyMac_RestoreMenuBar(void); /* Restore menu bar for ease of exiting */
Jack Jansenb4b27be2001-04-25 22:07:42 +000078void PyMac_RaiseConsoleWindow(); /* Bring console window to front, if it exists */
Jack Jansen0194ad52001-05-12 22:46:35 +000079#endif
Jack Janseneda78631997-06-12 15:29:46 +000080int PyMac_FindResourceModule(PyStringObject *, char *, char *); /* Test for 'PYC ' resource in a file */
Jack Jansen74162f31995-02-15 22:58:33 +000081PyObject * PyMac_LoadResourceModule(char *, char *); /* Load 'PYC ' resource from file */
Jack Jansenf22e67d1998-07-13 13:39:34 +000082int PyMac_FindCodeResourceModule(PyStringObject *, char *, char *); /* Test for 'PYD ' resource in a file */
83PyObject * PyMac_LoadCodeResourceModule(char *, char *); /* Load 'PYD ' resource from file */
Jack Jansenfe38d292000-07-03 23:53:40 +000084struct filedescr *PyMac_FindModuleExtension(char *, size_t *, char *); /* Look for module in single folder */
Jack Jansen74162f31995-02-15 22:58:33 +000085
Jack Jansen6e68a7e2001-05-12 21:31:34 +000086#if TARGET_API_MAC_OS8
Jack Jansen32486f51995-08-14 12:36:37 +000087int PyMac_GetDirectory(FSSpec *dirfss, char *prompt); /* Ask user for a directory */
88void PyMac_PromptGetFile(short numTypes, ConstSFTypeListPtr typeList,
89 StandardFileReply *reply, char *prompt); /* Ask user for file, with prompt */
Jack Jansen6e68a7e2001-05-12 21:31:34 +000090#endif /* TARGET_API_MAC_OS8 */
Jack Jansen3ec804a1995-02-20 15:56:10 +000091
Guido van Rossumf71a9a91995-02-18 14:59:48 +000092void PyMac_InitApplet(void); /* Initialize and run an Applet */
Jack Jansen52ac0371997-01-15 15:49:08 +000093void PyMac_Initialize(void); /* Initialize function for embedding Python */
Jack Jansenc84cb951998-04-15 14:12:45 +000094
Jack Jansenee081042000-04-21 23:53:37 +000095#ifdef USE_GUSI2
96short PyMac_OpenPrefFile(void); /* From macgetpath.c, open and return preference file */
97#endif
98
Jack Jansen4e566ab2001-07-08 22:07:23 +000099
Jack Jansenc84cb951998-04-15 14:12:45 +0000100/* From macfiletype.c: */
101
Jack Jansen9ae898b2000-07-11 21:16:03 +0000102long PyMac_getfiletype(char *); /* Get file type */
103int PyMac_setfiletype(char *, long, long); /* Set file creator and type */
104
105/* from macmain.c: */
106void PyMac_Exit(int);
107void PyMac_InitApplication(void);
Jack Jansen8413b472000-10-19 22:02:16 +0000108void PyMac_OutputSeen(void);
Jack Jansen8a387142001-02-11 01:08:04 +0000109void PyMac_OutputNotSeen(void);
110int PyMac_GetDelayConsoleFlag(void);
Jack Jansen9ae898b2000-07-11 21:16:03 +0000111#ifdef USE_MAC_APPLET_SUPPORT
112void PyMac_InitApplet(void);
113#endif
114
115/* from macgetargv: */
116OSErr PyMac_init_process_location(void);
Jack Jansen9ae898b2000-07-11 21:16:03 +0000117char * strdup(const char *str);
Jack Jansen9ae898b2000-07-11 21:16:03 +0000118
Jack Jansenb58f1c02001-10-08 13:16:39 +0000119#ifdef USE_GUSI2
120/* from pyGUSISIOUX.cp */
121typedef long (*PyWriteHandler)(char *buffer, long n);
122typedef long (*PyReadHandler)(char *buffer, long n);
123
124/* Override routines that normally reads and writes to the
125** SIOUX console window. Intended for embedding applications
126** that want to forestall a Python console window ever showing up.
127*/
128void PyMac_SetConsoleHandler(PyReadHandler stdinH, PyWriteHandler stdoutH,
129 PyWriteHandler stderrH);
130
131/* Courtesy console handlers that drop all output and return
132** 0 on reads.
133*/
134long PyMac_DummyReadHandler(char *, long);
135long PyMac_DummyWriteHandler(char *, long);
136#endif /* USE_GUSI2 */
137
Jack Jansenc7fda7e1999-09-30 11:14:49 +0000138#ifdef __cplusplus
139 }
140#endif
Jack Jansen47ec1412002-09-10 12:32:47 +0000141#endif