diff --git a/class.c b/class.c index b844ead..5a40e75 100644 --- a/class.c +++ b/class.c @@ -94,6 +94,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "objc/objc-api.h" #include "lock.h" +#include "magic_objects.h" #include @@ -230,13 +231,15 @@ void __objc_resolve_class_links (void) { void *es = NULL; - Class object_class = objc_get_class ("Object"); + Class object_class = objc_get_class (ROOT_OBJECT_CLASS_NAME); + fprintf(stderr, "Using root class: %s\n", ROOT_OBJECT_CLASS_NAME); Class class1; assert (object_class); LOCK(__objc_runtime_mutex); + /* Assign subclass links. */ while ((class1 = class_table_next (&es))) { diff --git a/init.c b/init.c index 27588ea..edb4c97 100644 --- a/init.c +++ b/init.c @@ -28,6 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "objc/runtime-legacy.h" #include "objc/encoding.h" #include "lock.h" +#include "magic_objects.h" /* The version number of this runtime. This must match the number defined in gcc (objc-act.c). */ @@ -837,8 +838,8 @@ objc_send_load (void) /* Special check to allow creating and sending messages to constant strings in +load methods. If these classes are not yet known, even if all the other classes are known, delay sending of +load. */ - if (! objc_lookup_class ("NXConstantString") || - ! objc_lookup_class ("Object")) + if (! objc_lookup_class (CONSTANT_STRING_CLASS) || + ! objc_lookup_class (ROOT_OBJECT_CLASS_NAME)) return; /* Iterate over all modules in the __objc_module_list and call on diff --git a/magic_objects.h b/magic_objects.h new file mode 100644 index 0000000..2b483a6 --- /dev/null +++ b/magic_objects.h @@ -0,0 +1,7 @@ +#ifdef GNUSTEP +static const char *ROOT_OBJECT_CLASS_NAME = "NSObject"; +static const char *CONSTANT_STRING_CLASS = "NSConstantString"; +#else +static const char *ROOT_OBJECT_CLASS_NAME = "Object"; +static const char *CONSTANT_STRING_CLASS = "NXConstantString"; +#endif