Darwin constant string class fixes and compiling

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11974 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 2002-01-03 20:39:12 +00:00
parent 5b042a2594
commit 89f0569cbd
9 changed files with 77 additions and 44 deletions

View file

@ -1,3 +1,17 @@
2002-01-03 Adam Fedor <fedor@gnu.org>
* 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 <n.pero@mi.flashnet.it> Thu Jan 3 19:38:42 2002 Nicola Pero <n.pero@mi.flashnet.it>
* Tools/HTMLLinker.m: New tool. * Tools/HTMLLinker.m: New tool.

View file

@ -336,6 +336,10 @@ enum {
} }
@end @end
#if NeXT_RUNTIME
/* For internal use with NeXT runtime. */
extern struct objc_class _NSConstantStringClassReference;
#endif
#ifndef NO_GNUSTEP #ifndef NO_GNUSTEP
/* /*

View file

@ -52,13 +52,8 @@ void behavior_class_add_class (Class class,
Class behavior); Class behavior);
void behavior_class_add_category (Class class, void behavior_class_add_category (Class class,
struct objc_category *category); 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, void behavior_class_add_methods (Class class,
struct objc_method_list *methods); struct objc_method_list *methods);
#endif
/* Set to non-zero if you want debugging messages on stderr. */ /* Set to non-zero if you want debugging messages on stderr. */
void set_behavior_debug(int i); void set_behavior_debug(int i);

View file

@ -52,6 +52,9 @@
#include <base/Unicode.h> #include <base/Unicode.h>
/* Used by the Darwin/NeXT ObjC Runtime */
struct objc_class _NSConstantStringClassReference;
/* /*
* GSPlaceholderString - placeholder class for objects awaiting intialisation. * GSPlaceholderString - placeholder class for objects awaiting intialisation.
*/ */
@ -2850,7 +2853,17 @@ transmute(ivars self, NSString *aString)
{ {
if (self == [NXConstantString class]) if (self == [NXConstantString class])
{ {
#if NeXT_RUNTIME
struct objc_class *ref = self;
#endif
behavior_class_add_class(self, [GSCString class]); 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
} }
} }

View file

@ -78,7 +78,7 @@ static Class NSConstantStringClass;
*/ */
static objc_mutex_t retain_counts_gate = NULL; 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 REFCNT_LOCAL 0
#define CACHE_ZONE 0 #define CACHE_ZONE 0
#endif #endif

View file

@ -54,10 +54,6 @@
#include <base/behavior.h> #include <base/behavior.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#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 BOOL class_is_kind_of(Class self, Class class);
static int behavior_debug = 0; static int behavior_debug = 0;
@ -79,14 +75,15 @@ behavior_class_add_class (Class class, Class behavior)
#if NeXT_RUNTIME #if NeXT_RUNTIME
if (class->instance_size < behavior->instance_size) if (class->instance_size < behavior->instance_size)
{ {
/* We can allow this since we're pretty sure NXConstantString is not subclassed. */ /* We can allow this since we're pretty sure NXConstantString is
if (strcmp(class_get_class_name(class), "NXConstantString") == 0) not subclassed. */
if (class == [NXConstantString class])
{ {
class->instance_size = behavior->instance_size; class->instance_size = behavior->instance_size;
} }
else else
NSCAssert2(class->instance_size >= behavior->instance_size, 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)); class_get_class_name(behavior), class_get_class_name(class));
} }
#else #else
@ -116,7 +113,17 @@ behavior_class_add_class (Class class, Class behavior)
fprintf(stderr, "Adding instance methods from %s\n", fprintf(stderr, "Adding instance methods from %s\n",
behavior->name); 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); behavior_class_add_methods (class, behavior->methods);
#endif
/* Add class methods */ /* Add class methods */
if (behavior_debug) if (behavior_debug)
@ -124,8 +131,19 @@ behavior_class_add_class (Class class, Class behavior)
fprintf(stderr, "Adding class methods from %s\n", fprintf(stderr, "Adding class methods from %s\n",
behavior->class_pointer->name); 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_add_methods (class->class_pointer,
behavior->class_pointer->methods); behavior->class_pointer->methods);
#endif
/* Add behavior's superclass, if not already there. */ /* 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); behavior_class_add_class (class, behavior);
} }
#if NeXT_RUNTIME
void void
behavior_class_add_category (Class class, struct objc_category *category) behavior_class_add_category (Class class, struct objc_category *category)
{ {
struct objc_method_list *mlists[2]; behavior_class_add_methods (class,
category->instance_methods);
mlists[1] = 0; behavior_class_add_methods (class->class_pointer,
mlists[0] = category->instance_methods; category->class_methods);
behavior_class_add_methods (class, mlists);
mlists[0] = category->class_methods;
behavior_class_add_methods (class->class_pointer, mlists);
/* xxx Add the protocols (category->protocols) too. */ /* xxx Add the protocols (category->protocols) too. */
} }
#if NeXT_RUNTIME
static struct objc_method *search_for_method_in_list (Class class, SEL op);
void 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; static SEL initialize_sel = 0;
struct objc_method_list *mlist; 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"); initialize_sel = sel_register_name ("initialize");
/* Add methods to class->dtable and class->methods */ /* Add methods to class->dtable and class->methods */
while ((mlist = *(methodLists++))) mlist = methods;
{ {
int counter; int counter;
struct objc_method_list *new_list; 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)); 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)) && !sel_eq(method->method_name, initialize_sel))
{ {
/* As long as the method isn't defined in the CLASS, /* 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 /* Search for the named method's method structure. Return a pointer
method's method structure. Return a pointer to the method's method to the method's method structure if found. NULL otherwise. */
structure if found. NULL otherwise. */
static struct objc_method * 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)) if (! sel_is_mapped (op))
return NULL; return NULL;
/* If not found then we'll search the list. */ /* If not found then we'll search the list. */
while (method_list) while ( (method_list = class_nextMethodList(class, &iterator)) )
{ {
int i; int i;
@ -248,10 +266,6 @@ search_for_method_in_list (struct objc_method_list **list, SEL op)
return method; return method;
} }
} }
/* The method wasn't found. Follow the link to the next list of
methods. */
method_list = *(list++);
} }
return NULL; 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 Method_t search_for_method_in_list(MethodList_t list, SEL op);
extern void class_add_method_list(Class, MethodList_t); 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 void
behavior_class_add_methods (Class class, behavior_class_add_methods (Class class,
struct objc_method_list *methods) struct objc_method_list *methods)

View file

@ -4,6 +4,7 @@
#include <Foundation/NSValue.h> #include <Foundation/NSValue.h>
#include <Foundation/NSDate.h> #include <Foundation/NSDate.h>
#include <Foundation/NSAutoreleasePool.h> #include <Foundation/NSAutoreleasePool.h>
#include <assert.h>
int int
main(int argc, char** argv, char** envp) main(int argc, char** argv, char** envp)

View file

@ -2,6 +2,7 @@
#include <Foundation/NSFileHandle.h> #include <Foundation/NSFileHandle.h>
#include <Foundation/NSData.h> #include <Foundation/NSData.h>
#include <Foundation/NSString.h> #include <Foundation/NSString.h>
#include <assert.h>
int int
main () main ()

View file

@ -2,6 +2,7 @@
#include <Foundation/NSArray.h> #include <Foundation/NSArray.h>
#include <Foundation/NSString.h> #include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.h> #include <Foundation/NSAutoreleasePool.h>
#include <assert.h>
void original_test (); void original_test ();
void intersects_set_test(); void intersects_set_test();