Hi,
just to get this going: please review and perhaps apply the attached patch.
Thanks and best regards,
Mathias
Am 20.01.14 18:07, schrieb David Chisnall:
This looks like a simple omission. It's fairly uncommon to use the C99 _Bool
type (for which bool is a typedef), rather than the Objective-C BOOL type, in
Objective-C code. It shouldn't be too difficult to fix, I think we just need
an extra case in a couple of switch statements.
David
On 19 Jan 2014, at 11:48, Mathias Bauer <[email protected]> wrote:
Hi,
the following simple program crashes because GSObjCSetVal in GSObjCRuntime.m
does not handle boolean values:
#import <Foundation/Foundation.h>
@interface TestObject : NSObject
@property (nonatomic, assign) bool switcher;
@end
@implementation TestObject
@end
int main(int argc, const char * argv[])
{
TestObject* test = [TestObject new];
[test setValue:[NSNumber numberWithBool:YES] forKey:@"switcher"];
return 0;
}
compiled with:
clang `gnustep-config --objc-flags` -x objective-c -fobjc-arc -std=gnu99
-fpascal-strings -fstrict-aliasing -lobjc -lgnustep-base `gnustep-config
--objc-libs` test.m
I think this is a serious defect. On my system the type that needed to be handled in
GSObjCSetVal would be "B16", but on other system this might be different.
I'm unsure about how a correct fix should be, so any opinions of people in the
know would be greatly appreciated.
Best regards,
Mathias
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Index: GSObjCRuntime.m
===================================================================
--- GSObjCRuntime.m (revision 37628)
+++ GSObjCRuntime.m (working copy)
@@ -1090,6 +1090,25 @@
}
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 @@
}
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];
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep