From b19444fecac0fd38ef9647ad6e4efb4fb58893a6 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Thu, 11 Apr 2002 20:48:25 +0000 Subject: Got rid of ifdefs for long-obsolete GUSI versions and other stuff that is now standard (appearance, interned strings) --- Mac/Python/macgetpath.c | 34 ------------------ Mac/Python/macglue.c | 91 ------------------------------------------------- Mac/Python/macimport.c | 41 ---------------------- Mac/Python/macmain.c | 31 ----------------- 4 files changed, 197 deletions(-) diff --git a/Mac/Python/macgetpath.c b/Mac/Python/macgetpath.c index b79e90b..dfb689e 100644 --- a/Mac/Python/macgetpath.c +++ b/Mac/Python/macgetpath.c @@ -63,10 +63,6 @@ PERFORMANCE OF THIS SOFTWARE. #include #include -#ifdef USE_GUSI1 -#include -#endif - #ifndef USE_BUILTIN_PATH staticforward char *PyMac_GetPythonPath(); #endif @@ -211,11 +207,6 @@ PyMac_OpenPrefFile() return -1; prefrh = FSpOpenResFile(&dirspec, fsRdWrShPerm); if ( prefrh < 0 ) { -#if 0 - action = CautionAlert(NOPREFFILE_ID, NULL); - if ( action == NOPREFFILE_NO ) - exit(1); -#endif FSpCreateResFile(&dirspec, 'Pyth', 'pref', 0); prefrh = FSpOpenResFile(&dirspec, fsRdWrShPerm); if ( prefrh == -1 ) { @@ -453,28 +444,3 @@ PyMac_PreferenceOptions(PyMac_PrefRecord *pr) if ( prefrh != -1) CloseResFile(prefrh); UseResFile(oldrh); } - -#ifdef USE_GUSI1 -void -PyMac_SetGUSIOptions() -{ - Handle h; - short oldrh, prefrh = -1; - - oldrh = CurResFile(); - - /* Try override from the application resource fork */ - UseResFile(PyMac_AppRefNum); - h = Get1Resource('GU\267I', GUSIOPTIONSOVERRIDE_ID); - UseResFile(oldrh); - - /* If that didn't work try nonoverride from anywhere */ - if ( h == NULL ) { - prefrh = PyMac_OpenPrefFile(); - h = GetResource('GU\267I', GUSIOPTIONS_ID); - } - if ( h ) GUSILoadConfiguration(h); - if ( prefrh != -1) CloseResFile(prefrh); - UseResFile(oldrh); -} -#endif /* USE_GUSI1 */ diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c index f78f97f..feb148f 100644 --- a/Mac/Python/macglue.c +++ b/Mac/Python/macglue.c @@ -71,11 +71,6 @@ extern pascal unsigned char *PLstrrchr(unsigned char *, unsigned char); #endif -#ifdef USE_GUSI1 -#include /* For Path2FSSpec */ -#include -#endif - /* The ID of the Sioux apple menu */ #define SIOUX_APPLEID 32000 @@ -174,11 +169,6 @@ static int upp_inited = 0; */ static PyObject *python_event_handler; -/* -** Set to true if we're appearance-compliant -*/ -int PyMac_AppearanceCompliant; - /* Given an FSSpec, return the FSSpec of the parent folder */ static OSErr @@ -250,29 +240,6 @@ PyMac_GetFullPathname (FSSpec *fss, char *buf, int length) return 0; } -#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 -** to chdir() to rectify things. -*/ -void -PyMac_FixGUSIcd() -{ - WDPBRec pb; - FSSpec curdirfss; - - if ( Path2FSSpec(":x", &curdirfss) != noErr ) - return; - - /* Set MacOS "working directory" */ - pb.ioNamePtr= "\p"; - pb.ioVRefNum= curdirfss.vRefNum; - pb.ioWDDirID= curdirfss.parID; - if (PBHSetVolSync(&pb) != noErr) - return; -} -#endif #ifdef USE_GUSI /* @@ -282,48 +249,6 @@ PyMac_FixGUSIcd() void SpinCursor(short x) { /* Dummy */ } void RotateCursor(short x) { /* Dummy */ } -/* -** Replacement GUSI Spin function -*/ -#ifdef USE_GUSI1 -static int -PyMac_GUSISpin(spin_msg msg, long arg) -{ - static Boolean inForeground = true; - int maxsleep = 6; /* 6 ticks is "normal" sleeptime */ - - if (PyMac_ConsoleIsDead) return 0; -#if 0 - if (inForeground) - SpinCursor(msg == SP_AUTO_SPIN ? short(arg) : 1); -#endif - - - if ( msg == SP_AUTO_SPIN ) - maxsleep = 0; - if ( msg==SP_SLEEP||msg==SP_SELECT ) { - maxsleep = arg; - /* - ** We force-scan for interrupts. Not pretty, but otherwise - ** a program may hang in select or sleep forever. - */ - scan_event_queue(1); - } - if (interrupted) { - interrupted = 0; - return -1; - } - - PyMac_DoYield(maxsleep, 0); /* XXXX or is it safe to call python here? */ - - return 0; -} - -void -PyMac_SetGUSISpin() { - GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin); -} -#endif /* Called at exit() time thru atexit(), to stop event processing */ void @@ -440,11 +365,6 @@ PyOS_CheckStack() if ( &here < sentinel ) { if (thread_for_sentinel == PyThreadState_Get()) { return -1; -#if 0 - } else { - /* Else we are unsure... */ - fprintf(stderr, "Stackcheck in other thread (was %x now %x)\n", thread_for_sentinel,PyThreadState_Get()); -#endif } } return 0; @@ -735,15 +655,7 @@ PyMac_InitMenuBar() static unsigned char about_sioux[] = "\pAbout SIOUX"; if ( sioux_mbar ) return; -#if 0 - /* This code does not seem to work anymore: apparently - ** we now always have a menubar (since MacOS9?). - ** So we simply always setup the Sioux menus here. - */ - if ( (sioux_mbar=GetMenuBar()) == NULL ) { -#else if ( (sioux_mbar=GetMenuBar()) == NULL || GetMenuHandle(SIOUX_APPLEID) == NULL) { -#endif /* Sioux menu not installed yet. Do so */ SIOUXSetupMenus(); if ( (sioux_mbar=GetMenuBar()) == NULL ) @@ -762,8 +674,6 @@ PyMac_InitMenuBar() void PyMac_RestoreMenuBar() { -#if 1 - /* This doesn't seem to work anymore? Or only for Carbon? */ MenuBarHandle curmenubar; curmenubar = GetMenuBar(); @@ -774,7 +684,6 @@ PyMac_RestoreMenuBar() PyMac_InitMenuBar(); DrawMenuBar(); } -#endif } void diff --git a/Mac/Python/macimport.c b/Mac/Python/macimport.c index 49d1b14..cc562f1 100644 --- a/Mac/Python/macimport.c +++ b/Mac/Python/macimport.c @@ -35,24 +35,9 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#if 0 -#include /* for Set(Current)A5 */ -#include -#include -#include -#include -#include -#include -#include -#include -#endif #include #include -#ifdef USE_GUSI1 -#include "TFileSpec.h" /* for Path2FSSpec() */ -#endif - typedef void (*dl_funcptr)(); #define FUNCNAME_PATTERN "init%.200s" @@ -82,7 +67,6 @@ findnamedresource( int ok; Handle h; -#ifdef INTERN_STRINGS /* ** If we have interning find_module takes care of interning all ** sys.path components. We then keep a record of all sys.path @@ -100,16 +84,9 @@ findnamedresource( if ( obj == not_a_file[i] ) return 0; } -#endif /* INTERN_STRINGS */ -#ifdef USE_GUSI1 - if ( Path2FSSpec(filename, &fss) != noErr ) { -#else if ( FSMakeFSSpec(0, 0, Pstring(filename), &fss) != noErr ) { -#endif -#ifdef INTERN_STRINGS if ( obj && max_not_a_file < MAXPATHCOMPONENTS && obj->ob_sinterned ) not_a_file[max_not_a_file++] = obj; -#endif /* INTERN_STRINGS */ /* doesn't exist or is folder */ return 0; } @@ -123,14 +100,12 @@ findnamedresource( UseResFile(PyMac_AppRefNum); filerh = -1; } else { -#ifdef INTERN_STRINGS if ( FSpGetFInfo(&fss, &finfo) != noErr ) { if ( obj && max_not_a_file < MAXPATHCOMPONENTS && obj->ob_sinterned ) not_a_file[max_not_a_file++] = obj; /* doesn't exist or is folder */ return 0; } -#endif /* INTERN_STRINGS */ oldrh = CurResFile(); filerh = FSpOpenResFile(&fss, fsRdPerm); if ( filerh == -1 ) @@ -270,14 +245,12 @@ PyMac_LoadCodeResourceModule(name, pathname) "dynamic module not initialized properly"); return NULL; } -#if 1 /* Remember the filename as the __file__ attribute */ d = PyModule_GetDict(m); s = PyString_FromString(pathname); if (s == NULL || PyDict_SetItemString(d, "__file__", s) != 0) PyErr_Clear(); /* Not important enough to report */ Py_XDECREF(s); -#endif if (Py_VerboseFlag) PySys_WriteStderr("import %s # pyd fragment %#s loaded from %s\n", name, fragmentname, pathname); @@ -301,12 +274,7 @@ char *filename; PyObject *m, *co; long num, size; -#ifdef USE_GUSI1 - if ( (err=Path2FSSpec(filename, &fss)) != noErr || - FSpGetFInfo(&fss, &finfo) != noErr ) -#else if ( (err=FSMakeFSSpec(0, 0, Pstring(filename), &fss)) != noErr ) -#endif goto error; if ( fssequal(&fss, &PyMac_ApplicationFSSpec) ) { /* @@ -423,9 +391,6 @@ PyMac_FindModuleExtension(char *buf, size_t *lenp, char *module) unsigned char fnbuf[64]; int modnamelen = strlen(module); FSSpec fss; -#ifdef USE_GUSI1 - FInfo finfo; -#endif short refnum; long dirid; @@ -438,14 +403,8 @@ PyMac_FindModuleExtension(char *buf, size_t *lenp, char *module) return 0; strcpy(buf+*lenp, _PyImport_Filetab[0].suffix); -#ifdef USE_GUSI1 - if ( Path2FSSpec(buf, &fss) == noErr && - FSpGetFInfo(&fss, &finfo) == noErr) - return _PyImport_Filetab; -#else if ( FSMakeFSSpec(0, 0, Pstring(buf), &fss) == noErr ) return _PyImport_Filetab; -#endif /* ** We cannot check for fnfErr (unfortunately), it can mean either that ** the file doesn't exist (fine, we try others) or the path leading to it. diff --git a/Mac/Python/macmain.c b/Mac/Python/macmain.c index cb6b331..8b38a2c 100644 --- a/Mac/Python/macmain.c +++ b/Mac/Python/macmain.c @@ -45,10 +45,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #endif /* TARGET_API_MAC_CARBON */ -#ifdef USE_APPEARANCE #include #include -#endif /* USE_APPEARANCE */ #else #include #endif /* WITHOUT_FRAMEWORKS */ @@ -91,21 +89,6 @@ PyMac_PrefRecord PyMac_options; static void Py_Main(int, char **, char *); /* Forward */ void PyMac_Exit(int); /* Forward */ -static void init_appearance(void) -{ -#ifdef USE_APPEARANCE - OSErr err; - SInt32 response; - - err = Gestalt(gestaltAppearanceAttr,&response); - if ( err ) goto no_appearance; - if ( !(response&(1<