mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
patch by Mathias Bauer <mathias_bauer@gmx.net>
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37758 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
20d172dfbb
commit
74ddbe1517
3 changed files with 47 additions and 0 deletions
|
@ -6,6 +6,8 @@
|
|||
* Source/NSData.m:
|
||||
* Source/NSString.m:
|
||||
Fix for bug #41626
|
||||
* Source/Additions/GSObjCRuntime.m: patch by Mathias Bauer
|
||||
for bool encoding/decoding.
|
||||
|
||||
2014-03-11 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -1090,6 +1090,25 @@ GSObjCGetVal(NSObject *self, const char *key, SEL sel,
|
|||
}
|
||||
break;
|
||||
|
||||
case _C_BOOL:
|
||||
{
|
||||
bool v;
|
||||
|
||||
if (sel == 0)
|
||||
{
|
||||
v = *(bool *)((char *)self + offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool (*imp)(id, SEL) =
|
||||
(bool (*)(id, SEL))[self methodForSelector: sel];
|
||||
|
||||
v = (*imp)(self, sel);
|
||||
}
|
||||
val = [NSNumber numberWithBool: v];
|
||||
}
|
||||
break;
|
||||
|
||||
case _C_SHT:
|
||||
{
|
||||
short v;
|
||||
|
@ -1534,6 +1553,26 @@ GSObjCSetVal(NSObject *self, const char *key, id val, SEL sel,
|
|||
}
|
||||
break;
|
||||
|
||||
case _C_BOOL:
|
||||
{
|
||||
bool v = [val boolValue];
|
||||
|
||||
if (sel == 0)
|
||||
{
|
||||
bool *ptr = (bool*)((char *)self + offset);
|
||||
|
||||
*ptr = v;
|
||||
}
|
||||
else
|
||||
{
|
||||
void (*imp)(id, SEL, bool) =
|
||||
(void (*)(id, SEL, bool))[self methodForSelector: sel];
|
||||
|
||||
(*imp)(self, sel, v);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case _C_SHT:
|
||||
{
|
||||
short v = [val shortValue];
|
||||
|
|
|
@ -20,6 +20,7 @@ typedef struct {
|
|||
int num4;
|
||||
TestClass *child;
|
||||
myStruct s;
|
||||
bool b;
|
||||
}
|
||||
|
||||
- (void) setNum3:(int) num;
|
||||
|
@ -165,6 +166,7 @@ int main()
|
|||
UndefinedKey2 *undefinedKey2 = [[[UndefinedKey2 alloc] init] autorelease];
|
||||
|
||||
NSNumber *n = [NSNumber numberWithInt:8];
|
||||
NSNumber *nb = [NSNumber numberWithBool:1];
|
||||
NSNumber *adjustedN = [NSNumber numberWithInt:7];
|
||||
NSNumber *n2 = [NSNumber numberWithDouble:87.999];
|
||||
|
||||
|
@ -181,6 +183,10 @@ int main()
|
|||
PASS(rc + 1 == [m retainCount], "KVC retains object values");
|
||||
}
|
||||
|
||||
[tester setValue:nb forKey: @"b"];
|
||||
PASS([[tester valueForKey: @"b"] isEqualToNumber:nb],
|
||||
"KVC works with bool");
|
||||
|
||||
[tester setValue:n forKey: @"num1"];
|
||||
PASS([[tester valueForKey: @"num1"] isEqualToNumber:n],
|
||||
"KVC works with ints");
|
||||
|
|
Loading…
Reference in a new issue