fix endian problems for intel macs
svn: r2529
This commit is contained in:
parent
a10c2acb13
commit
9fa38084b4
|
@ -1336,7 +1336,21 @@ static long check_four(char *name, int which, int argc, Scheme_Object **argv)
|
|||
if (!SCHEME_BYTE_STRINGP(o) || (SCHEME_BYTE_STRTAG_VAL(o) != 4))
|
||||
scheme_wrong_type(name, "MacOS type/creator 4-character byte string", which, argc, argv);
|
||||
|
||||
return *(long *)SCHEME_BYTE_STR_VAL(o);
|
||||
#ifdef __POWERPC__
|
||||
return *(int *)SCHEME_BYTE_STR_VAL(o);
|
||||
#else
|
||||
{
|
||||
int v;
|
||||
char tmp[4], *bs;
|
||||
bs = SCHEME_BYTE_STR_VAL(o);
|
||||
tmp[3] = bs[0];
|
||||
tmp[2] = bs[1];
|
||||
tmp[1] = bs[2];
|
||||
tmp[0] = bs[3];
|
||||
memcpy(&v, tmp, 4);
|
||||
return v;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int has_null(const char *s, long l)
|
||||
|
|
|
@ -276,7 +276,6 @@ int main(int argc, char *argv[])
|
|||
int rval;
|
||||
void *stack_start;
|
||||
|
||||
|
||||
stack_start = (void *)&stack_start;
|
||||
|
||||
#if defined(MZ_PRECISE_GC)
|
||||
|
|
|
@ -89,7 +89,8 @@ Bool wxCloseClipboard(void)
|
|||
|
||||
Bool wxEmptyClipboard(void)
|
||||
{
|
||||
ClearCurrentScrap();
|
||||
OSStatus err;
|
||||
err = ClearCurrentScrap();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -156,9 +157,8 @@ Bool wxSetClipboardData(int dataFormat, wxObject *obj, int width, int height)
|
|||
}
|
||||
|
||||
err = GetCurrentScrap(&scrap);
|
||||
if (err != noErr) {
|
||||
if (err != noErr)
|
||||
return FALSE;
|
||||
}
|
||||
err = PutScrapFlavor(scrap, format, kScrapFlavorMaskNone, length, (const void *)obj);
|
||||
return (err == noErr);
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ wxObject *wxGetClipboardData(int dataFormat, long *size)
|
|||
return (wxObject *)result;
|
||||
}
|
||||
|
||||
int wxEnumClipboardFormats(int dataFormat)
|
||||
int wxEnumClipboardFormats(int dataFormat)
|
||||
{
|
||||
long format;
|
||||
wxNode *node;
|
||||
|
@ -304,9 +304,19 @@ int wxEnumClipboardFormats(int dataFormat)
|
|||
|
||||
for (; node; node = node->Next()) {
|
||||
cf = (ClipboardFormat *)node->Data();
|
||||
#ifdef __POWERPC__
|
||||
memcpy(&format, cf->name, 4);
|
||||
#else
|
||||
{
|
||||
char tmp[4];
|
||||
tmp[3] = cf->name[0];
|
||||
tmp[2] = cf->name[1];
|
||||
tmp[1] = cf->name[2];
|
||||
tmp[0] = cf->name[3];
|
||||
memcpy(&format, tmp, 4);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
#ifdef WX_CARBON
|
||||
ScrapRef scrap;
|
||||
OSErr err;
|
||||
ScrapFlavorFlags dontcare;
|
||||
|
@ -314,18 +324,13 @@ int wxEnumClipboardFormats(int dataFormat)
|
|||
err = GetCurrentScrap(&scrap);
|
||||
if ((err != noErr)||(GetScrapFlavorFlags(scrap,format,&dontcare) != noErr))
|
||||
return cf->format;
|
||||
#else
|
||||
long offset;
|
||||
if (GetScrap(NULL, format, &offset) > 0)
|
||||
return cf->format;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxRegisterClipboardFormat(char *formatName)
|
||||
int wxRegisterClipboardFormat(char *formatName)
|
||||
{
|
||||
wxNode *node;
|
||||
ClipboardFormat *cf;
|
||||
|
@ -365,10 +370,17 @@ Bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount)
|
|||
for (node = ClipboardFormats->First(); node; node = node->Next()) {
|
||||
cf = (ClipboardFormat *)node->Data();
|
||||
if (cf->format == dataFormat) {
|
||||
#ifdef __POWERPC__
|
||||
formatName[0] = cf->name[0];
|
||||
formatName[1] = cf->name[1];
|
||||
formatName[2] = cf->name[2];
|
||||
formatName[3] = cf->name[3];
|
||||
#else
|
||||
formatName[3] = cf->name[0];
|
||||
formatName[2] = cf->name[1];
|
||||
formatName[1] = cf->name[2];
|
||||
formatName[0] = cf->name[3];
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,10 +158,15 @@ void wxCanvasDC::EndSetPixelFast()
|
|||
void wxCanvasDC::SetPixelFast(int i, int j, int r, int g, int b)
|
||||
{
|
||||
if (Colour) {
|
||||
UInt32 *p;
|
||||
UInt32 *p, pixval;
|
||||
|
||||
p = (UInt32 *)fast_pb;
|
||||
p[(j * (fast_rb >> 2)) + i] = ((r << 16) | (g << 8) | (b << 0));
|
||||
#ifdef __POWERPC__
|
||||
pixval = ((r << 16) | (g << 8) | (b << 0));
|
||||
#else
|
||||
pixval = ((r << 8) | (g << 16) | (b << 24));
|
||||
#endif
|
||||
p[(j * (fast_rb >> 2)) + i] = pixval;
|
||||
} else {
|
||||
unsigned char *p, v, bit;
|
||||
int pos;
|
||||
|
@ -229,9 +234,15 @@ void wxCanvasDC::GetPixelFast(int x, int y, int *r, int *g, int *b)
|
|||
|
||||
p = (UInt32 *)fast_pb;
|
||||
v = p[(y * (fast_rb >> 2)) + x];
|
||||
#ifdef __POWERPC__
|
||||
*r = (v >> 16) & 0xFF;
|
||||
*g = (v >> 8) & 0xFF;
|
||||
*b = v & 0xFF;
|
||||
#else
|
||||
*r = (v >> 8) & 0xFF;
|
||||
*g = (v >> 16) & 0xFF;
|
||||
*b = (v >> 24) & 0xFF;
|
||||
#endif
|
||||
} else {
|
||||
unsigned char *p, v, bit;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user