[Python-checkins] python/dist/src/Mac/Python macgetargv.c,1.26,1.27 macgetcompiler.c,1.18,1.19 macgetpath.c,1.27,1.28 macglue.c,1.112,1.113 macmain.c,1.79,1.80 pyGUSISIOUX.cp,1.4,1.5
jackjansen@users.sourceforge.net
jackjansen@users.sourceforge.net
Thu, 12 Dec 2002 02:31:56 -0800
Update of /cvsroot/python/python/dist/src/Mac/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv21368/Python
Modified Files:
macgetargv.c macgetcompiler.c macgetpath.c macglue.c macmain.c
pyGUSISIOUX.cp
Log Message:
Getting rid of pre-Carbon (MacOS8) support. All code depending on
TARGET_API_MAC_OS8 (or !TARGET_API_MAC_CARBON) is gone. Also some
TARGET_API_MAC_OSX conditional code is gone, because it is no longer
used on OSX-only Python (only in MacPython-OS9).
Index: macgetargv.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Python/macgetargv.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** macgetargv.c 10 Sep 2001 22:00:39 -0000 1.26
--- macgetargv.c 12 Dec 2002 10:31:53 -0000 1.27
***************
*** 55,63 ****
#include "macglue.h"
- #ifdef TARGET_API_MAC_OSX
- #define PATHNAMELEN 1024
- #else
#define PATHNAMELEN 256
- #endif
static int arg_count;
--- 55,59 ----
***************
*** 80,85 ****
#endif
-
- #if !TARGET_API_MAC_OSX
/* Initialize FSSpec and full name of current application */
--- 76,79 ----
***************
*** 105,109 ****
return 0;
}
- #endif /* !TARGET_API_MAC_OSX */
/* Check that there aren't any args remaining in the event */
--- 99,102 ----
***************
*** 230,236 ****
got_one = 0;
for (n = 0; n < 100 && !got_one; n++) {
- #if !TARGET_API_MAC_CARBON
- SystemTask();
- #endif
ok = GetNextEvent(everyEvent, &event);
if (ok && event.what == kHighLevelEvent) {
--- 223,226 ----
***************
*** 246,256 ****
{
arg_count = 0;
- #if TARGET_API_MAC_OSX
- /* In an OSX bundle argv[0] is okay */
- arg_count++;
- #else
(void)PyMac_init_process_location();
arg_vector[arg_count++] = strdup(PyMac_ApplicationPath);
- #endif /* TARGET_API_MAC_OSX */
if( !noevents ) {
--- 236,241 ----
Index: macgetcompiler.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Python/macgetcompiler.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** macgetcompiler.c 7 Jul 2002 20:54:44 -0000 1.18
--- macgetcompiler.c 12 Dec 2002 10:31:54 -0000 1.19
***************
*** 48,58 ****
#endif
! #if TARGET_API_MAC_CARBON
! #define TARGET_API ""
! #else
! #define TARGET_API " PPC"
! #endif
!
! #define COMPILER " [CW" TARGET_API HASGUSI HASTHREAD"]"
#endif
--- 48,52 ----
#endif
! #define COMPILER " [CW" HASGUSI HASTHREAD"]"
#endif
Index: macgetpath.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Python/macgetpath.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** macgetpath.c 17 Jul 2002 16:30:35 -0000 1.27
--- macgetpath.c 12 Dec 2002 10:31:54 -0000 1.28
***************
*** 39,47 ****
#endif
- #ifdef TARGET_API_MAC_OSX
- #define PATHNAMELEN 1024
- #else
#define PATHNAMELEN 256
- #endif
/* Return the initial python search path. This is called once from
--- 39,43 ----
Index: macglue.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Python/macglue.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -C2 -d -r1.112 -r1.113
*** macglue.c 26 Jun 2002 20:37:40 -0000 1.112
--- macglue.c 12 Dec 2002 10:31:54 -0000 1.113
***************
*** 52,60 ****
#endif
- #if !TARGET_API_MAC_OS8
- /* Unfortunately this call is probably slower... */
- #define LMGetTicks() TickCount()
- #endif
-
#ifdef __MWERKS__
#include <SIOUX.h>
--- 52,55 ----
***************
*** 86,90 ****
#endif
- #if TARGET_API_MAC_CARBON
/*
** On MacOSX StackSpace() lies: it gives the distance from heap end to stack pointer,
--- 81,84 ----
***************
*** 94,98 ****
*/
#define MAXIMUM_STACK_SIZE (256*1024)
- #endif
/*
--- 88,91 ----
***************
*** 149,169 ****
/*
- ** Some stuff for our GetDirectory and PromptGetFile routines
- */
- struct hook_args {
- int selectcur_hit; /* Set to true when "select current" selected */
- char *prompt; /* The prompt */
- };
- #if !TARGET_API_MAC_OS8
- /* The StandardFile hooks don't exist in Carbon. This breaks GetDirectory,
- ** but the macfsn code will replace it by a NavServices version anyway.
- */
- #define myhook_upp NULL
- #else
- static DlgHookYDUPP myhook_upp;
- static int upp_inited = 0;
- #endif
-
- /*
** The python-code event handler
*/
--- 142,145 ----
***************
*** 257,302 ****
}
- #if TARGET_API_MAC_OS8
- /*
- ** Replacement routines for the PLstr... functions so we don't need
- ** StdCLib.
- */
- pascal void
- PLstrcpy(unsigned char *to, unsigned char *fr)
- {
- memcpy(to, fr, fr[0]+1);
- }
-
- pascal int
- PLstrcmp(unsigned char *s1, unsigned char *s2)
- {
- int res;
- int l = s1[0] < s2[0] ? s1[0] : s2[0];
-
- res = memcmp(s1+1, s2+1, l);
- if ( res != 0 )
- return res;
-
- if ( s1[0] < s2[0] )
- return -1;
- else if ( s1[0] > s2[0] )
- return 1;
- else
- return 0;
- }
-
- pascal unsigned char *
- PLstrrchr(unsigned char *str, unsigned char chr)
- {
- unsigned char *ptr = 0;
- unsigned char *p;
-
- for(p=str+1; p<str+str[0]; p++)
- if ( *p == chr )
- ptr = p;
- return ptr;
- }
-
- #endif /* TARGET_API_MAC_OS8 */
#endif /* USE_GUSI */
--- 233,236 ----
***************
*** 317,343 ****
}
- #if TARGET_API_MAC_OS8
- Point
- LMGetMouse(void)
- {
- return LMGetMouseLocation();
- }
-
- long LMGetExpandMem(void)
- {
- return 0;
- }
-
- void
- c2pstrcpy(unsigned char *dst, const char *src)
- {
- int len;
-
- len = strlen(src);
- if ( len > 255 ) len = 255;
- strncpy((char *)dst+1, src, len);
- dst[0] = len;
- }
- #endif /* TARGET_API_MAC_OS8 */
#ifdef USE_STACKCHECK
--- 251,254 ----
***************
*** 421,446 ****
int force;
{
- #if !TARGET_API_MAC_OS8
if ( interrupted || (!schedparams.check_interrupt && !force) )
return;
if ( CheckEventQueueForUserCancel() )
interrupted = 1;
- #else
- register EvQElPtr q;
-
- if ( interrupted || (!schedparams.check_interrupt && !force) || !PyMac_InForeground() )
- return;
- q = (EvQElPtr) LMGetEventQueue()->qHead;
-
- for (; q; q = (EvQElPtr)q->qLink) {
- if (q->evtQWhat == keyDown &&
- (char)q->evtQMessage == '.' &&
- (q->evtQModifiers & cmdKey) != 0) {
- FlushEvents(keyDownMask, 0);
- interrupted = 1;
- break;
- }
- }
- #endif
}
--- 332,339 ----
***************
*** 449,453 ****
{
if (schedparams.enabled) {
! if ( interrupted || (unsigned long)LMGetTicks() > schedparams.next_check ) {
scan_event_queue(0);
if (interrupted) {
--- 342,346 ----
{
if (schedparams.enabled) {
! if ( interrupted || (unsigned long)TickCount() > schedparams.next_check ) {
scan_event_queue(0);
if (interrupted) {
***************
*** 458,462 ****
if ( PyMac_Yield() < 0)
return -1;
! schedparams.next_check = (unsigned long)LMGetTicks()
+ schedparams.check_interval;
}
--- 351,355 ----
if ( PyMac_Yield() < 0)
return -1;
! schedparams.next_check = (unsigned long)TickCount()
+ schedparams.check_interval;
}
***************
*** 499,512 ****
EventRecord *evp;
{
- #if TARGET_API_MAC_OS8
- if ( evp->what == mouseDown ) {
- WindowPtr wp;
-
- if ( FindWindow(evp->where, &wp) == inSysWindow ) {
- SystemClick(evp, wp);
- return;
- }
- }
- #endif
#ifdef __MWERKS__
{
--- 392,395 ----
***************
*** 569,580 ****
(python_event_handler && !maycallpython) ) {
if ( maxsleep >= 0 ) {
! #if TARGET_API_MAC_OS8
! SystemTask();
! #else
! int xxx = 0;
! #endif
}
} else {
! latest_time_ready = LMGetTicks() + maxsleep;
do {
/* XXXX Hack by Jack.
--- 452,459 ----
(python_event_handler && !maycallpython) ) {
if ( maxsleep >= 0 ) {
! /* XXXX Need to do something here */
}
} else {
! latest_time_ready = TickCount() + maxsleep;
do {
/* XXXX Hack by Jack.
***************
*** 591,595 ****
return -1;
}
! maxsleep = latest_time_ready - LMGetTicks();
} while ( maxsleep > 0 );
}
--- 470,474 ----
return -1;
}
! maxsleep = latest_time_ready - TickCount();
} while ( maxsleep > 0 );
}
***************
*** 731,811 ****
#endif /* !TARGET_API_MAC_OSX */
-
- #if TARGET_API_MAC_OS8
- /*
- ** Helper routine for GetDirectory
- */
- static pascal short
- myhook_proc(short item, DialogPtr theDialog, struct hook_args *dataptr)
- {
- if ( item == sfHookFirstCall && dataptr->prompt) {
- Handle prompth;
- short type;
- Rect rect;
-
- GetDialogItem(theDialog, PROMPT_ITEM, &type, &prompth, &rect);
- if ( prompth )
- SetDialogItemText(prompth, (unsigned char *)dataptr->prompt);
- } else
- if ( item == SELECTCUR_ITEM ) {
- item = sfItemCancelButton;
- dataptr->selectcur_hit = 1;
- }
- return item;
- }
-
- /*
- ** Ask the user for a directory. I still can't understand
- ** why Apple doesn't provide a standard solution for this...
- */
- int
- PyMac_GetDirectory(dirfss, prompt)
- FSSpec *dirfss;
- char *prompt;
- {
- static SFTypeList list = {'fldr', 0, 0, 0};
- static Point where = {-1, -1};
- StandardFileReply reply;
- struct hook_args hook_args;
-
- if ( !upp_inited ) {
- myhook_upp = NewDlgHookYDProc(myhook_proc);
- upp_inited = 1;
- }
- if ( prompt && *prompt )
- hook_args.prompt = (char *)Pstring(prompt);
- else
- hook_args.prompt = NULL;
- hook_args.selectcur_hit = 0;
- CustomGetFile((FileFilterYDUPP)0, 1, list, &reply, GETDIR_ID, where, myhook_upp,
- NULL, NULL, NULL, (void *)&hook_args);
-
- reply.sfFile.name[0] = 0;
- if( FSMakeFSSpec(reply.sfFile.vRefNum, reply.sfFile.parID, reply.sfFile.name, dirfss) )
- return 0;
- return hook_args.selectcur_hit;
- }
-
- /*
- ** Slightly extended StandardGetFile: accepts a prompt */
- void PyMac_PromptGetFile(short numTypes, ConstSFTypeListPtr typeList,
- StandardFileReply *reply, char *prompt)
- {
- static Point where = {-1, -1};
- struct hook_args hook_args;
-
- if ( !upp_inited ) {
- myhook_upp = NewDlgHookYDProc(myhook_proc);
- upp_inited = 1;
- }
- if ( prompt && *prompt )
- hook_args.prompt = (char *)Pstring(prompt);
- else
- hook_args.prompt = NULL;
- hook_args.selectcur_hit = 0;
- CustomGetFile((FileFilterYDUPP)0, numTypes, typeList, reply, GETFILEPROMPT_ID, where,
- myhook_upp, NULL, NULL, NULL, (void *)&hook_args);
- }
- #endif /* TARGET_API_MAC_OS8 */
-
-
--- 610,611 ----
Index: macmain.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Python/macmain.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -C2 -d -r1.79 -r1.80
*** macmain.c 5 Aug 2002 14:13:31 -0000 1.79
--- macmain.c 12 Dec 2002 10:31:54 -0000 1.80
***************
*** 39,43 ****
#include <Fonts.h>
#include <Balloons.h>
- #if TARGET_API_MAC_CARBON
#include <CFBundle.h>
#include <CFURL.h>
--- 39,42 ----
***************
*** 45,49 ****
#include <CFBase.h>
#include <CFArray.h>
- #endif /* TARGET_API_MAC_CARBON */
#include <Gestalt.h>
#include <Appearance.h>
--- 44,47 ----
***************
*** 95,108 ****
init_mac_world(void)
{
- #if !TARGET_API_MAC_CARBON
- /* These aren't needed for carbon */
- MaxApplZone();
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- TEInit();
- InitDialogs((long)0);
- InitMenus();
- #endif
InitCursor();
}
--- 93,96 ----
***************
*** 177,186 ****
exit(0);
}
- #if !TARGET_API_MAC_CARBON
- if ( item == OPT_HELP ) {
- HMSetBalloons(!HMGetBalloons());
- }
- #endif
- #if !TARGET_API_MAC_OSX
if ( item == OPT_CMDLINE ) {
int old_argc = *argcp;
--- 165,168 ----
***************
*** 203,207 ****
/* XXXX Is it not safe to use free() here, apparently */
}
- #endif /* !TARGET_API_MAC_OSX */
#define OPT_ITEM(num, var) \
if ( item == (num) ) { \
--- 185,188 ----
***************
*** 280,286 ****
PyMac_options.keep_console = POPT_KEEPCONSOLE_OUTPUT; /* default-default */
PyMac_options.unixnewlines = 1;
- #if !TARGET_API_MAC_OSX
PyMac_PreferenceOptions(&PyMac_options);
- #endif
if ( embedded ) {
--- 261,265 ----
***************
*** 294,302 ****
** command line arguments.
*/
- #if TARGET_API_MAC_OSX
- if (*argcp == 2 && strncmp((*argvp)[1], "-psn_", 5) == 0)
- #endif
*argcp = PyMac_GetArgv(argvp, PyMac_options.noargs);
- #if !TARGET_API_MAC_OSX
#ifndef NO_ARGV0_CHDIR
if (*argcp >= 1 && (*argvp)[0] && (*argvp)[0][0]) {
--- 273,277 ----
***************
*** 312,316 ****
}
#endif
- #endif
/* Do interactive option setting, if allowed and <option> depressed */
PyMac_InteractiveOptions(&PyMac_options, argcp, argvp);
--- 287,290 ----
***************
*** 325,329 ****
Py_TabcheckFlag = PyMac_options.tabwarn;
Py_DivisionWarningFlag = PyMac_options.divisionwarn;
- #if !TARGET_API_MAC_OSX
if ( PyMac_options.noargs ) {
/* don't process events at all without the scripts permission */
--- 299,302 ----
***************
*** 335,339 ****
PyMac_SetSchedParams(&scp);
}
- #endif /* !TARGET_API_MAC_OSX */
/* Set buffering */
--- 308,311 ----
***************
*** 447,547 ****
#endif /* USE_MAC_APPLET_SUPPORT */
- #if TARGET_API_MAC_OSX /* Really: TARGET_API_MAC_CARBON */
-
- static int
- locateResourcePy(CFStringRef resourceType, char *resourceName, char *resourceURLCStr, int length)
- {
- CFBundleRef mainBundle = NULL;
- CFURLRef URL, absoluteURL;
- CFStringRef filenameString, filepathString, rsrcString;
- CFIndex size, i;
- CFArrayRef arrayRef = NULL;
- int success = 0;
-
- #if TARGET_API_MAC_OSX
- CFURLPathStyle thePathStyle = kCFURLPOSIXPathStyle;
- #else
- CFURLPathStyle thePathStyle = kCFURLHFSPathStyle;
- #endif
-
- /* Get a reference to our main bundle */
- mainBundle = CFBundleGetMainBundle();
-
- /* If we are running inside a bundle, look through it. Otherwise, do nothing. */
- if (mainBundle) {
- /* Create a CFString with the resource name in it */
- rsrcString = CFStringCreateWithCString(0, resourceName, kCFStringEncodingMacRoman);
-
- /* Look for py files in the main bundle by type */
- arrayRef = CFBundleCopyResourceURLsOfType( mainBundle,
- resourceType,
- NULL );
-
- /* See if there are any filename matches */
- size = CFArrayGetCount(arrayRef);
- for (i = 0; i < size; i++) {
- URL = CFArrayGetValueAtIndex(arrayRef, i);
- filenameString = CFURLCopyLastPathComponent(URL);
- if (CFStringCompare(filenameString, rsrcString, 0) == kCFCompareEqualTo) {
- /* We found a match, get the file's full path */
- absoluteURL = CFURLCopyAbsoluteURL(URL);
- filepathString = CFURLCopyFileSystemPath(absoluteURL, thePathStyle);
- CFRelease(absoluteURL);
-
- /* Copy the full path into the caller's character buffer */
- success = CFStringGetCString(filepathString, resourceURLCStr, length,
- kCFStringEncodingMacRoman);
-
- CFRelease(filepathString);
- }
- CFRelease(filenameString);
- }
- CFRelease(arrayRef);
- CFRelease(rsrcString);
- }
- return success;
- }
-
- #endif /* TARGET_API_MAC_CARBON */
-
- #if TARGET_API_MAC_OSX
-
- int
- main(int argc, char **argv)
- {
- static char scriptpath[1024];
- char *script = NULL;
-
- /* First we see whether we have __rawmain__.py and run that if it
- ** is there
- */
- if (locateResourcePy(CFSTR("py"), "__rawmain__.py", scriptpath, 1024)) {
- /* If we have a raw main we don't do AppleEvent processing.
- ** Notice that this also means we keep the -psn.... argv[1]
- ** value intact. Not sure whether that is important to someone,
- ** but you never know...
- */
- script = scriptpath;
- } else if (locateResourcePy(CFSTR("pyc"), "__rawmain__.pyc", scriptpath, 1024)) {
- script = scriptpath;
- } else {
- /* Otherwise we look for __main__.py. Whether that is
- ** found or not we also process AppleEvent arguments.
- */
- if (locateResourcePy(CFSTR("py"), "__main__.py", scriptpath, 1024))
- script = scriptpath;
- else if (locateResourcePy(CFSTR("pyc"), "__main__.pyc", scriptpath, 1024))
- script = scriptpath;
-
- init_common(&argc, &argv, 0);
-
- }
-
- PyMac_Main(argc, argv, script);
- return 0;
- }
-
- #else
-
/* For normal application */
void
--- 419,422 ----
***************
*** 557,566 ****
init_common(&argc, &argv, 0);
- #if TARGET_API_MAC_OSX /* Really: TARGET_API_MAC_CARBON */
- /* If we are running inside of a bundle, and a __main__.py is available, use it */
- if (locateResourcePy("__main__.py", scriptpath, 1024))
- script = scriptpath;
- #endif
-
if ( argc > 1 ) {
/* We're running a script. Attempt to change current directory */
--- 432,435 ----
***************
*** 583,587 ****
PyMac_Main(argc, argv, script);
}
- #endif /* TARGET_API_MAC_OSX */
/* Main program */
--- 452,455 ----
***************
*** 606,614 ****
(command == NULL && filename == NULL && isatty((int)fileno(fp))))
fprintf(stderr, "%s %s on %s\n%s\n",
- #if !TARGET_API_MAC_OSX
"Python",
- #else
- "Pythonw",
- #endif
Py_GetVersion(), Py_GetPlatform(), COPYRIGHT);
--- 474,478 ----
***************
*** 621,628 ****
}
- #if !TARGET_API_MAC_OSX
/* We initialize the menubar here, hoping SIOUX is initialized by now */
PyMac_InitMenuBar();
- #endif
Py_Initialize();
--- 485,490 ----
***************
*** 652,656 ****
}
- #if !TARGET_API_MAC_OSX
/*
** Reset the "unseen output" flag
--- 514,517 ----
***************
*** 684,688 ****
PyMac_Exit(1);
}
- #endif /* !TARGET_API_MAC_OSX */
/*
--- 545,548 ----
***************
*** 740,744 ****
}
- #if !TARGET_API_MAC_OSX
/* Make the *original* argc/argv available to other modules.
This is rare, but it is needed by the secureware extension. */
--- 600,603 ----
***************
*** 750,757 ****
*argv = orig_argv;
}
- #endif
/* More cruft that shouldn't really be here, used in sysmodule.c */
- #if !TARGET_API_MAC_OSX
/* Return the program name -- some code out there needs this. */
char *
--- 609,614 ----
***************
*** 797,800 ****
}
#endif /* WITHOUT_UNIX_NEWLINES */
- #endif /* !TARGET_API_MAC_OSX */
--- 654,656 ----
Index: pyGUSISIOUX.cp
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Python/pyGUSISIOUX.cp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** pyGUSISIOUX.cp 11 Jan 2002 10:24:23 -0000 1.4
--- pyGUSISIOUX.cp 12 Dec 2002 10:31:54 -0000 1.5
***************
*** 175,191 ****
static bool input_pending()
{
- #if !TARGET_API_MAC_CARBON
- // Jack thinks that completely removing this code is a bit
- // too much...
- QHdrPtr eventQueue = LMGetEventQueue();
- EvQElPtr element = (EvQElPtr)eventQueue->qHead;
-
- // now, count the number of pending keyDown events.
- while (element != nil) {
- if (element->evtQWhat == keyDown || element->evtQWhat == autoKey)
- return true;
- element = (EvQElPtr)element->qLink;
- }
- #endif
return false;
}
--- 175,178 ----