From b1df03adc71d7f8d530f49b8e0406b5151fb0609 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 24 Jul 2013 10:54:55 -0400 Subject: [PATCH] Fix for old runtimes. --- OpenChange/BSONCodec.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenChange/BSONCodec.m b/OpenChange/BSONCodec.m index 518900ba2..58625a59f 100644 --- a/OpenChange/BSONCodec.m +++ b/OpenChange/BSONCodec.m @@ -85,13 +85,17 @@ static NSDictionary *BSONTypes() @implementation NSObject (BSONObjectCoding) - (NSData *) BSONEncode { - if (!class_conformsToProtocol([self class], @protocol(BSONObjectCoding))) + if (![self conformsToProtocol: @protocol(BSONObjectCoding)]) [NSException raise: NSInvalidArgumentException format: @"BSON encoding is only valid on objects conforming to the BSONObjectEncoding protocol."]; id myself = (id ) self; NSMutableDictionary *values = [[myself BSONDictionary] mutableCopy]; +#if (defined(__GNU_LIBOBJC__) && (__GNU_LIBOBJC__ >= 20100911)) || defined(APPLE_RUNTIME) || defined(__GNUSTEP_RUNTIME__) const char* className = class_getName([self class]); +#else + const char* className = [self class]->name; +#endif [values setObject: [NSData dataWithBytes: (void *)className length: strlen(className)] forKey: CLASS_NAME_MARKER]; NSData *retval = [values BSONEncode]; [values release];