Guido van Rossum | b340466 | 1995-01-22 18:36:13 +0000 | [diff] [blame] | 1 | /*********************************************************** |
Jack Jansen | 42218ce | 1997-01-31 16:15:11 +0000 | [diff] [blame] | 2 | Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, |
Guido van Rossum | b340466 | 1995-01-22 18:36:13 +0000 | [diff] [blame] | 3 | The Netherlands. |
| 4 | |
| 5 | All Rights Reserved |
| 6 | |
| 7 | Permission to use, copy, modify, and distribute this software and its |
| 8 | documentation for any purpose and without fee is hereby granted, |
| 9 | provided that the above copyright notice appear in all copies and that |
| 10 | both that copyright notice and this permission notice appear in |
| 11 | supporting documentation, and that the names of Stichting Mathematisch |
| 12 | Centrum or CWI not be used in advertising or publicity pertaining to |
| 13 | distribution of the software without specific, written prior permission. |
| 14 | |
| 15 | STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
| 16 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 17 | FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
| 18 | FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 20 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 21 | OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 22 | |
| 23 | ******************************************************************/ |
Jack Jansen | 47ec141 | 2002-09-10 12:32:47 +0000 | [diff] [blame] | 24 | #ifndef Py_MACGLUE_H |
| 25 | #define Py_MACGLUE_H |
Jack Jansen | 0194ad5 | 2001-05-12 22:46:35 +0000 | [diff] [blame] | 26 | #ifdef WITHOUT_FRAMEWORKS |
Jack Jansen | 5f65309 | 1995-01-18 13:53:49 +0000 | [diff] [blame] | 27 | #include <Types.h> |
Guido van Rossum | b340466 | 1995-01-22 18:36:13 +0000 | [diff] [blame] | 28 | #include <Files.h> |
Guido van Rossum | cf27c2d | 1995-01-25 23:06:44 +0000 | [diff] [blame] | 29 | #include <Events.h> |
Jack Jansen | 32486f5 | 1995-08-14 12:36:37 +0000 | [diff] [blame] | 30 | #include <StandardFile.h> |
Jack Jansen | 0194ad5 | 2001-05-12 22:46:35 +0000 | [diff] [blame] | 31 | #else |
| 32 | #include <Carbon/Carbon.h> |
| 33 | #endif |
Jack Jansen | 5f65309 | 1995-01-18 13:53:49 +0000 | [diff] [blame] | 34 | |
Jack Jansen | 94bebc0 | 2001-08-08 13:17:31 +0000 | [diff] [blame] | 35 | #include "pymactoolbox.h" |
| 36 | |
Jack Jansen | c7fda7e | 1999-09-30 11:14:49 +0000 | [diff] [blame] | 37 | #ifdef __cplusplus |
| 38 | extern "C" { |
| 39 | #endif |
| 40 | |
Jack Jansen | 4a79a4b | 1997-06-03 15:27:31 +0000 | [diff] [blame] | 41 | /* Scheduler parameters */ |
| 42 | typedef 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 Jansen | f22e67d | 1998-07-13 13:39:34 +0000 | [diff] [blame] | 50 | unsigned char *Pstring(char *str); /* Convert c-string to pascal-string in static buffer */ |
Guido van Rossum | f71a9a9 | 1995-02-18 14:59:48 +0000 | [diff] [blame] | 51 | |
Jack Jansen | f6865f7 | 1996-09-04 15:24:59 +0000 | [diff] [blame] | 52 | #ifdef USE_GUSI |
| 53 | extern int PyMac_ConsoleIsDead; /* True when exiting */ |
Jack Jansen | 570e4b7 | 1997-05-23 15:33:20 +0000 | [diff] [blame] | 54 | extern void PyMac_StopGUSISpin(void); /* Stop eventprocessing during exit() */ |
Jack Jansen | f6865f7 | 1996-09-04 15:24:59 +0000 | [diff] [blame] | 55 | #endif |
Jack Jansen | ee23d6e | 1995-01-27 14:43:25 +0000 | [diff] [blame] | 56 | |
Jack Jansen | 3d22887 | 1996-09-06 22:18:40 +0000 | [diff] [blame] | 57 | extern short PyMac_AppRefNum; /* RefNum of application rsrcfork (from macmain.c) */ |
Jack Jansen | 570e4b7 | 1997-05-23 15:33:20 +0000 | [diff] [blame] | 58 | extern FSSpec PyMac_ApplicationFSSpec; /* Application location (from macargv.c) */ |
| 59 | extern char PyMac_ApplicationPath[]; /* Application location (from macargv.c) */ |
Jack Jansen | d88296d | 2000-07-11 19:51:05 +0000 | [diff] [blame] | 60 | extern OSErr PyMac_init_application_location(void); /* Init the above */ |
Jack Jansen | d88296d | 2000-07-11 19:51:05 +0000 | [diff] [blame] | 61 | extern int PyMac_GetArgv(char ***, int); /* Get argc, argv (from macargv.c) */ |
Jack Jansen | 3d22887 | 1996-09-06 22:18:40 +0000 | [diff] [blame] | 62 | |
Guido van Rossum | cf27c2d | 1995-01-25 23:06:44 +0000 | [diff] [blame] | 63 | extern PyObject *PyMac_OSErrException; /* Exception for OSErr */ |
| 64 | PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */ |
Guido van Rossum | b340466 | 1995-01-22 18:36:13 +0000 | [diff] [blame] | 65 | |
Jack Jansen | 0194ad5 | 2001-05-12 22:46:35 +0000 | [diff] [blame] | 66 | #if !TARGET_API_MAC_OSX |
Jack Jansen | d88296d | 2000-07-11 19:51:05 +0000 | [diff] [blame] | 67 | void PyMac_GetSchedParams(PyMacSchedParams *); /* Get schedulers params */ |
| 68 | void PyMac_SetSchedParams(PyMacSchedParams *); /* Set schedulers params */ |
Jack Jansen | d88296d | 2000-07-11 19:51:05 +0000 | [diff] [blame] | 69 | int PyMac_DoYield(int, int); /* Yield cpu. First arg is maxtime, second ok to call python */ |
Jack Jansen | 0194ad5 | 2001-05-12 22:46:35 +0000 | [diff] [blame] | 70 | #endif |
Jack Jansen | d88296d | 2000-07-11 19:51:05 +0000 | [diff] [blame] | 71 | int PyMac_HandleEvent(EventRecord *); /* Handle one event, possibly in Python */ |
| 72 | void PyMac_HandleEventIntern(EventRecord *); /* Handle one event internal only */ |
| 73 | int PyMac_SetEventHandler(PyObject *); /* set python-coded event handler */ |
Guido van Rossum | b340466 | 1995-01-22 18:36:13 +0000 | [diff] [blame] | 74 | |
Jack Jansen | 0194ad5 | 2001-05-12 22:46:35 +0000 | [diff] [blame] | 75 | #if !TARGET_API_MAC_OSX |
Jack Jansen | 3469e99 | 1996-09-06 00:30:45 +0000 | [diff] [blame] | 76 | void PyMac_InitMenuBar(void); /* Setup menu bar as we want it */ |
Jack Jansen | 0130f0f | 1997-06-12 10:51:39 +0000 | [diff] [blame] | 77 | void PyMac_RestoreMenuBar(void); /* Restore menu bar for ease of exiting */ |
Jack Jansen | b4b27be | 2001-04-25 22:07:42 +0000 | [diff] [blame] | 78 | void PyMac_RaiseConsoleWindow(); /* Bring console window to front, if it exists */ |
Jack Jansen | 0194ad5 | 2001-05-12 22:46:35 +0000 | [diff] [blame] | 79 | #endif |
Jack Jansen | eda7863 | 1997-06-12 15:29:46 +0000 | [diff] [blame] | 80 | int PyMac_FindResourceModule(PyStringObject *, char *, char *); /* Test for 'PYC ' resource in a file */ |
Jack Jansen | 74162f3 | 1995-02-15 22:58:33 +0000 | [diff] [blame] | 81 | PyObject * PyMac_LoadResourceModule(char *, char *); /* Load 'PYC ' resource from file */ |
Jack Jansen | f22e67d | 1998-07-13 13:39:34 +0000 | [diff] [blame] | 82 | int PyMac_FindCodeResourceModule(PyStringObject *, char *, char *); /* Test for 'PYD ' resource in a file */ |
| 83 | PyObject * PyMac_LoadCodeResourceModule(char *, char *); /* Load 'PYD ' resource from file */ |
Jack Jansen | fe38d29 | 2000-07-03 23:53:40 +0000 | [diff] [blame] | 84 | struct filedescr *PyMac_FindModuleExtension(char *, size_t *, char *); /* Look for module in single folder */ |
Jack Jansen | 74162f3 | 1995-02-15 22:58:33 +0000 | [diff] [blame] | 85 | |
Jack Jansen | 6e68a7e | 2001-05-12 21:31:34 +0000 | [diff] [blame] | 86 | #if TARGET_API_MAC_OS8 |
Jack Jansen | 32486f5 | 1995-08-14 12:36:37 +0000 | [diff] [blame] | 87 | int PyMac_GetDirectory(FSSpec *dirfss, char *prompt); /* Ask user for a directory */ |
| 88 | void PyMac_PromptGetFile(short numTypes, ConstSFTypeListPtr typeList, |
| 89 | StandardFileReply *reply, char *prompt); /* Ask user for file, with prompt */ |
Jack Jansen | 6e68a7e | 2001-05-12 21:31:34 +0000 | [diff] [blame] | 90 | #endif /* TARGET_API_MAC_OS8 */ |
Jack Jansen | 3ec804a | 1995-02-20 15:56:10 +0000 | [diff] [blame] | 91 | |
Guido van Rossum | f71a9a9 | 1995-02-18 14:59:48 +0000 | [diff] [blame] | 92 | void PyMac_InitApplet(void); /* Initialize and run an Applet */ |
Jack Jansen | 52ac037 | 1997-01-15 15:49:08 +0000 | [diff] [blame] | 93 | void PyMac_Initialize(void); /* Initialize function for embedding Python */ |
Jack Jansen | c84cb95 | 1998-04-15 14:12:45 +0000 | [diff] [blame] | 94 | |
Jack Jansen | ee08104 | 2000-04-21 23:53:37 +0000 | [diff] [blame] | 95 | #ifdef USE_GUSI2 |
| 96 | short PyMac_OpenPrefFile(void); /* From macgetpath.c, open and return preference file */ |
| 97 | #endif |
| 98 | |
Jack Jansen | 4e566ab | 2001-07-08 22:07:23 +0000 | [diff] [blame] | 99 | |
Jack Jansen | c84cb95 | 1998-04-15 14:12:45 +0000 | [diff] [blame] | 100 | /* From macfiletype.c: */ |
| 101 | |
Jack Jansen | 9ae898b | 2000-07-11 21:16:03 +0000 | [diff] [blame] | 102 | long PyMac_getfiletype(char *); /* Get file type */ |
| 103 | int PyMac_setfiletype(char *, long, long); /* Set file creator and type */ |
| 104 | |
| 105 | /* from macmain.c: */ |
| 106 | void PyMac_Exit(int); |
| 107 | void PyMac_InitApplication(void); |
Jack Jansen | 8413b47 | 2000-10-19 22:02:16 +0000 | [diff] [blame] | 108 | void PyMac_OutputSeen(void); |
Jack Jansen | 8a38714 | 2001-02-11 01:08:04 +0000 | [diff] [blame] | 109 | void PyMac_OutputNotSeen(void); |
| 110 | int PyMac_GetDelayConsoleFlag(void); |
Jack Jansen | 9ae898b | 2000-07-11 21:16:03 +0000 | [diff] [blame] | 111 | #ifdef USE_MAC_APPLET_SUPPORT |
| 112 | void PyMac_InitApplet(void); |
| 113 | #endif |
| 114 | |
| 115 | /* from macgetargv: */ |
| 116 | OSErr PyMac_init_process_location(void); |
Jack Jansen | 9ae898b | 2000-07-11 21:16:03 +0000 | [diff] [blame] | 117 | char * strdup(const char *str); |
Jack Jansen | 9ae898b | 2000-07-11 21:16:03 +0000 | [diff] [blame] | 118 | |
Jack Jansen | b58f1c0 | 2001-10-08 13:16:39 +0000 | [diff] [blame] | 119 | #ifdef USE_GUSI2 |
| 120 | /* from pyGUSISIOUX.cp */ |
| 121 | typedef long (*PyWriteHandler)(char *buffer, long n); |
| 122 | typedef 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 | */ |
| 128 | void 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 | */ |
| 134 | long PyMac_DummyReadHandler(char *, long); |
| 135 | long PyMac_DummyWriteHandler(char *, long); |
| 136 | #endif /* USE_GUSI2 */ |
| 137 | |
Jack Jansen | c7fda7e | 1999-09-30 11:14:49 +0000 | [diff] [blame] | 138 | #ifdef __cplusplus |
| 139 | } |
| 140 | #endif |
Jack Jansen | 47ec141 | 2002-09-10 12:32:47 +0000 | [diff] [blame] | 141 | #endif |