Attempt fix for #22277

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26114 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2008-02-20 15:14:48 +00:00
parent fa23e252b3
commit 9c1da2872f
2 changed files with 163 additions and 0 deletions

View file

@ -1,3 +1,8 @@
2008-02-20 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additiuons/GSObjCRuntime.m: Add support for NSPoint, NSRange,
NSSize and NSRect for bug #22277
2008-02-20 Richard Frith-Macdonald <rfm@gnu.org>
* configure.ac: Add convoluted checks to cope with interdependency

View file

@ -1760,6 +1760,82 @@ GSObjCGetVal(NSObject *self, const char *key, SEL sel,
val = nil;
break;
case _C_STRUCT_B:
if (strcmp(@encode(NSPoint), type) == 0)
{
NSPoint v;
if (sel == 0)
{
memcpy((char*)&v, ((char *)self + offset), sizeof(v));
}
else
{
NSPoint (*imp)(id, SEL) =
(NSPoint (*)(id, SEL))[self methodForSelector: sel];
v = (*imp)(self, sel);
}
val = [NSValue valueWithPoint: v];
}
else if (strcmp(@encode(NSRange), type) == 0)
{
NSRange v;
if (sel == 0)
{
memcpy((char*)&v, ((char *)self + offset), sizeof(v));
}
else
{
NSRange (*imp)(id, SEL) =
(NSRange (*)(id, SEL))[self methodForSelector: sel];
v = (*imp)(self, sel);
}
val = [NSValue valueWithRange: v];
}
else if (strcmp(@encode(NSRect), type) == 0)
{
NSRect v;
if (sel == 0)
{
memcpy((char*)&v, ((char *)self + offset), sizeof(v));
}
else
{
NSRect (*imp)(id, SEL) =
(NSRect (*)(id, SEL))[self methodForSelector: sel];
v = (*imp)(self, sel);
}
val = [NSValue valueWithRect: v];
}
else if (strcmp(@encode(NSSize), type) == 0)
{
NSSize v;
if (sel == 0)
{
memcpy((char*)&v, ((char *)self + offset), sizeof(v));
}
else
{
NSSize (*imp)(id, SEL) =
(NSSize (*)(id, SEL))[self methodForSelector: sel];
v = (*imp)(self, sel);
}
val = [NSValue valueWithSize: v];
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"key-value get method unsupported struct"];
}
break;
default:
[NSException raise: NSInvalidArgumentException
format: @"key-value get method has unsupported type"];
@ -1767,6 +1843,7 @@ GSObjCGetVal(NSObject *self, const char *key, SEL sel,
return val;
}
}
/**
* Calls GSObjCGetVal()
*/
@ -2093,12 +2170,93 @@ GSObjCSetVal(NSObject *self, const char *key, id val, SEL sel,
}
break;
case _C_STRUCT_B:
if (strcmp(@encode(NSPoint), type) == 0)
{
NSPoint v = [val pointValue];
if (sel == 0)
{
NSPoint *ptr = (NSPoint*)((char *)self + offset);
*ptr = v;
}
else
{
void (*imp)(id, SEL, NSPoint) =
(void (*)(id, SEL, NSPoint))[self methodForSelector: sel];
(*imp)(self, sel, v);
}
}
else if (strcmp(@encode(NSRange), type) == 0)
{
NSRange v = [val rangeValue];
if (sel == 0)
{
NSRange *ptr = (NSRange*)((char *)self + offset);
*ptr = v;
}
else
{
void (*imp)(id, SEL, NSRange) =
(void (*)(id, SEL, NSRange))[self methodForSelector: sel];
(*imp)(self, sel, v);
}
}
else if (strcmp(@encode(NSRect), type) == 0)
{
NSRect v = [val rectValue];
if (sel == 0)
{
NSRect *ptr = (NSRect*)((char *)self + offset);
*ptr = v;
}
else
{
void (*imp)(id, SEL, NSRect) =
(void (*)(id, SEL, NSRect))[self methodForSelector: sel];
(*imp)(self, sel, v);
}
}
else if (strcmp(@encode(NSSize), type) == 0)
{
NSSize v = [val sizeValue];
if (sel == 0)
{
NSSize *ptr = (NSSize*)((char *)self + offset);
*ptr = v;
}
else
{
void (*imp)(id, SEL, NSSize) =
(void (*)(id, SEL, NSSize))[self methodForSelector: sel];
(*imp)(self, sel, v);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"key-value set method unsupported struct"];
}
break;
default:
[NSException raise: NSInvalidArgumentException
format: @"key-value set method has unsupported type"];
}
}
}
/**
* Calls GSObjCSetVal()
*/