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 | ******************************************************************/ |
| 24 | |
Jack Jansen | 0194ad5 | 2001-05-12 22:46:35 +0000 | [diff] [blame] | 25 | #ifdef WITHOUT_FRAMEWORKS |
Jack Jansen | 5f65309 | 1995-01-18 13:53:49 +0000 | [diff] [blame] | 26 | #include <Types.h> |
Guido van Rossum | b340466 | 1995-01-22 18:36:13 +0000 | [diff] [blame] | 27 | #include <Files.h> |
Guido van Rossum | cf27c2d | 1995-01-25 23:06:44 +0000 | [diff] [blame] | 28 | #include <Events.h> |
Jack Jansen | 32486f5 | 1995-08-14 12:36:37 +0000 | [diff] [blame] | 29 | #include <StandardFile.h> |
Jack Jansen | 0194ad5 | 2001-05-12 22:46:35 +0000 | [diff] [blame] | 30 | #else |
| 31 | #include <Carbon/Carbon.h> |
| 32 | #endif |
Jack Jansen | 5f65309 | 1995-01-18 13:53:49 +0000 | [diff] [blame] | 33 | |
Jack Jansen | c7fda7e | 1999-09-30 11:14:49 +0000 | [diff] [blame] | 34 | #ifdef __cplusplus |
| 35 | extern "C" { |
| 36 | #endif |
| 37 | |
Jack Jansen | 4a79a4b | 1997-06-03 15:27:31 +0000 | [diff] [blame] | 38 | /* Scheduler parameters */ |
| 39 | typedef struct { |
| 40 | int check_interrupt; /* if true check for command-dot */ |
| 41 | int process_events; /* if nonzero enable evt processing, this mask */ |
| 42 | int besocial; /* Be social, give up CPU now and again */ |
| 43 | double check_interval; /* how often to check */ |
| 44 | double bg_yield; /* yield at most so long when in background */ |
| 45 | } PyMacSchedParams; |
| 46 | |
Jack Jansen | 5bdbabd | 2000-07-24 19:52:52 +0000 | [diff] [blame] | 47 | char *PyMac_getscript(void); /* Get the default encoding for our 8bit character set */ |
Jack Jansen | 2d1306b | 2000-04-07 09:10:49 +0000 | [diff] [blame] | 48 | #ifdef USE_GUSI1 |
Jack Jansen | d88296d | 2000-07-11 19:51:05 +0000 | [diff] [blame] | 49 | void PyMac_FixGUSIcd(void); /* Workaround for GUSI chdir() call */ |
Jack Jansen | 2d1306b | 2000-04-07 09:10:49 +0000 | [diff] [blame] | 50 | extern void PyMac_SetGUSISpin(void); /* Install our private GUSI spin routine */ |
Jack Jansen | 378815c | 1996-03-06 16:21:34 +0000 | [diff] [blame] | 51 | #endif |
| 52 | |
Guido van Rossum | f71a9a9 | 1995-02-18 14:59:48 +0000 | [diff] [blame] | 53 | char *PyMac_StrError(int); /* strerror with mac errors */ |
Jack Jansen | 0194ad5 | 2001-05-12 22:46:35 +0000 | [diff] [blame] | 54 | PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */ |
| 55 | PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */ |
Jack Jansen | f22e67d | 1998-07-13 13:39:34 +0000 | [diff] [blame] | 56 | 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] | 57 | |
Jack Jansen | f6865f7 | 1996-09-04 15:24:59 +0000 | [diff] [blame] | 58 | #ifdef USE_GUSI |
| 59 | extern int PyMac_ConsoleIsDead; /* True when exiting */ |
Jack Jansen | 570e4b7 | 1997-05-23 15:33:20 +0000 | [diff] [blame] | 60 | extern void PyMac_StopGUSISpin(void); /* Stop eventprocessing during exit() */ |
Jack Jansen | f6865f7 | 1996-09-04 15:24:59 +0000 | [diff] [blame] | 61 | #endif |
Jack Jansen | ee23d6e | 1995-01-27 14:43:25 +0000 | [diff] [blame] | 62 | |
Jack Jansen | 3d22887 | 1996-09-06 22:18:40 +0000 | [diff] [blame] | 63 | extern short PyMac_AppRefNum; /* RefNum of application rsrcfork (from macmain.c) */ |
Jack Jansen | 570e4b7 | 1997-05-23 15:33:20 +0000 | [diff] [blame] | 64 | extern FSSpec PyMac_ApplicationFSSpec; /* Application location (from macargv.c) */ |
| 65 | extern char PyMac_ApplicationPath[]; /* Application location (from macargv.c) */ |
Jack Jansen | d88296d | 2000-07-11 19:51:05 +0000 | [diff] [blame] | 66 | extern OSErr PyMac_init_application_location(void); /* Init the above */ |
| 67 | extern OSErr PyMac_GetFullPath(FSSpec *, char *); /* convert fsspec->path (macargv.c) */ |
| 68 | extern int PyMac_GetArgv(char ***, int); /* Get argc, argv (from macargv.c) */ |
Jack Jansen | 8f5725a | 1999-12-07 23:08:10 +0000 | [diff] [blame] | 69 | extern int PyMac_AppearanceCompliant; /* True if in appearance support mode */ |
Jack Jansen | 3d22887 | 1996-09-06 22:18:40 +0000 | [diff] [blame] | 70 | |
Guido van Rossum | cf27c2d | 1995-01-25 23:06:44 +0000 | [diff] [blame] | 71 | extern PyObject *PyMac_OSErrException; /* Exception for OSErr */ |
| 72 | PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */ |
Guido van Rossum | b340466 | 1995-01-22 18:36:13 +0000 | [diff] [blame] | 73 | |
Jack Jansen | 0194ad5 | 2001-05-12 22:46:35 +0000 | [diff] [blame] | 74 | #if !TARGET_API_MAC_OSX |
Jack Jansen | d88296d | 2000-07-11 19:51:05 +0000 | [diff] [blame] | 75 | void PyMac_GetSchedParams(PyMacSchedParams *); /* Get schedulers params */ |
| 76 | void PyMac_SetSchedParams(PyMacSchedParams *); /* Set schedulers params */ |
Jack Jansen | d88296d | 2000-07-11 19:51:05 +0000 | [diff] [blame] | 77 | 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] | 78 | #endif |
Jack Jansen | d88296d | 2000-07-11 19:51:05 +0000 | [diff] [blame] | 79 | int PyMac_HandleEvent(EventRecord *); /* Handle one event, possibly in Python */ |
| 80 | void PyMac_HandleEventIntern(EventRecord *); /* Handle one event internal only */ |
| 81 | int PyMac_SetEventHandler(PyObject *); /* set python-coded event handler */ |
Guido van Rossum | b340466 | 1995-01-22 18:36:13 +0000 | [diff] [blame] | 82 | |
Jack Jansen | 0194ad5 | 2001-05-12 22:46:35 +0000 | [diff] [blame] | 83 | #if !TARGET_API_MAC_OSX |
Jack Jansen | 3469e99 | 1996-09-06 00:30:45 +0000 | [diff] [blame] | 84 | void PyMac_InitMenuBar(void); /* Setup menu bar as we want it */ |
Jack Jansen | 0130f0f | 1997-06-12 10:51:39 +0000 | [diff] [blame] | 85 | void PyMac_RestoreMenuBar(void); /* Restore menu bar for ease of exiting */ |
Jack Jansen | b4b27be | 2001-04-25 22:07:42 +0000 | [diff] [blame] | 86 | void PyMac_RaiseConsoleWindow(); /* Bring console window to front, if it exists */ |
Jack Jansen | 0194ad5 | 2001-05-12 22:46:35 +0000 | [diff] [blame] | 87 | #endif |
Jack Jansen | eda7863 | 1997-06-12 15:29:46 +0000 | [diff] [blame] | 88 | 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] | 89 | PyObject * PyMac_LoadResourceModule(char *, char *); /* Load 'PYC ' resource from file */ |
Jack Jansen | f22e67d | 1998-07-13 13:39:34 +0000 | [diff] [blame] | 90 | int PyMac_FindCodeResourceModule(PyStringObject *, char *, char *); /* Test for 'PYD ' resource in a file */ |
| 91 | PyObject * PyMac_LoadCodeResourceModule(char *, char *); /* Load 'PYD ' resource from file */ |
Jack Jansen | fe38d29 | 2000-07-03 23:53:40 +0000 | [diff] [blame] | 92 | 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] | 93 | |
Jack Jansen | 6e68a7e | 2001-05-12 21:31:34 +0000 | [diff] [blame] | 94 | #if TARGET_API_MAC_OS8 |
Jack Jansen | 32486f5 | 1995-08-14 12:36:37 +0000 | [diff] [blame] | 95 | int PyMac_GetDirectory(FSSpec *dirfss, char *prompt); /* Ask user for a directory */ |
| 96 | void PyMac_PromptGetFile(short numTypes, ConstSFTypeListPtr typeList, |
| 97 | StandardFileReply *reply, char *prompt); /* Ask user for file, with prompt */ |
Jack Jansen | 6e68a7e | 2001-05-12 21:31:34 +0000 | [diff] [blame] | 98 | #endif /* TARGET_API_MAC_OS8 */ |
Jack Jansen | 3ec804a | 1995-02-20 15:56:10 +0000 | [diff] [blame] | 99 | |
Guido van Rossum | cf27c2d | 1995-01-25 23:06:44 +0000 | [diff] [blame] | 100 | int PyMac_GetOSType(PyObject *, OSType *); /* argument parser for OSType */ |
| 101 | PyObject *PyMac_BuildOSType(OSType); /* Convert OSType to PyObject */ |
Guido van Rossum | b340466 | 1995-01-22 18:36:13 +0000 | [diff] [blame] | 102 | |
Jack Jansen | 7046366 | 1996-08-02 11:21:03 +0000 | [diff] [blame] | 103 | PyObject *PyMac_BuildNumVersion(NumVersion); /* Convert NumVersion to PyObject */ |
| 104 | |
Guido van Rossum | cf27c2d | 1995-01-25 23:06:44 +0000 | [diff] [blame] | 105 | int PyMac_GetStr255(PyObject *, Str255); /* argument parser for Str255 */ |
| 106 | PyObject *PyMac_BuildStr255(Str255); /* Convert Str255 to PyObject */ |
Jack Jansen | b734ade | 1999-12-17 17:15:50 +0000 | [diff] [blame] | 107 | PyObject *PyMac_BuildOptStr255(Str255); /* Convert Str255 to PyObject, NULL to None */ |
Guido van Rossum | cf27c2d | 1995-01-25 23:06:44 +0000 | [diff] [blame] | 108 | |
Guido van Rossum | cf27c2d | 1995-01-25 23:06:44 +0000 | [diff] [blame] | 109 | int PyMac_GetRect(PyObject *, Rect *); /* argument parser for Rect */ |
| 110 | PyObject *PyMac_BuildRect(Rect *); /* Convert Rect to PyObject */ |
| 111 | |
| 112 | int PyMac_GetPoint(PyObject *, Point *); /* argument parser for Point */ |
| 113 | PyObject *PyMac_BuildPoint(Point); /* Convert Point to PyObject */ |
| 114 | |
| 115 | int PyMac_GetEventRecord(PyObject *, EventRecord *); /* argument parser for EventRecord */ |
| 116 | PyObject *PyMac_BuildEventRecord(EventRecord *); /* Convert EventRecord to PyObject */ |
Guido van Rossum | f71a9a9 | 1995-02-18 14:59:48 +0000 | [diff] [blame] | 117 | |
Jack Jansen | fa4d5d0 | 1995-11-15 15:19:29 +0000 | [diff] [blame] | 118 | int PyMac_GetFixed(PyObject *, Fixed *); /* argument parser for Fixed */ |
| 119 | PyObject *PyMac_BuildFixed(Fixed); /* Convert Fixed to PyObject */ |
Jack Jansen | 0dca752 | 1998-04-21 15:20:50 +0000 | [diff] [blame] | 120 | int PyMac_Getwide(PyObject *, wide *); /* argument parser for wide */ |
Jack Jansen | bbf4be2 | 1998-04-23 13:20:17 +0000 | [diff] [blame] | 121 | PyObject *PyMac_Buildwide(wide *); /* Convert wide to PyObject */ |
Guido van Rossum | f71a9a9 | 1995-02-18 14:59:48 +0000 | [diff] [blame] | 122 | void PyMac_InitApplet(void); /* Initialize and run an Applet */ |
Jack Jansen | 52ac037 | 1997-01-15 15:49:08 +0000 | [diff] [blame] | 123 | void PyMac_Initialize(void); /* Initialize function for embedding Python */ |
Jack Jansen | c84cb95 | 1998-04-15 14:12:45 +0000 | [diff] [blame] | 124 | |
Jack Jansen | ee08104 | 2000-04-21 23:53:37 +0000 | [diff] [blame] | 125 | #ifdef USE_GUSI2 |
| 126 | short PyMac_OpenPrefFile(void); /* From macgetpath.c, open and return preference file */ |
| 127 | #endif |
| 128 | |
Jack Jansen | 4e566ab | 2001-07-08 22:07:23 +0000 | [diff] [blame] | 129 | /* from macfsmodule.c: */ |
| 130 | int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */ |
| 131 | PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */ |
| 132 | |
| 133 | int PyMac_GetFSRef(PyObject *, FSRef *); /* argument parser for FSRef */ |
| 134 | PyObject *PyMac_BuildFSRef(FSRef *); /* Convert FSRef to PyObject */ |
| 135 | |
| 136 | |
Jack Jansen | c84cb95 | 1998-04-15 14:12:45 +0000 | [diff] [blame] | 137 | /* From macfiletype.c: */ |
| 138 | |
Jack Jansen | 9ae898b | 2000-07-11 21:16:03 +0000 | [diff] [blame] | 139 | long PyMac_getfiletype(char *); /* Get file type */ |
| 140 | int PyMac_setfiletype(char *, long, long); /* Set file creator and type */ |
| 141 | |
| 142 | /* from macmain.c: */ |
| 143 | void PyMac_Exit(int); |
| 144 | void PyMac_InitApplication(void); |
Jack Jansen | 8413b47 | 2000-10-19 22:02:16 +0000 | [diff] [blame] | 145 | void PyMac_OutputSeen(void); |
Jack Jansen | 8a38714 | 2001-02-11 01:08:04 +0000 | [diff] [blame] | 146 | void PyMac_OutputNotSeen(void); |
| 147 | int PyMac_GetDelayConsoleFlag(void); |
Jack Jansen | 9ae898b | 2000-07-11 21:16:03 +0000 | [diff] [blame] | 148 | #ifdef USE_MAC_APPLET_SUPPORT |
| 149 | void PyMac_InitApplet(void); |
| 150 | #endif |
| 151 | |
| 152 | /* from macgetargv: */ |
| 153 | OSErr PyMac_init_process_location(void); |
| 154 | #ifndef HAVE_STRDUP |
| 155 | char * strdup(const char *str); |
| 156 | #endif |
| 157 | |
Jack Jansen | c7fda7e | 1999-09-30 11:14:49 +0000 | [diff] [blame] | 158 | #ifdef __cplusplus |
| 159 | } |
| 160 | #endif |