1 /***********************************************************
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam,
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.
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.
23 ******************************************************************/
25 #ifdef WITHOUT_FRAMEWORKS
29 #include <StandardFile.h>
31 #include <Carbon/Carbon.h>
38 /* Scheduler parameters */
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 */
47 char *PyMac_getscript(void); /* Get the default encoding for our 8bit character set */
49 void PyMac_FixGUSIcd(void); /* Workaround for GUSI chdir() call */
50 extern void PyMac_SetGUSISpin(void); /* Install our private GUSI spin routine */
53 char *PyMac_StrError(int); /* strerror with mac errors */
54 PyObject
*PyErr_Mac(PyObject
*, int); /* Exception with a mac error */
55 PyObject
*PyMac_Error(OSErr
); /* Uses PyMac_GetOSErrException */
56 unsigned char *Pstring(char *str
); /* Convert c-string to pascal-string in static buffer */
59 extern int PyMac_ConsoleIsDead
; /* True when exiting */
60 extern void PyMac_StopGUSISpin(void); /* Stop eventprocessing during exit() */
63 extern short PyMac_AppRefNum
; /* RefNum of application rsrcfork (from macmain.c) */
64 extern FSSpec PyMac_ApplicationFSSpec
; /* Application location (from macargv.c) */
65 extern char PyMac_ApplicationPath
[]; /* Application location (from macargv.c) */
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) */
69 extern int PyMac_AppearanceCompliant
; /* True if in appearance support mode */
71 extern PyObject
*PyMac_OSErrException
; /* Exception for OSErr */
72 PyObject
*PyMac_GetOSErrException(void); /* Initialize & return it */
74 #if !TARGET_API_MAC_OSX
75 void PyMac_GetSchedParams(PyMacSchedParams
*); /* Get schedulers params */
76 void PyMac_SetSchedParams(PyMacSchedParams
*); /* Set schedulers params */
77 int PyMac_DoYield(int, int); /* Yield cpu. First arg is maxtime, second ok to call python */
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 */
83 #if !TARGET_API_MAC_OSX
84 void PyMac_InitMenuBar(void); /* Setup menu bar as we want it */
85 void PyMac_RestoreMenuBar(void); /* Restore menu bar for ease of exiting */
86 void PyMac_RaiseConsoleWindow(); /* Bring console window to front, if it exists */
88 int PyMac_FindResourceModule(PyStringObject
*, char *, char *); /* Test for 'PYC ' resource in a file */
89 PyObject
* PyMac_LoadResourceModule(char *, char *); /* Load 'PYC ' resource from file */
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 */
92 struct filedescr
*PyMac_FindModuleExtension(char *, size_t *, char *); /* Look for module in single folder */
94 #if TARGET_API_MAC_OS8
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 */
98 #endif /* TARGET_API_MAC_OS8 */
100 int PyMac_GetOSType(PyObject
*, OSType
*); /* argument parser for OSType */
101 PyObject
*PyMac_BuildOSType(OSType
); /* Convert OSType to PyObject */
103 PyObject
*PyMac_BuildNumVersion(NumVersion
); /* Convert NumVersion to PyObject */
105 int PyMac_GetStr255(PyObject
*, Str255
); /* argument parser for Str255 */
106 PyObject
*PyMac_BuildStr255(Str255
); /* Convert Str255 to PyObject */
107 PyObject
*PyMac_BuildOptStr255(Str255
); /* Convert Str255 to PyObject, NULL to None */
109 int PyMac_GetRect(PyObject
*, Rect
*); /* argument parser for Rect */
110 PyObject
*PyMac_BuildRect(Rect
*); /* Convert Rect to PyObject */
112 int PyMac_GetPoint(PyObject
*, Point
*); /* argument parser for Point */
113 PyObject
*PyMac_BuildPoint(Point
); /* Convert Point to PyObject */
115 int PyMac_GetEventRecord(PyObject
*, EventRecord
*); /* argument parser for EventRecord */
116 PyObject
*PyMac_BuildEventRecord(EventRecord
*); /* Convert EventRecord to PyObject */
118 int PyMac_GetFixed(PyObject
*, Fixed
*); /* argument parser for Fixed */
119 PyObject
*PyMac_BuildFixed(Fixed
); /* Convert Fixed to PyObject */
120 int PyMac_Getwide(PyObject
*, wide
*); /* argument parser for wide */
121 PyObject
*PyMac_Buildwide(wide
*); /* Convert wide to PyObject */
122 void PyMac_InitApplet(void); /* Initialize and run an Applet */
123 void PyMac_Initialize(void); /* Initialize function for embedding Python */
126 short PyMac_OpenPrefFile(void); /* From macgetpath.c, open and return preference file */
129 /* from macfsmodule.c: */
130 int PyMac_GetFSSpec(PyObject
*, FSSpec
*); /* argument parser for FSSpec */
131 PyObject
*PyMac_BuildFSSpec(FSSpec
*); /* Convert FSSpec to PyObject */
133 int PyMac_GetFSRef(PyObject
*, FSRef
*); /* argument parser for FSRef */
134 PyObject
*PyMac_BuildFSRef(FSRef
*); /* Convert FSRef to PyObject */
137 /* From macfiletype.c: */
139 long PyMac_getfiletype(char *); /* Get file type */
140 int PyMac_setfiletype(char *, long, long); /* Set file creator and type */
142 /* from macmain.c: */
143 void PyMac_Exit(int);
144 void PyMac_InitApplication(void);
145 void PyMac_OutputSeen(void);
146 void PyMac_OutputNotSeen(void);
147 int PyMac_GetDelayConsoleFlag(void);
148 #ifdef USE_MAC_APPLET_SUPPORT
149 void PyMac_InitApplet(void);
152 /* from macgetargv: */
153 OSErr
PyMac_init_process_location(void);
155 char * strdup(const char *str
);