mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
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:
parent
838a111cfe
commit
cf0e40cddc
9 changed files with 77 additions and 44 deletions
14
ChangeLog
14
ChangeLog
|
@ -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>
|
||||
|
||||
* Tools/HTMLLinker.m: New tool.
|
||||
|
|
|
@ -336,6 +336,10 @@ enum {
|
|||
}
|
||||
@end
|
||||
|
||||
#if NeXT_RUNTIME
|
||||
/* For internal use with NeXT runtime. */
|
||||
extern struct objc_class _NSConstantStringClassReference;
|
||||
#endif
|
||||
|
||||
#ifndef NO_GNUSTEP
|
||||
/*
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -52,6 +52,9 @@
|
|||
|
||||
#include <base/Unicode.h>
|
||||
|
||||
/* 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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -54,10 +54,6 @@
|
|||
#include <base/behavior.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 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)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSDate.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <assert.h>
|
||||
|
||||
int
|
||||
main(int argc, char** argv, char** envp)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <Foundation/NSFileHandle.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <assert.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <assert.h>
|
||||
|
||||
void original_test ();
|
||||
void intersects_set_test();
|
||||
|
|
Loading…
Reference in a new issue