Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d1306b

Browse files
committed
Started on GUSI2 and threading support.
1 parent 5c21420 commit 2d1306b

16 files changed

Lines changed: 194 additions & 29 deletions

Mac/Include/macglue.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ typedef struct {
5353
#pragma lib_export on
5454
#endif
5555

56-
#ifdef USE_GUSI
56+
#ifdef USE_GUSI1
5757
void PyMac_FixGUSIcd Py_PROTO((void)); /* Workaround for GUSI chdir() call */
58+
extern void PyMac_SetGUSISpin(void); /* Install our private GUSI spin routine */
5859
#endif
5960

6061
char *PyMac_StrError(int); /* strerror with mac errors */
6162
unsigned char *Pstring(char *str); /* Convert c-string to pascal-string in static buffer */
6263

6364
#ifdef USE_GUSI
6465
extern int PyMac_ConsoleIsDead; /* True when exiting */
65-
extern void PyMac_SetGUSISpin(void); /* Install our private GUSI spin routine */
6666
extern void PyMac_StopGUSISpin(void); /* Stop eventprocessing during exit() */
6767
#endif
6868

@@ -81,6 +81,7 @@ void PyMac_GetSchedParams Py_PROTO((PyMacSchedParams *)); /* Get schedulers para
8181
void PyMac_SetSchedParams Py_PROTO((PyMacSchedParams *)); /* Set schedulers params */
8282
PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */
8383
PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */
84+
int PyMac_DoYield Py_PROTO((int, int)); /* Yield cpu. First arg is maxtime, second ok to call python */
8485
int PyMac_HandleEvent Py_PROTO((EventRecord *)); /* Handle one event, possibly in Python */
8586
void PyMac_HandleEventIntern Py_PROTO((EventRecord *)); /* Handle one event internal only */
8687
int PyMac_SetEventHandler Py_PROTO((PyObject *)); /* set python-coded event handler */

Mac/Python/getmtime.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ PERFORMANCE OF THIS SOFTWARE.
3838
#ifdef USE_GUSI
3939
#include <sys/types.h>
4040
#endif /* USE_GUSI */
41+
#ifdef USE_GUSI2
42+
#include <sys/stat.h>
43+
#else
4144
#include <stat.h>
45+
#endif
4246
#include "rename2.h"
4347

4448
long

Mac/Python/gusiconfig.cpp

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* Generated with the GUSIConfig application and then hand-modified by jack.
3+
*/
4+
5+
#define GUSI_SOURCE
6+
#include <GUSIConfig.h>
7+
#include <sys/cdefs.h>
8+
9+
#include "Python.h"
10+
#include "macglue.h"
11+
12+
static void
13+
PyMac_GUSISpin(bool wait)
14+
{
15+
static Boolean inForeground = true;
16+
int maxsleep = 6; /* 6 ticks is "normal" sleeptime */
17+
18+
if (PyMac_ConsoleIsDead) return;
19+
20+
if ( !wait )
21+
maxsleep = 0;
22+
23+
PyMac_DoYield(maxsleep, 0); /* XXXX or is it safe to call python here? */
24+
}
25+
26+
27+
/* Declarations of Socket Factories */
28+
29+
__BEGIN_DECLS
30+
void GUSIwithInetSockets();
31+
void GUSIwithLocalSockets();
32+
void GUSIwithMTInetSockets();
33+
void GUSIwithMTTcpSockets();
34+
void GUSIwithMTUdpSockets();
35+
void GUSIwithOTInetSockets();
36+
void GUSIwithOTTcpSockets();
37+
void GUSIwithOTUdpSockets();
38+
void GUSIwithPPCSockets();
39+
void GUSISetupFactories();
40+
__END_DECLS
41+
42+
/* Configure Socket Factories */
43+
44+
void GUSISetupFactories()
45+
{
46+
#ifdef GUSISetupFactories_BeginHook
47+
GUSISetupFactories_BeginHook
48+
#endif
49+
GUSIwithInetSockets();
50+
#ifdef GUSISetupFactories_EndHook
51+
GUSISetupFactories_EndHook
52+
#endif
53+
}
54+
55+
/* Declarations of File Devices */
56+
57+
__BEGIN_DECLS
58+
void GUSIwithDConSockets();
59+
void GUSIwithNullSockets();
60+
void GUSISetupDevices();
61+
__END_DECLS
62+
63+
/* Configure File Devices */
64+
65+
void GUSISetupDevices()
66+
{
67+
#ifdef GUSISetupDevices_BeginHook
68+
GUSISetupDevices_BeginHook
69+
#endif
70+
#ifdef GUSISetupDevices_EndHook
71+
GUSISetupDevices_EndHook
72+
#endif
73+
}
74+
75+
#ifndef __cplusplus
76+
#error GUSISetupConfig() needs to be written in C++
77+
#endif
78+
79+
GUSIConfiguration::FileSuffix sSuffices[] = {
80+
"", '????', '????'
81+
};
82+
83+
extern "C" void GUSISetupConfig()
84+
{
85+
GUSIConfiguration * config =
86+
GUSIConfiguration::CreateInstance(GUSIConfiguration::kNoResource);
87+
88+
config->ConfigureDefaultTypeCreator('TEXT', 'TEXT');
89+
config->ConfigureSuffices(
90+
sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices);
91+
config->ConfigureAutoInitGraf(false);
92+
config->ConfigureAutoSpin(false);
93+
config->ConfigureHandleAppleEvents(false);
94+
config->ConfigureSigInt(false);
95+
config->ConfigureSigPipe(true);
96+
97+
GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin);
98+
99+
}
100+
101+
/**************** END GUSI CONFIGURATION *************************/

Mac/Python/macgetcompiler.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,35 @@ PERFORMANCE OF THIS SOFTWARE.
3838
#endif
3939

4040
#ifdef __MWERKS__
41-
#ifdef USE_GUSI
42-
#define HASGUSI " w/GUSI"
41+
#ifdef USE_GUSI1
42+
#define HASGUSI " w/GUSI1"
43+
#else
44+
#ifdef USE_GUSI2
45+
#define HASGUSI " w/GUSI2"
4346
#else
4447
#define HASGUSI ""
4548
#endif
49+
#endif
50+
4651
#ifdef USE_MSL
4752
#define HASMSL " w/MSL"
4853
#else
4954
#define HASMSL ""
5055
#endif
56+
57+
#ifdef WITH_THREAD
58+
#define HASTHREAD " w/THREADS"
59+
#else
60+
#define HASTHREAD ""
61+
#endif
62+
5163
#ifdef __powerc
52-
#define COMPILER " [CW PPC" HASGUSI HASMSL "]"
64+
#define COMPILER " [CW PPC" HASGUSI HASMSL HASTHREAD"]"
5365
#else
5466
#ifdef __CFM68K__
55-
#define COMPILER " [CW CFM68K" HASGUSI HASMSL "]"
67+
#define COMPILER " [CW CFM68K" HASGUSI HASMSL HASTHREAD"]"
5668
#else
57-
#define COMPILER " [CW 68K" HASGUSI HASMSL "]"
69+
#define COMPILER " [CW 68K" HASGUSI HASMSL HASTHREAD"]"
5870
#endif
5971
#endif
6072
#endif

Mac/Python/macgetpath.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ PERFORMANCE OF THIS SOFTWARE.
5454
#include <TextUtils.h>
5555
#include <Dialogs.h>
5656

57-
#ifdef USE_GUSI
57+
#ifdef USE_GUSI1
5858
#include <GUSI.h>
5959
#endif
6060

@@ -444,7 +444,7 @@ PyMac_PreferenceOptions(PyMac_PrefRecord *pr)
444444
UseResFile(oldrh);
445445
}
446446

447-
#ifdef USE_GUSI
447+
#ifdef USE_GUSI1
448448
void
449449
PyMac_SetGUSIOptions()
450450
{

Mac/Python/macglue.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6262
#ifdef __MWERKS__
6363
#include <SIOUX.h>
6464
#endif
65-
#ifdef USE_GUSI
65+
#ifdef USE_GUSI1
6666
#include <TFileSpec.h> /* For Path2FSSpec */
67-
#include <LowMem.h> /* For SetSFCurDir, etc */
6867
#include <GUSI.h>
6968
#endif
69+
#include <LowMem.h>
7070

7171
/* The ID of the Sioux apple menu */
7272
#define SIOUX_APPLEID 32000
@@ -108,7 +108,6 @@ extern PyObject *newmfssobject Py_PROTO((FSSpec *));
108108
static int interrupted; /* Set to true when cmd-. seen */
109109
static RETSIGTYPE intcatcher Py_PROTO((int));
110110

111-
static int PyMac_DoYield Py_PROTO((int, int));
112111
static int PyMac_Yield Py_PROTO((void));
113112

114113
/*
@@ -161,7 +160,7 @@ static PyObject *python_event_handler;
161160
*/
162161
int PyMac_AppearanceCompliant;
163162

164-
#ifdef USE_GUSI
163+
#ifdef USE_GUSI1
165164
/*
166165
** GUSI (1.6.0 and earlier, at the least) do not set the MacOS idea of
167166
** the working directory. Hence, we call this routine after each call
@@ -183,7 +182,9 @@ PyMac_FixGUSIcd()
183182
if (PBHSetVolSync(&pb) != noErr)
184183
return;
185184
}
185+
#endif
186186

187+
#ifdef USE_GUSI
187188
/*
188189
** SpinCursor (needed by GUSI) drags in heaps of stuff, so we
189190
** provide a dummy here.
@@ -194,6 +195,7 @@ void RotateCursor(short x) { /* Dummy */ }
194195
/*
195196
** Replacement GUSI Spin function
196197
*/
198+
#ifdef USE_GUSI1
197199
static int
198200
PyMac_GUSISpin(spin_msg msg, long arg)
199201
{
@@ -222,6 +224,7 @@ void
222224
PyMac_SetGUSISpin() {
223225
GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin);
224226
}
227+
#endif
225228

226229
/* Called at exit() time thru atexit(), to stop event processing */
227230
void
@@ -531,7 +534,7 @@ PyMac_HandleEvent(evp)
531534
/*
532535
** Yield the CPU to other tasks without processing events.
533536
*/
534-
static int
537+
int
535538
PyMac_DoYield(int maxsleep, int maycallpython)
536539
{
537540
EventRecord ev;
@@ -563,7 +566,7 @@ PyMac_DoYield(int maxsleep, int maycallpython)
563566
}
564567
} else {
565568
latest_time_ready = LMGetTicks() + maxsleep;
566-
while ( maxsleep >= 0 ) {
569+
do {
567570
/* XXXX Hack by Jack.
568571
** In time.sleep() you can click to another application
569572
** once only. If you come back to Python you cannot get away
@@ -578,7 +581,7 @@ PyMac_DoYield(int maxsleep, int maycallpython)
578581
return -1;
579582
}
580583
maxsleep = latest_time_ready - LMGetTicks();
581-
}
584+
} while ( maxsleep > 0 );
582585
}
583586
in_here--;
584587
return 0;

Mac/Python/macimport.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4848
#endif
4949
#include <CodeFragments.h>
5050

51-
#ifdef USE_GUSI
51+
#ifdef USE_GUSI1
5252
#include "TFileSpec.h" /* for Path2FSSpec() */
5353
#endif
5454

@@ -104,7 +104,7 @@ findnamedresource(
104104
UseResFile(PyMac_AppRefNum);
105105
filerh = -1;
106106
} else {
107-
#ifdef USE_GUSI
107+
#ifdef USE_GUSI1
108108
if ( Path2FSSpec(filename, &fss) != noErr ||
109109
#else
110110
if ( FSMakeFSSpec(0, 0, Pstring(filename), &fss) != noErr ||
@@ -303,7 +303,7 @@ char *filename;
303303
UseResFile(PyMac_AppRefNum);
304304
filerh = -1;
305305
} else {
306-
#ifdef USE_GUSI
306+
#ifdef USE_GUSI1
307307
if ( (err=Path2FSSpec(filename, &fss)) != noErr ||
308308
FSpGetFInfo(&fss, &finfo) != noErr )
309309
#else
@@ -432,7 +432,7 @@ PyMac_FindModuleExtension(char *buf, int *lenp, char *module)
432432
#else
433433
strcpy(buf+*lenp, _PyImport_Filetab[0].suffix);
434434
#endif
435-
#ifdef USE_GUSI
435+
#ifdef USE_GUSI1
436436
if ( Path2FSSpec(buf, &fss) == noErr &&
437437
FSpGetFInfo(&fss, &finfo) == noErr)
438438
return _PyImport_Filetab;

Mac/Python/macmain.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,15 @@ init_common(int *argcp, char ***argvp, int embedded)
225225
PyMac_AddLibResources();
226226
#endif
227227

228-
#if defined(USE_GUSI)
228+
#if defined(USE_GUSI1)
229229
/* Setup GUSI */
230230
GUSIDefaultSetup();
231231
PyMac_SetGUSISpin();
232232
PyMac_SetGUSIOptions();
233-
atexit(PyMac_StopGUSISpin);
234233
#endif
234+
#if defined(USE_GUSI)
235+
atexit(PyMac_StopGUSISpin);
236+
#endif
235237

236238
#ifdef USE_SIOUX
237239
/* Set various SIOUX flags. Some are changed later based on options */
@@ -405,7 +407,7 @@ PyMac_InitApplication()
405407
*endp = '\0';
406408

407409
chdir(curwd);
408-
#ifdef USE_GUSI
410+
#ifdef USE_GUSI1
409411
/* Change MacOS's idea of wd too */
410412
PyMac_FixGUSIcd();
411413
#endif

Mac/mwerks/errno_unix.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ PERFORMANCE OF THIS SOFTWARE.
2929
3030
******************************************************************/
3131

32+
#ifndef USE_GUSI2
3233
#define ENOTDIR (-120)
3334
#ifndef __MSL__
3435
#define EACCES (-54)
@@ -40,6 +41,7 @@ PERFORMANCE OF THIS SOFTWARE.
4041
#define ENFILE (-42)
4142
#define EIO (-36)
4243
#define ENOSPC (-34)
44+
#endif
4345

4446
#define ESRCH 3
4547
#define EINTR 4

Mac/mwerks/mwerks_nonshared_config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
** specific features, you may also need different sets of sources.
66
*/
77

8-
#define USE_GUSI /* Stdio implemented with GUSI */
8+
#define USE_GUSI1 /* Stdio implemented with GUSI */
9+
/* #define USE_GUSI2 /* Stdio implemented with GUSI 2 */
910
#define USE_MSL /* Use Mw Standard Library (as opposed to Plaugher C libraries) */
1011
#define USE_TOOLBOX /* Include toolbox modules in core Python */
1112
#define USE_QT /* Include quicktime modules in core Python */

0 commit comments

Comments
 (0)