On Mon, Aug 29, 2011 at 5:17 PM, Stefan Bidi <stefanb...@gmail.com> wrote: > I wasn't really following the previous string of e-mails (perhaps I should > have). Can you give me an overview of what the problem is and why > initializing CF in [NSCFType+load] doesn't work?
http://gcc.gnu.org/onlinedocs/gcc/What-you-can-and-what-you-cannot-do-in-_002bload.html e.g. NSCFType is not a subclass of NSCFString nor implemented in the same file, thus the call to CFStringInitialize should be moved to NSCFString +load. that documentation doesn't seem to say you can't call objc_getClass(), apparently you cannot... so the NSNull I added is broken also, its just not crashing. it's of the "In particular, the following things, even if they can work in a particular case, are not guaranteed:" variety. those were the 2 things that popped out at me looking through CF*Initialize but i'm not all that familiar with the library.
Index: Source/objc_interface.h =================================================================== --- Source/objc_interface.h (revision 33795) +++ Source/objc_interface.h (working copy) @@ -28,7 +28,7 @@ #define __OBJC_INTERFACE_H__ 1 #include "CoreFoundation/CFRuntime.h" -#include <GNUstepBase/preface.h> +#include <objc/runtime.h> @@ -54,7 +54,7 @@ CF_IS_OBJC (CFTypeID typeID, const void *obj) { return (typeID >= __CFRuntimeClassTableCount - || object_getClass(obj) != __CFISAForTypeID (typeID)); + || object_getClass((id)obj) != __CFISAForTypeID (typeID)); } #define CF_OBJC_FUNCDISPATCH0(typeID, rettype, obj, sel) do { \ Index: Source/CFRuntime.m =================================================================== --- Source/CFRuntime.m (revision 33795) +++ Source/CFRuntime.m (working copy) @@ -375,7 +375,6 @@ extern void CFBundleInitialize (void); extern void CFNullInitialize (void); extern void CFNumberFormatterInitialize (void); -extern void CFStringInitialize (void); extern void CFTimeZoneInitialize (void); extern void CFUUIDInitialize (void); @@ -398,7 +397,6 @@ CFBundleInitialize(); CFNullInitialize (); CFNumberFormatterInitialize (); - CFStringInitialize (); CFTimeZoneInitialize (); CFUUIDInitialize (); } Index: Source/CFUUID.c =================================================================== --- Source/CFUUID.c (revision 33795) +++ Source/CFUUID.c (working copy) @@ -56,7 +56,7 @@ int fd; unsigned int seed = 0; size_t len = sizeof(seed); - BOOL hasSeed = NO; + Boolean hasSeed = false; fd = open("/dev/random", O_RDONLY | O_NONBLOCK, 0); if (fd >= 0) @@ -64,12 +64,12 @@ if (errno != EWOULDBLOCK) { if (read(fd, &seed, len) == (ssize_t)len) - hasSeed = YES; + hasSeed = true; } close(fd); } - if (hasSeed == NO) + if (hasSeed == false) { struct timeval tv; unsigned long junk; Index: Source/NSCFString.m =================================================================== --- Source/NSCFString.m (revision 33795) +++ Source/NSCFString.m (working copy) @@ -35,7 +35,14 @@ @interface NSCFString : NSMutableString @end +extern void CFStringInitialize (void); @implementation NSCFString + ++ (void) load +{ + CFStringInitialize(); +} + - (id) initWithBytes: (const void*) bytes length: (NSUInteger) length encoding: (NSStringEncoding) encoding Index: Source/CFBase.m =================================================================== --- Source/CFBase.m (revision 33795) +++ Source/CFBase.m (working copy) @@ -250,7 +250,8 @@ void CFNullInitialize (void) { _kCFNullTypeID = _CFRuntimeRegisterClass (&CFNullClass); - ((CFRuntimeBase*)kCFNull)->_isa = [NSNull class]; + /* don't use [NSNull class] before autorelease pool setup. */ + ((CFRuntimeBase*)kCFNull)->_isa = objc_getClass("NSNull"); } CFTypeID Index: ChangeLog =================================================================== --- ChangeLog (revision 33795) +++ ChangeLog (working copy) @@ -1,3 +1,13 @@ +2011-08-28 Matt Rice <ratm...@gmail.com> + + * Source/objc_interface.h: Remove reference to preface.h + add runtime.h. + (CF_IS_OBJC): Add cast to avoid warning. + * Source/CFRuntime.m: Remove call to CFStringInitialize. + * Source/CFString.m (+load): Move above call here. + * Source/CFUUID.m: Replace BOOL/YES/NO with Boolean/true/false. + * Source/CFBase (CFNullInitialize): Avoid +initialize. + 2011-07-20 Stefan Bidigaray <stefanb...@gmail.com> * Source/CFDate.c:
_______________________________________________ Gnustep-dev mailing list Gnustep-dev@gnu.org https://lists.gnu.org/mailman/listinfo/gnustep-dev