blob: eb0c9a1c7e8b935dad78813af3691ae8eff7504d [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******************************************************************/
24
Jack Jansen0194ad52001-05-12 22:46:35 +000025#ifdef WITHOUT_FRAMEWORKS
Jack Jansen5f653091995-01-18 13:53:49 +000026#include <Types.h>
Guido van Rossumb3404661995-01-22 18:36:13 +000027#include <Files.h>
Guido van Rossumcf27c2d1995-01-25 23:06:44 +000028#include <Events.h>
Jack Jansen32486f51995-08-14 12:36:37 +000029#include <StandardFile.h>
Jack Jansen0194ad52001-05-12 22:46:35 +000030#else
31#include <Carbon/Carbon.h>
32#endif
Jack Jansen5f653091995-01-18 13:53:49 +000033
Jack Jansen94bebc02001-08-08 13:17:31 +000034#include "pymactoolbox.h"
35
Jack Jansenc7fda7e1999-09-30 11:14:49 +000036#ifdef __cplusplus
37 extern "C" {
38#endif
39
Jack Jansen4a79a4b1997-06-03 15:27:31 +000040/* Scheduler parameters */
41typedef struct {
42 int check_interrupt; /* if true check for command-dot */
43 int process_events; /* if nonzero enable evt processing, this mask */
44 int besocial; /* Be social, give up CPU now and again */
45 double check_interval; /* how often to check */
46 double bg_yield; /* yield at most so long when in background */
47} PyMacSchedParams;
48
Jack Jansen2d1306b2000-04-07 09:10:49 +000049#ifdef USE_GUSI1
Jack Jansend88296d2000-07-11 19:51:05 +000050void PyMac_FixGUSIcd(void); /* Workaround for GUSI chdir() call */
Jack Jansen2d1306b2000-04-07 09:10:49 +000051extern void PyMac_SetGUSISpin(void); /* Install our private GUSI spin routine */
Jack Jansen378815c1996-03-06 16:21:34 +000052#endif
53
Jack Jansenf22e67d1998-07-13 13:39:34 +000054unsigned char *Pstring(char *str); /* Convert c-string to pascal-string in static buffer */
Guido van Rossumf71a9a91995-02-18 14:59:48 +000055
Jack Jansenf6865f71996-09-04 15:24:59 +000056#ifdef USE_GUSI
57extern int PyMac_ConsoleIsDead; /* True when exiting */
Jack Jansen570e4b71997-05-23 15:33:20 +000058extern void PyMac_StopGUSISpin(void); /* Stop eventprocessing during exit() */
Jack Jansenf6865f71996-09-04 15:24:59 +000059#endif
Jack Jansenee23d6e1995-01-27 14:43:25 +000060
Jack Jansen3d228871996-09-06 22:18:40 +000061extern short PyMac_AppRefNum; /* RefNum of application rsrcfork (from macmain.c) */
Jack Jansen570e4b71997-05-23 15:33:20 +000062extern FSSpec PyMac_ApplicationFSSpec; /* Application location (from macargv.c) */
63extern char PyMac_ApplicationPath[]; /* Application location (from macargv.c) */
Jack Jansend88296d2000-07-11 19:51:05 +000064extern OSErr PyMac_init_application_location(void); /* Init the above */
Jack Jansend88296d2000-07-11 19:51:05 +000065extern int PyMac_GetArgv(char ***, int); /* Get argc, argv (from macargv.c) */
Jack Jansen8f5725a1999-12-07 23:08:10 +000066extern int PyMac_AppearanceCompliant; /* True if in appearance support mode */
Jack Jansen3d228871996-09-06 22:18:40 +000067
Guido van Rossumcf27c2d1995-01-25 23:06:44 +000068extern PyObject *PyMac_OSErrException; /* Exception for OSErr */
69PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */
Guido van Rossumb3404661995-01-22 18:36:13 +000070
Jack Jansen0194ad52001-05-12 22:46:35 +000071#if !TARGET_API_MAC_OSX
Jack Jansend88296d2000-07-11 19:51:05 +000072void PyMac_GetSchedParams(PyMacSchedParams *); /* Get schedulers params */
73void PyMac_SetSchedParams(PyMacSchedParams *); /* Set schedulers params */
Jack Jansend88296d2000-07-11 19:51:05 +000074int PyMac_DoYield(int, int); /* Yield cpu. First arg is maxtime, second ok to call python */
Jack Jansen0194ad52001-05-12 22:46:35 +000075#endif
Jack Jansend88296d2000-07-11 19:51:05 +000076int PyMac_HandleEvent(EventRecord *); /* Handle one event, possibly in Python */
77void PyMac_HandleEventIntern(EventRecord *); /* Handle one event internal only */
78int PyMac_SetEventHandler(PyObject *); /* set python-coded event handler */
Guido van Rossumb3404661995-01-22 18:36:13 +000079
Jack Jansen0194ad52001-05-12 22:46:35 +000080#if !TARGET_API_MAC_OSX
Jack Jansen3469e991996-09-06 00:30:45 +000081void PyMac_InitMenuBar(void); /* Setup menu bar as we want it */
Jack Jansen0130f0f1997-06-12 10:51:39 +000082void PyMac_RestoreMenuBar(void); /* Restore menu bar for ease of exiting */
Jack Jansenb4b27be2001-04-25 22:07:42 +000083void PyMac_RaiseConsoleWindow(); /* Bring console window to front, if it exists */
Jack Jansen0194ad52001-05-12 22:46:35 +000084#endif
Jack Janseneda78631997-06-12 15:29:46 +000085int PyMac_FindResourceModule(PyStringObject *, char *, char *); /* Test for 'PYC ' resource in a file */
Jack Jansen74162f31995-02-15 22:58:33 +000086PyObject * PyMac_LoadResourceModule(char *, char *); /* Load 'PYC ' resource from file */
Jack Jansenf22e67d1998-07-13 13:39:34 +000087int PyMac_FindCodeResourceModule(PyStringObject *, char *, char *); /* Test for 'PYD ' resource in a file */
88PyObject * PyMac_LoadCodeResourceModule(char *, char *); /* Load 'PYD ' resource from file */
Jack Jansenfe38d292000-07-03 23:53:40 +000089struct filedescr *PyMac_FindModuleExtension(char *, size_t *, char *); /* Look for module in single folder */
Jack Jansen74162f31995-02-15 22:58:33 +000090
Jack Jansen6e68a7e2001-05-12 21:31:34 +000091#if TARGET_API_MAC_OS8
Jack Jansen32486f51995-08-14 12:36:37 +000092int PyMac_GetDirectory(FSSpec *dirfss, char *prompt); /* Ask user for a directory */
93void PyMac_PromptGetFile(short numTypes, ConstSFTypeListPtr typeList,
94 StandardFileReply *reply, char *prompt); /* Ask user for file, with prompt */
Jack Jansen6e68a7e2001-05-12 21:31:34 +000095#endif /* TARGET_API_MAC_OS8 */
Jack Jansen3ec804a1995-02-20 15:56:10 +000096
Guido van Rossumf71a9a91995-02-18 14:59:48 +000097void PyMac_InitApplet(void); /* Initialize and run an Applet */
Jack Jansen52ac0371997-01-15 15:49:08 +000098void PyMac_Initialize(void); /* Initialize function for embedding Python */
Jack Jansenc84cb951998-04-15 14:12:45 +000099
Jack Jansenee081042000-04-21 23:53:37 +0000100#ifdef USE_GUSI2
101short PyMac_OpenPrefFile(void); /* From macgetpath.c, open and return preference file */
102#endif
103
Jack Jansen4e566ab2001-07-08 22:07:23 +0000104
Jack Jansenc84cb951998-04-15 14:12:45 +0000105/* From macfiletype.c: */
106
Jack Jansen9ae898b2000-07-11 21:16:03 +0000107long PyMac_getfiletype(char *); /* Get file type */
108int PyMac_setfiletype(char *, long, long); /* Set file creator and type */
109
110/* from macmain.c: */
111void PyMac_Exit(int);
112void PyMac_InitApplication(void);
Jack Jansen8413b472000-10-19 22:02:16 +0000113void PyMac_OutputSeen(void);
Jack Jansen8a387142001-02-11 01:08:04 +0000114void PyMac_OutputNotSeen(void);
115int PyMac_GetDelayConsoleFlag(void);
Jack Jansen9ae898b2000-07-11 21:16:03 +0000116#ifdef USE_MAC_APPLET_SUPPORT
117void PyMac_InitApplet(void);
118#endif
119
120/* from macgetargv: */
121OSErr PyMac_init_process_location(void);
122#ifndef HAVE_STRDUP
123char * strdup(const char *str);
124#endif
125
Jack Jansenc7fda7e1999-09-30 11:14:49 +0000126#ifdef __cplusplus
127 }
128#endif