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

Skip to content

Commit 6e68a7e

Browse files
committed
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
1 parent 1bd0a71 commit 6e68a7e

4 files changed

Lines changed: 26 additions & 23 deletions

File tree

Mac/Include/macglue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ int PyMac_FindCodeResourceModule(PyStringObject *, char *, char *); /* Test for
8484
PyObject * PyMac_LoadCodeResourceModule(char *, char *); /* Load 'PYD ' resource from file */
8585
struct filedescr *PyMac_FindModuleExtension(char *, size_t *, char *); /* Look for module in single folder */
8686

87-
#if !TARGET_API_MAC_CARBON
87+
#if TARGET_API_MAC_OS8
8888
int PyMac_GetDirectory(FSSpec *dirfss, char *prompt); /* Ask user for a directory */
8989
void PyMac_PromptGetFile(short numTypes, ConstSFTypeListPtr typeList,
9090
StandardFileReply *reply, char *prompt); /* Ask user for file, with prompt */
91-
#endif /* TARGET_API_MAC_CARBON */
91+
#endif /* TARGET_API_MAC_OS8 */
9292

9393
int PyMac_GetOSType(PyObject *, OSType *); /* argument parser for OSType */
9494
PyObject *PyMac_BuildOSType(OSType); /* Convert OSType to PyObject */

Mac/Modules/macmodule.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3131
#include <string.h>
3232
#include <errno.h>
3333

34-
#if !TARGET_API_MAC_CARBON
34+
#if TARGET_API_MAC_OS8
3535
/* Skip for Carbon */
3636
#include "macstat.h"
3737
#endif
@@ -51,7 +51,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5151
#include <sys/types.h>
5252
#include <sys/stat.h>
5353
#else /* USE_GUSI */
54-
#if !TARGET_API_MAC_CARBON
54+
#if TARGET_API_MAC_OS8
5555
#define stat macstat
5656
#endif
5757
#endif /* USE_GUSI */
@@ -259,7 +259,7 @@ mac_fdopen(self, args)
259259
}
260260
#endif
261261

262-
#if !TARGET_API_MAC_CARBON
262+
#if TARGET_API_MAC_OS8
263263
static PyObject *
264264
mac_getbootvol(self, args)
265265
PyObject *self;
@@ -499,7 +499,7 @@ mac_fstat(self, args)
499499
}
500500
#endif /* WEHAVE_FSTAT */
501501

502-
#if !TARGET_API_MAC_CARBON
502+
#if TARGET_API_MAC_OS8
503503
static PyObject *
504504
mac_xstat(self, args)
505505
PyObject *self;
@@ -611,7 +611,7 @@ static struct PyMethodDef mac_methods[] = {
611611
#ifdef WEHAVE_FSTAT
612612
{"fstat", mac_fstat},
613613
#endif
614-
#if !TARGET_API_MAC_CARBON
614+
#if TARGET_API_MAC_OS8
615615
{"getbootvol", mac_getbootvol}, /* non-standard */
616616
#endif
617617
{"getcwd", mac_getcwd},
@@ -623,7 +623,7 @@ static struct PyMethodDef mac_methods[] = {
623623
{"rename", mac_rename},
624624
{"rmdir", mac_rmdir},
625625
{"stat", mac_stat},
626-
#if !TARGET_API_MAC_CARBON
626+
#if TARGET_API_MAC_OS8
627627
{"xstat", mac_xstat},
628628
#endif
629629
{"sync", mac_sync},

Mac/Modules/macosmodule.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ MacOS_SetCreatorAndType(PyObject *self, PyObject *args)
360360
#include <EPPC.h>
361361
#include <Events.h>
362362

363-
#if !TARGET_API_MAC_CARBON
363+
#if TARGET_API_MAC_OS8
364364
static char accepthle_doc[] = "Get arguments of pending high-level event";
365365

366366
static PyObject *
@@ -704,7 +704,7 @@ MacOS_OutputSeen(PyObject *self, PyObject *args)
704704
}
705705

706706
static PyMethodDef MacOS_Methods[] = {
707-
#if !TARGET_API_MAC_CARBON
707+
#if TARGET_API_MAC_OS8
708708
{"AcceptHighLevelEvent", MacOS_AcceptHighLevelEvent, 1, accepthle_doc},
709709
#endif
710710
{"GetCreatorAndType", MacOS_GetCreatorAndType, 1, getcrtp_doc},
@@ -760,10 +760,13 @@ initMacOS()
760760
Py_BuildValue("i", PyMac_AppearanceCompliant)) != 0)
761761
return;
762762
#if TARGET_API_MAC_CARBON
763-
/* Will need a different name for MachO-carbon later (macho?) */
764763
#define PY_RUNTIMEMODEL "carbon"
765-
#else
764+
#elif TARGET_API_MAC_OS8
766765
#define PY_RUNTIMEMODEL "ppc"
766+
#elif TARGET_API_MAC_OSX
767+
#define PY_RUNTIMEMODEL "macho"
768+
#else
769+
#error "None of the TARGET_API_MAC_XXX I know about is set"
767770
#endif
768771
if (PyDict_SetItemString(d, "runtimemodel",
769772
Py_BuildValue("s", PY_RUNTIMEMODEL)) != 0)

Mac/Python/macglue.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3232

3333
#include <Events.h>
3434

35-
#if TARGET_API_MAC_CARBON
35+
#if !TARGET_API_MAC_OS8
3636
/* Unfortunately this call is probably slower... */
3737
#define LMGetTicks() TickCount()
3838
#endif
@@ -171,7 +171,7 @@ struct hook_args {
171171
int selectcur_hit; /* Set to true when "select current" selected */
172172
char *prompt; /* The prompt */
173173
};
174-
#if TARGET_API_MAC_CARBON
174+
#if !TARGET_API_MAC_OS8
175175
/* The StandardFile hooks don't exist in Carbon. This breaks GetDirectory,
176176
** but the macfsn code will replace it by a NavServices version anyway.
177177
*/
@@ -297,7 +297,7 @@ PyMac_StopGUSISpin() {
297297
PyMac_ConsoleIsDead = 1;
298298
}
299299

300-
#if !TARGET_API_MAC_CARBON
300+
#if TARGET_API_MAC_OS8
301301
/*
302302
** Replacement routines for the PLstr... functions so we don't need
303303
** StdCLib.
@@ -338,7 +338,7 @@ PLstrrchr(unsigned char *str, unsigned char chr)
338338
return ptr;
339339
}
340340

341-
#endif /* !TARGET_API_MAC_CARBON */
341+
#endif /* TARGET_API_MAC_OS8 */
342342
#endif /* USE_GUSI */
343343

344344

@@ -357,7 +357,7 @@ Pstring(char *str)
357357
return buf;
358358
}
359359

360-
#if !TARGET_API_MAC_CARBON
360+
#if TARGET_API_MAC_OS8
361361
void
362362
c2pstrcpy(unsigned char *dst, const char *src)
363363
{
@@ -368,7 +368,7 @@ c2pstrcpy(unsigned char *dst, const char *src)
368368
strncpy((char *)dst+1, src, len);
369369
dst[0] = len;
370370
}
371-
#endif /* !TARGET_API_MAC_CARBON */
371+
#endif /* TARGET_API_MAC_OS8 */
372372

373373
/* Like strerror() but for Mac OS error numbers */
374374
char *PyMac_StrError(int err)
@@ -498,7 +498,7 @@ static void
498498
scan_event_queue(flush)
499499
int flush;
500500
{
501-
#if TARGET_API_MAC_CARBON
501+
#if !TARGET_API_MAC_OS8
502502
if ( CheckEventQueueForUserCancel() )
503503
interrupted = 1;
504504
#else
@@ -608,7 +608,7 @@ void
608608
PyMac_HandleEventIntern(evp)
609609
EventRecord *evp;
610610
{
611-
#if !TARGET_API_MAC_CARBON
611+
#if TARGET_API_MAC_OS8
612612
if ( evp->what == mouseDown ) {
613613
WindowPtr wp;
614614

@@ -686,7 +686,7 @@ PyMac_DoYield(int maxsleep, int maycallpython)
686686
if( in_here > 1 || !schedparams.process_events ||
687687
(python_event_handler && !maycallpython) ) {
688688
if ( maxsleep >= 0 ) {
689-
#if !TARGET_API_MAC_CARBON
689+
#if TARGET_API_MAC_OS8
690690
SystemTask();
691691
#else
692692
int xxx = 0;
@@ -878,7 +878,7 @@ myhook_proc(short item, DialogPtr theDialog, struct hook_args *dataptr)
878878
}
879879
return item;
880880
}
881-
#if !TARGET_API_MAC_CARBON
881+
#if TARGET_API_MAC_OS8
882882
/*
883883
** Ask the user for a directory. I still can't understand
884884
** why Apple doesn't provide a standard solution for this...
@@ -931,7 +931,7 @@ void PyMac_PromptGetFile(short numTypes, ConstSFTypeListPtr typeList,
931931
CustomGetFile((FileFilterYDUPP)0, numTypes, typeList, reply, GETFILEPROMPT_ID, where,
932932
myhook_upp, NULL, NULL, NULL, (void *)&hook_args);
933933
}
934-
#endif /* TARGET_API_MAC_CARBON */
934+
#endif /* TARGET_API_MAC_OS8 */
935935

936936
/* Convert a 4-char string object argument to an OSType value */
937937
int

0 commit comments

Comments
 (0)