diff --git a/ChangeLog b/ChangeLog index fbd8b412f..879e4986a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2002-01-03 Adam Fedor + + * Headers/gnustep/base/NSString.h: Extern constant string class + reference for Darwin added. + * Source/GSString.m ([NXConstantString +initialize]): Setup constant + string class reference variable for Darwin. + * Source/NSObject.m: Don't put reference count and zone with object + on Darwin. + * Source/behavior.m (NeXT_RUNTIME/behavior_class_add_class): Use NeXT + runtime functions. Pass only one method_list at a time. + (NeXT_RUNTIME/behavior_class_add_methods): Only look at one + method_list at a time. + (NeXT_RUNTIME/search_for_method_in_list): Use NeXT runtime functions. + Thu Jan 3 19:38:42 2002 Nicola Pero * Tools/HTMLLinker.m: New tool. diff --git a/Headers/gnustep/base/NSString.h b/Headers/gnustep/base/NSString.h index bb273cbc3..f6ad724c5 100644 --- a/Headers/gnustep/base/NSString.h +++ b/Headers/gnustep/base/NSString.h @@ -336,6 +336,10 @@ enum { } @end +#if NeXT_RUNTIME +/* For internal use with NeXT runtime. */ +extern struct objc_class _NSConstantStringClassReference; +#endif #ifndef NO_GNUSTEP /* diff --git a/Headers/gnustep/base/behavior.h b/Headers/gnustep/base/behavior.h index c22f41a0e..adf94bf5b 100644 --- a/Headers/gnustep/base/behavior.h +++ b/Headers/gnustep/base/behavior.h @@ -52,13 +52,8 @@ void behavior_class_add_class (Class class, Class behavior); void behavior_class_add_category (Class class, struct objc_category *category); -#if NeXT_RUNTIME -void behavior_class_add_methods (Class class, - struct objc_method_list **methodLists); -#else void behavior_class_add_methods (Class class, struct objc_method_list *methods); -#endif /* Set to non-zero if you want debugging messages on stderr. */ void set_behavior_debug(int i); diff --git a/Source/GSString.m b/Source/GSString.m index e22de2d1e..7a43278bb 100644 --- a/Source/GSString.m +++ b/Source/GSString.m @@ -52,6 +52,9 @@ #include +/* Used by the Darwin/NeXT ObjC Runtime */ +struct objc_class _NSConstantStringClassReference; + /* * GSPlaceholderString - placeholder class for objects awaiting intialisation. */ @@ -2850,7 +2853,17 @@ transmute(ivars self, NSString *aString) { if (self == [NXConstantString class]) { +#if NeXT_RUNTIME + struct objc_class *ref = self; +#endif behavior_class_add_class(self, [GSCString class]); + +#if NeXT_RUNTIME + /* Set up a structure to represent the constant string class. All constant strings point to + this structure. + */ + _NSConstantStringClassReference = *ref; +#endif } } diff --git a/Source/NSObject.m b/Source/NSObject.m index 9a12ace00..da311cf81 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -78,7 +78,7 @@ static Class NSConstantStringClass; */ static objc_mutex_t retain_counts_gate = NULL; -#if GS_WITH_GC == 0 +#if GS_WITH_GC == 0 && !defined(NeXT_RUNTIME) #define REFCNT_LOCAL 0 #define CACHE_ZONE 0 #endif diff --git a/Source/behavior.m b/Source/behavior.m index 507403fd6..181011ae5 100644 --- a/Source/behavior.m +++ b/Source/behavior.m @@ -54,10 +54,6 @@ #include #include -#if NeXT_RUNTIME -#define methods methodLists -static struct objc_method *search_for_method_in_list (struct objc_method_list **list, SEL op); -#endif static BOOL class_is_kind_of(Class self, Class class); static int behavior_debug = 0; @@ -79,14 +75,15 @@ behavior_class_add_class (Class class, Class behavior) #if NeXT_RUNTIME if (class->instance_size < behavior->instance_size) { - /* We can allow this since we're pretty sure NXConstantString is not subclassed. */ - if (strcmp(class_get_class_name(class), "NXConstantString") == 0) + /* We can allow this since we're pretty sure NXConstantString is + not subclassed. */ + if (class == [NXConstantString class]) { class->instance_size = behavior->instance_size; } else NSCAssert2(class->instance_size >= behavior->instance_size, - @"Trying to add behavior (%s) with instance size larger than class (%s)", + @"Trying to add behavior (%s) with instance size larger than class (%s)", class_get_class_name(behavior), class_get_class_name(class)); } #else @@ -116,7 +113,17 @@ behavior_class_add_class (Class class, Class behavior) fprintf(stderr, "Adding instance methods from %s\n", behavior->name); } +#if NeXT_RUNTIME + { + void *iterator = 0; + struct objc_method_list *method_list; + + while ( (method_list = class_nextMethodList(behavior, &iterator)) ) + behavior_class_add_methods (class, method_list); + } +#else behavior_class_add_methods (class, behavior->methods); +#endif /* Add class methods */ if (behavior_debug) @@ -124,8 +131,19 @@ behavior_class_add_class (Class class, Class behavior) fprintf(stderr, "Adding class methods from %s\n", behavior->class_pointer->name); } +#if NeXT_RUNTIME + { + void *iterator = 0; + struct objc_method_list *method_list; + + while ( (method_list = + class_nextMethodList(behavior->class_pointer, &iterator)) ) + behavior_class_add_methods (class->class_pointer, method_list); + } +#else behavior_class_add_methods (class->class_pointer, behavior->class_pointer->methods); +#endif /* Add behavior's superclass, if not already there. */ { @@ -143,22 +161,22 @@ class_add_behavior (Class class, Class behavior) behavior_class_add_class (class, behavior); } -#if NeXT_RUNTIME void behavior_class_add_category (Class class, struct objc_category *category) { - struct objc_method_list *mlists[2]; - - mlists[1] = 0; - mlists[0] = category->instance_methods; - behavior_class_add_methods (class, mlists); - mlists[0] = category->class_methods; - behavior_class_add_methods (class->class_pointer, mlists); + behavior_class_add_methods (class, + category->instance_methods); + behavior_class_add_methods (class->class_pointer, + category->class_methods); /* xxx Add the protocols (category->protocols) too. */ } +#if NeXT_RUNTIME + +static struct objc_method *search_for_method_in_list (Class class, SEL op); + void -behavior_class_add_methods (Class class, struct objc_method_list **methodLists) +behavior_class_add_methods (Class class, struct objc_method_list *methods) { static SEL initialize_sel = 0; struct objc_method_list *mlist; @@ -167,7 +185,7 @@ behavior_class_add_methods (Class class, struct objc_method_list **methodLists) initialize_sel = sel_register_name ("initialize"); /* Add methods to class->dtable and class->methods */ - while ((mlist = *(methodLists++))) + mlist = methods; { int counter; struct objc_method_list *new_list; @@ -191,7 +209,7 @@ behavior_class_add_methods (Class class, struct objc_method_list **methodLists) sel_get_name(method->method_name)); } - if (!search_for_method_in_list(class->methodLists,method->method_name) + if (!search_for_method_in_list(class,method->method_name) && !sel_eq(method->method_name, initialize_sel)) { /* As long as the method isn't defined in the CLASS, @@ -221,19 +239,19 @@ behavior_class_add_methods (Class class, struct objc_method_list **methodLists) } } -/* Given a linked list of method and a method's name. Search for the named - method's method structure. Return a pointer to the method's method - structure if found. NULL otherwise. */ +/* Search for the named method's method structure. Return a pointer + to the method's method structure if found. NULL otherwise. */ static struct objc_method * -search_for_method_in_list (struct objc_method_list **list, SEL op) +search_for_method_in_list (Class class, SEL op) { - struct objc_method_list *method_list = *(list++); + void *iterator = 0; + struct objc_method_list *method_list; if (! sel_is_mapped (op)) return NULL; /* If not found then we'll search the list. */ - while (method_list) + while ( (method_list = class_nextMethodList(class, &iterator)) ) { int i; @@ -248,10 +266,6 @@ search_for_method_in_list (struct objc_method_list **list, SEL op) return method; } } - - /* The method wasn't found. Follow the link to the next list of - methods. */ - method_list = *(list++); } return NULL; @@ -266,16 +280,6 @@ search_for_method_in_list (struct objc_method_list **list, SEL op) extern Method_t search_for_method_in_list(MethodList_t list, SEL op); extern void class_add_method_list(Class, MethodList_t); -void -behavior_class_add_category (Class class, struct objc_category *category) -{ - behavior_class_add_methods (class, - category->instance_methods); - behavior_class_add_methods (class->class_pointer, - category->class_methods); - /* xxx Add the protocols (category->protocols) too. */ -} - void behavior_class_add_methods (Class class, struct objc_method_list *methods) diff --git a/Testing/nsdictionary.m b/Testing/nsdictionary.m index 71eec95ac..4e1f3899d 100644 --- a/Testing/nsdictionary.m +++ b/Testing/nsdictionary.m @@ -4,6 +4,7 @@ #include #include #include +#include int main(int argc, char** argv, char** envp) diff --git a/Testing/nsfilehandle.m b/Testing/nsfilehandle.m index 24938f7ff..effb8ffa2 100644 --- a/Testing/nsfilehandle.m +++ b/Testing/nsfilehandle.m @@ -2,6 +2,7 @@ #include #include #include +#include int main () diff --git a/Testing/nsset.m b/Testing/nsset.m index b4807ecc9..539a4966d 100644 --- a/Testing/nsset.m +++ b/Testing/nsset.m @@ -2,6 +2,7 @@ #include #include #include +#include void original_test (); void intersects_set_test();