summaryrefslogtreecommitdiffstats
path: root/Mac/Python
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2000-04-07 09:10:49 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2000-04-07 09:10:49 (GMT)
commit2d1306b7cf4a85290ffbd90a15fed6115a522310 (patch)
tree01dc9d71385f7659ba36bd2b27f4ca2c3d3a1154 /Mac/Python
parent5c21420772a94846ce7dd077d10a2575da15e84e (diff)
downloadcpython-2d1306b7cf4a85290ffbd90a15fed6115a522310.zip
cpython-2d1306b7cf4a85290ffbd90a15fed6115a522310.tar.gz
cpython-2d1306b7cf4a85290ffbd90a15fed6115a522310.tar.bz2
Started on GUSI2 and threading support.
Diffstat (limited to 'Mac/Python')
-rw-r--r--Mac/Python/getmtime.c4
-rw-r--r--Mac/Python/gusiconfig.cpp101
-rw-r--r--Mac/Python/macgetcompiler.c22
-rw-r--r--Mac/Python/macgetpath.c4
-rw-r--r--Mac/Python/macglue.c17
-rw-r--r--Mac/Python/macimport.c8
-rw-r--r--Mac/Python/macmain.c8
7 files changed, 143 insertions, 21 deletions
diff --git a/Mac/Python/getmtime.c b/Mac/Python/getmtime.c
index 29721ee..a14ef71 100644
--- a/Mac/Python/getmtime.c
+++ b/Mac/Python/getmtime.c
@@ -38,7 +38,11 @@ PERFORMANCE OF THIS SOFTWARE.
#ifdef USE_GUSI
#include <sys/types.h>
#endif /* USE_GUSI */
+#ifdef USE_GUSI2
+#include <sys/stat.h>
+#else
#include <stat.h>
+#endif
#include "rename2.h"
long
diff --git a/Mac/Python/gusiconfig.cpp b/Mac/Python/gusiconfig.cpp
new file mode 100644
index 0000000..c69498f
--- /dev/null
+++ b/Mac/Python/gusiconfig.cpp
@@ -0,0 +1,101 @@
+/*
+ * Generated with the GUSIConfig application and then hand-modified by jack.
+ */
+
+#define GUSI_SOURCE
+#include <GUSIConfig.h>
+#include <sys/cdefs.h>
+
+#include "Python.h"
+#include "macglue.h"
+
+static void
+PyMac_GUSISpin(bool wait)
+{
+ static Boolean inForeground = true;
+ int maxsleep = 6; /* 6 ticks is "normal" sleeptime */
+
+ if (PyMac_ConsoleIsDead) return;
+
+ if ( !wait )
+ maxsleep = 0;
+
+ PyMac_DoYield(maxsleep, 0); /* XXXX or is it safe to call python here? */
+}
+
+
+/* Declarations of Socket Factories */
+
+__BEGIN_DECLS
+void GUSIwithInetSockets();
+void GUSIwithLocalSockets();
+void GUSIwithMTInetSockets();
+void GUSIwithMTTcpSockets();
+void GUSIwithMTUdpSockets();
+void GUSIwithOTInetSockets();
+void GUSIwithOTTcpSockets();
+void GUSIwithOTUdpSockets();
+void GUSIwithPPCSockets();
+void GUSISetupFactories();
+__END_DECLS
+
+/* Configure Socket Factories */
+
+void GUSISetupFactories()
+{
+#ifdef GUSISetupFactories_BeginHook
+ GUSISetupFactories_BeginHook
+#endif
+ GUSIwithInetSockets();
+#ifdef GUSISetupFactories_EndHook
+ GUSISetupFactories_EndHook
+#endif
+}
+
+/* Declarations of File Devices */
+
+__BEGIN_DECLS
+void GUSIwithDConSockets();
+void GUSIwithNullSockets();
+void GUSISetupDevices();
+__END_DECLS
+
+/* Configure File Devices */
+
+void GUSISetupDevices()
+{
+#ifdef GUSISetupDevices_BeginHook
+ GUSISetupDevices_BeginHook
+#endif
+#ifdef GUSISetupDevices_EndHook
+ GUSISetupDevices_EndHook
+#endif
+}
+
+#ifndef __cplusplus
+#error GUSISetupConfig() needs to be written in C++
+#endif
+
+GUSIConfiguration::FileSuffix sSuffices[] = {
+ "", '????', '????'
+};
+
+extern "C" void GUSISetupConfig()
+{
+ GUSIConfiguration * config =
+ GUSIConfiguration::CreateInstance(GUSIConfiguration::kNoResource);
+
+ config->ConfigureDefaultTypeCreator('TEXT', 'TEXT');
+ config->ConfigureSuffices(
+ sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices);
+ config->ConfigureAutoInitGraf(false);
+ config->ConfigureAutoSpin(false);
+ config->ConfigureHandleAppleEvents(false);
+ config->ConfigureSigInt(false);
+ config->ConfigureSigPipe(true);
+
+ GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin);
+
+}
+
+/**************** END GUSI CONFIGURATION *************************/
diff --git a/Mac/Python/macgetcompiler.c b/Mac/Python/macgetcompiler.c
index 347b8d2..8836581 100644
--- a/Mac/Python/macgetcompiler.c
+++ b/Mac/Python/macgetcompiler.c
@@ -38,23 +38,35 @@ PERFORMANCE OF THIS SOFTWARE.
#endif
#ifdef __MWERKS__
-#ifdef USE_GUSI
-#define HASGUSI " w/GUSI"
+#ifdef USE_GUSI1
+#define HASGUSI " w/GUSI1"
+#else
+#ifdef USE_GUSI2
+#define HASGUSI " w/GUSI2"
#else
#define HASGUSI ""
#endif
+#endif
+
#ifdef USE_MSL
#define HASMSL " w/MSL"
#else
#define HASMSL ""
#endif
+
+#ifdef WITH_THREAD
+#define HASTHREAD " w/THREADS"
+#else
+#define HASTHREAD ""
+#endif
+
#ifdef __powerc
-#define COMPILER " [CW PPC" HASGUSI HASMSL "]"
+#define COMPILER " [CW PPC" HASGUSI HASMSL HASTHREAD"]"
#else
#ifdef __CFM68K__
-#define COMPILER " [CW CFM68K" HASGUSI HASMSL "]"
+#define COMPILER " [CW CFM68K" HASGUSI HASMSL HASTHREAD"]"
#else
-#define COMPILER " [CW 68K" HASGUSI HASMSL "]"
+#define COMPILER " [CW 68K" HASGUSI HASMSL HASTHREAD"]"
#endif
#endif
#endif
diff --git a/Mac/Python/macgetpath.c b/Mac/Python/macgetpath.c
index 02f9b48..d1c60a0 100644
--- a/Mac/Python/macgetpath.c
+++ b/Mac/Python/macgetpath.c
@@ -54,7 +54,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include <TextUtils.h>
#include <Dialogs.h>
-#ifdef USE_GUSI
+#ifdef USE_GUSI1
#include <GUSI.h>
#endif
@@ -444,7 +444,7 @@ PyMac_PreferenceOptions(PyMac_PrefRecord *pr)
UseResFile(oldrh);
}
-#ifdef USE_GUSI
+#ifdef USE_GUSI1
void
PyMac_SetGUSIOptions()
{
diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c
index 46493d3..fd0ddfb 100644
--- a/Mac/Python/macglue.c
+++ b/Mac/Python/macglue.c
@@ -62,11 +62,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifdef __MWERKS__
#include <SIOUX.h>
#endif
-#ifdef USE_GUSI
+#ifdef USE_GUSI1
#include <TFileSpec.h> /* For Path2FSSpec */
-#include <LowMem.h> /* For SetSFCurDir, etc */
#include <GUSI.h>
#endif
+#include <LowMem.h>
/* The ID of the Sioux apple menu */
#define SIOUX_APPLEID 32000
@@ -108,7 +108,6 @@ extern PyObject *newmfssobject Py_PROTO((FSSpec *));
static int interrupted; /* Set to true when cmd-. seen */
static RETSIGTYPE intcatcher Py_PROTO((int));
-static int PyMac_DoYield Py_PROTO((int, int));
static int PyMac_Yield Py_PROTO((void));
/*
@@ -161,7 +160,7 @@ static PyObject *python_event_handler;
*/
int PyMac_AppearanceCompliant;
-#ifdef USE_GUSI
+#ifdef USE_GUSI1
/*
** GUSI (1.6.0 and earlier, at the least) do not set the MacOS idea of
** the working directory. Hence, we call this routine after each call
@@ -183,7 +182,9 @@ PyMac_FixGUSIcd()
if (PBHSetVolSync(&pb) != noErr)
return;
}
+#endif
+#ifdef USE_GUSI
/*
** SpinCursor (needed by GUSI) drags in heaps of stuff, so we
** provide a dummy here.
@@ -194,6 +195,7 @@ void RotateCursor(short x) { /* Dummy */ }
/*
** Replacement GUSI Spin function
*/
+#ifdef USE_GUSI1
static int
PyMac_GUSISpin(spin_msg msg, long arg)
{
@@ -222,6 +224,7 @@ void
PyMac_SetGUSISpin() {
GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin);
}
+#endif
/* Called at exit() time thru atexit(), to stop event processing */
void
@@ -531,7 +534,7 @@ PyMac_HandleEvent(evp)
/*
** Yield the CPU to other tasks without processing events.
*/
-static int
+int
PyMac_DoYield(int maxsleep, int maycallpython)
{
EventRecord ev;
@@ -563,7 +566,7 @@ PyMac_DoYield(int maxsleep, int maycallpython)
}
} else {
latest_time_ready = LMGetTicks() + maxsleep;
- while ( maxsleep >= 0 ) {
+ do {
/* XXXX Hack by Jack.
** In time.sleep() you can click to another application
** once only. If you come back to Python you cannot get away
@@ -578,7 +581,7 @@ PyMac_DoYield(int maxsleep, int maycallpython)
return -1;
}
maxsleep = latest_time_ready - LMGetTicks();
- }
+ } while ( maxsleep > 0 );
}
in_here--;
return 0;
diff --git a/Mac/Python/macimport.c b/Mac/Python/macimport.c
index e079d2e..2f5d622 100644
--- a/Mac/Python/macimport.c
+++ b/Mac/Python/macimport.c
@@ -48,7 +48,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#endif
#include <CodeFragments.h>
-#ifdef USE_GUSI
+#ifdef USE_GUSI1
#include "TFileSpec.h" /* for Path2FSSpec() */
#endif
@@ -104,7 +104,7 @@ findnamedresource(
UseResFile(PyMac_AppRefNum);
filerh = -1;
} else {
-#ifdef USE_GUSI
+#ifdef USE_GUSI1
if ( Path2FSSpec(filename, &fss) != noErr ||
#else
if ( FSMakeFSSpec(0, 0, Pstring(filename), &fss) != noErr ||
@@ -303,7 +303,7 @@ char *filename;
UseResFile(PyMac_AppRefNum);
filerh = -1;
} else {
-#ifdef USE_GUSI
+#ifdef USE_GUSI1
if ( (err=Path2FSSpec(filename, &fss)) != noErr ||
FSpGetFInfo(&fss, &finfo) != noErr )
#else
@@ -432,7 +432,7 @@ PyMac_FindModuleExtension(char *buf, int *lenp, char *module)
#else
strcpy(buf+*lenp, _PyImport_Filetab[0].suffix);
#endif
-#ifdef USE_GUSI
+#ifdef USE_GUSI1
if ( Path2FSSpec(buf, &fss) == noErr &&
FSpGetFInfo(&fss, &finfo) == noErr)
return _PyImport_Filetab;
diff --git a/Mac/Python/macmain.c b/Mac/Python/macmain.c
index db39e18..98298c8 100644
--- a/Mac/Python/macmain.c
+++ b/Mac/Python/macmain.c
@@ -225,13 +225,15 @@ init_common(int *argcp, char ***argvp, int embedded)
PyMac_AddLibResources();
#endif
-#if defined(USE_GUSI)
+#if defined(USE_GUSI1)
/* Setup GUSI */
GUSIDefaultSetup();
PyMac_SetGUSISpin();
PyMac_SetGUSIOptions();
- atexit(PyMac_StopGUSISpin);
#endif
+#if defined(USE_GUSI)
+ atexit(PyMac_StopGUSISpin);
+#endif
#ifdef USE_SIOUX
/* Set various SIOUX flags. Some are changed later based on options */
@@ -405,7 +407,7 @@ PyMac_InitApplication()
*endp = '\0';
chdir(curwd);
-#ifdef USE_GUSI
+#ifdef USE_GUSI1
/* Change MacOS's idea of wd too */
PyMac_FixGUSIcd();
#endif