mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Darwin fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11904 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
546773b804
commit
9619360e8c
9 changed files with 187 additions and 32 deletions
26
ChangeLog
26
ChangeLog
|
@ -1,3 +1,29 @@
|
||||||
|
2001-12-27 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
|
* Headers/gnustep/base/objc-gnu2next.h: Disable __builtin functions
|
||||||
|
for GCC < 3.x (darwin).
|
||||||
|
|
||||||
|
* Headers/gnustep/base/behavior.h: New defs for darwin/NeXT. Remove
|
||||||
|
depreciated function.
|
||||||
|
* Source/GSSet.m (+initialize): Use new behavior function in place
|
||||||
|
of depreciated one.
|
||||||
|
* Source/behavior.m (behavior_class_add_class): On darwin, allow
|
||||||
|
NXConstantString class to increase in size.
|
||||||
|
(behavior_class_add_category): New/rewrite for darwin methodLists
|
||||||
|
structure.
|
||||||
|
(behavior_class_add_methods): Likewise.
|
||||||
|
(search_for_method_in_list): Likewise.
|
||||||
|
|
||||||
|
* Source/NSObject.m: Move ALIGN definition outside of #if
|
||||||
|
(NSDecrementExtraRefCountWasZero): Change NSAssert to NSCAssert.
|
||||||
|
|
||||||
|
* Source/mframe.m (method_types_get_first_argument): Use
|
||||||
|
method_types_get_next_argument.
|
||||||
|
|
||||||
|
* Source/Makefile.preamble: Additional flags for darwin linking.
|
||||||
|
|
||||||
|
* Source/libgnustep-base.def: Updated for new/removed classes.
|
||||||
|
|
||||||
2001-12-26 Richard Frith-Macdonald <rfm@gnu.org>
|
2001-12-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Tools/autogsdoc.m: Add options for better control of index file and
|
* Tools/autogsdoc.m: Add options for better control of index file and
|
||||||
|
|
|
@ -52,11 +52,13 @@ 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
|
||||||
/* The old deprecated interface */
|
|
||||||
void class_add_behavior (Class class, Class behavior);
|
|
||||||
|
|
||||||
/* 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);
|
||||||
|
|
|
@ -33,6 +33,14 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* Disable builtin functions for gcc < 3.x since it triggers a bad bug (even some 3.x versions may have this
|
||||||
|
bug) */
|
||||||
|
#if __GNUC__ < 3
|
||||||
|
#define __builtin_apply(a,b,c) 0
|
||||||
|
#define __builtin_apply_args() 0
|
||||||
|
#define __builtin_return(a) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
char *arg_ptr;
|
char *arg_ptr;
|
||||||
char arg_regs[sizeof (char*)];
|
char arg_regs[sizeof (char*)];
|
||||||
|
|
|
@ -438,7 +438,7 @@ static Class mutableSetClass;
|
||||||
{
|
{
|
||||||
if (self == [GSMutableSet class])
|
if (self == [GSMutableSet class])
|
||||||
{
|
{
|
||||||
class_add_behavior(self, [GSSet class]);
|
behavior_class_add_class(self, [GSSet class]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,11 @@ endif
|
||||||
ifeq ($(GNUSTEP_TARGET_OS),cygwin)
|
ifeq ($(GNUSTEP_TARGET_OS),cygwin)
|
||||||
libgnustep-base_LIBRARIES_DEPEND_UPON += -lobjc
|
libgnustep-base_LIBRARIES_DEPEND_UPON += -lobjc
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(findstring darwin1, $(GNUSTEP_TARGET_OS)), darwin1)
|
||||||
|
libgnustep-base_LIBRARIES_DEPEND_UPON += $(CONFIG_SYSTEM_LIBS) \
|
||||||
|
-flat_namespace
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Flags dealing with installing and uninstalling
|
# Flags dealing with installing and uninstalling
|
||||||
|
|
|
@ -83,6 +83,11 @@ static objc_mutex_t retain_counts_gate = NULL;
|
||||||
#define CACHE_ZONE 0
|
#define CACHE_ZONE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ALIGN
|
||||||
|
#undef ALIGN
|
||||||
|
#endif
|
||||||
|
#define ALIGN __alignof__(double)
|
||||||
|
|
||||||
#if defined(REFCNT_LOCAL) || defined(CACHE_ZONE)
|
#if defined(REFCNT_LOCAL) || defined(CACHE_ZONE)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -105,10 +110,6 @@ typedef struct obj_layout_unpadded {
|
||||||
* what padding (if any) is required to get the alignment of the
|
* what padding (if any) is required to get the alignment of the
|
||||||
* structure correct.
|
* structure correct.
|
||||||
*/
|
*/
|
||||||
#ifdef ALIGN
|
|
||||||
#undef ALIGN
|
|
||||||
#endif
|
|
||||||
#define ALIGN __alignof__(double)
|
|
||||||
|
|
||||||
struct obj_layout {
|
struct obj_layout {
|
||||||
#if defined(REFCNT_LOCAL)
|
#if defined(REFCNT_LOCAL)
|
||||||
|
@ -265,7 +266,7 @@ NSDecrementExtraRefCountWasZero (id anObject)
|
||||||
objc_mutex_unlock(retain_counts_gate);
|
objc_mutex_unlock(retain_counts_gate);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
NSAssert((int)(node->value) > 0, NSInternalInconsistencyException);
|
NSCAssert((int)(node->value) > 0, NSInternalInconsistencyException);
|
||||||
if (!--((int)(node->value)))
|
if (!--((int)(node->value)))
|
||||||
{
|
{
|
||||||
o_map_remove_node (node);
|
o_map_remove_node (node);
|
||||||
|
@ -279,7 +280,7 @@ NSDecrementExtraRefCountWasZero (id anObject)
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
NSAssert((int)(node->value) > 0, NSInternalInconsistencyException);
|
NSCAssert((int)(node->value) > 0, NSInternalInconsistencyException);
|
||||||
if (!--((int)(node->value)))
|
if (!--((int)(node->value)))
|
||||||
{
|
{
|
||||||
o_map_remove_node (node);
|
o_map_remove_node (node);
|
||||||
|
|
|
@ -54,15 +54,12 @@
|
||||||
#include <base/behavior.h>
|
#include <base/behavior.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
|
|
||||||
/* Darwin behavior */
|
|
||||||
#if NeXT_RUNTIME
|
#if NeXT_RUNTIME
|
||||||
#if !defined(Release3CompatibilityBuild)
|
|
||||||
#define methods methodLists
|
#define methods methodLists
|
||||||
#define method_next obsolete
|
static struct objc_method *search_for_method_in_list (struct objc_method_list **list, SEL op);
|
||||||
|
#else
|
||||||
|
static struct objc_method *search_for_method_in_list (struct objc_method_list *list, SEL op);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
static struct objc_method *search_for_method_in_list (struct objc_method_list * list, SEL op);
|
|
||||||
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;
|
||||||
|
@ -82,8 +79,18 @@ behavior_class_add_class (Class class, Class behavior)
|
||||||
NSCAssert(CLS_ISCLASS(behavior), NSInvalidArgumentException);
|
NSCAssert(CLS_ISCLASS(behavior), NSInvalidArgumentException);
|
||||||
|
|
||||||
#if NeXT_RUNTIME
|
#if NeXT_RUNTIME
|
||||||
NSCAssert(class->instance_size >= behavior->instance_size,
|
if (class->instance_size < behavior->instance_size)
|
||||||
@"Trying to add behavior with instance size larger than class");
|
{
|
||||||
|
/* We can allow this since we're pretty sure NXConstantString is not subclassed. */
|
||||||
|
if (strcmp(class_get_class_name(class), "NXConstantString") == 0)
|
||||||
|
{
|
||||||
|
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)",
|
||||||
|
class_get_class_name(behavior), class_get_class_name(class));
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* If necessary, increase instance_size of CLASS. */
|
/* If necessary, increase instance_size of CLASS. */
|
||||||
if (class->instance_size < behavior->instance_size)
|
if (class->instance_size < behavior->instance_size)
|
||||||
|
@ -131,13 +138,112 @@ behavior_class_add_class (Class class, Class behavior)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The old interface */
|
#if NeXT_RUNTIME
|
||||||
void
|
void
|
||||||
class_add_behavior (Class class, Class behavior)
|
behavior_class_add_category (Class class, struct objc_category *category)
|
||||||
{
|
{
|
||||||
behavior_class_add_class (class, behavior);
|
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);
|
||||||
|
/* xxx Add the protocols (category->protocols) too. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
behavior_class_add_methods (Class class, struct objc_method_list **methodLists)
|
||||||
|
{
|
||||||
|
static SEL initialize_sel = 0;
|
||||||
|
struct objc_method_list *mlist;
|
||||||
|
|
||||||
|
if (!initialize_sel)
|
||||||
|
initialize_sel = sel_register_name ("initialize");
|
||||||
|
|
||||||
|
/* Add methods to class->dtable and class->methods */
|
||||||
|
while ((mlist = *(methodLists++)))
|
||||||
|
{
|
||||||
|
int counter;
|
||||||
|
struct objc_method_list *new_list;
|
||||||
|
|
||||||
|
counter = mlist->method_count ? mlist->method_count - 1 : 1;
|
||||||
|
|
||||||
|
/* This is a little wasteful of memory, since not necessarily
|
||||||
|
all methods will go in here. */
|
||||||
|
new_list = (struct objc_method_list *)
|
||||||
|
objc_malloc (sizeof(struct objc_method_list) +
|
||||||
|
sizeof(struct objc_method[counter+1]));
|
||||||
|
new_list->method_count = 0;
|
||||||
|
|
||||||
|
while (counter >= 0)
|
||||||
|
{
|
||||||
|
struct objc_method *method = &(mlist->method_list[counter]);
|
||||||
|
|
||||||
|
if (behavior_debug)
|
||||||
|
fprintf(stderr, " processing method [%s]\n",
|
||||||
|
sel_get_name(method->method_name));
|
||||||
|
|
||||||
|
if (!search_for_method_in_list(class->methodLists, method->method_name)
|
||||||
|
&& !sel_eq(method->method_name, initialize_sel))
|
||||||
|
{
|
||||||
|
/* As long as the method isn't defined in the CLASS,
|
||||||
|
put the BEHAVIOR method in there. Thus, behavior
|
||||||
|
methods override the superclasses' methods. */
|
||||||
|
new_list->method_list[new_list->method_count] = *method;
|
||||||
|
(new_list->method_count)++;
|
||||||
|
}
|
||||||
|
counter -= 1;
|
||||||
|
}
|
||||||
|
if (new_list->method_count)
|
||||||
|
{
|
||||||
|
class_add_method_list(class, new_list);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OBJC_FREE(new_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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. */
|
||||||
|
static struct objc_method *
|
||||||
|
search_for_method_in_list (struct objc_method_list **list, SEL op)
|
||||||
|
{
|
||||||
|
struct objc_method_list *method_list = *(list++);
|
||||||
|
|
||||||
|
if (! sel_is_mapped (op))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* If not found then we'll search the list. */
|
||||||
|
while (method_list)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Search the method list. */
|
||||||
|
for (i = 0; i < method_list->method_count; ++i)
|
||||||
|
{
|
||||||
|
struct objc_method *method = &method_list->method_list[i];
|
||||||
|
|
||||||
|
if (method->method_name)
|
||||||
|
{
|
||||||
|
if (sel_eq(method->method_name, op))
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The method wasn't found. Follow the link to the next list of
|
||||||
|
methods. */
|
||||||
|
method_list = *(list++);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* GNU runtime */
|
||||||
void
|
void
|
||||||
behavior_class_add_category (Class class, struct objc_category *category)
|
behavior_class_add_category (Class class, struct objc_category *category)
|
||||||
{
|
{
|
||||||
|
@ -195,14 +301,10 @@ behavior_class_add_methods (Class class,
|
||||||
}
|
}
|
||||||
if (new_list->method_count)
|
if (new_list->method_count)
|
||||||
{
|
{
|
||||||
#if NeXT_RUNTIME
|
|
||||||
/* Not sure why this doesn't work for GNU runtime */
|
/* Not sure why this doesn't work for GNU runtime */
|
||||||
class_add_method_list(class, new_list);
|
//class_add_method_list(class, new_list);
|
||||||
#else
|
|
||||||
new_list->method_next = class->methods;
|
new_list->method_next = class->methods;
|
||||||
class->methods = new_list;
|
class->methods = new_list;
|
||||||
//__objc_update_dispatch_table_for_class (class);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -233,8 +335,10 @@ search_for_method_in_list (struct objc_method_list *list, SEL op)
|
||||||
struct objc_method *method = &method_list->method_list[i];
|
struct objc_method *method = &method_list->method_list[i];
|
||||||
|
|
||||||
if (method->method_name)
|
if (method->method_name)
|
||||||
if (sel_eq(method->method_name, op))
|
{
|
||||||
return method;
|
if (sel_eq(method->method_name, op))
|
||||||
|
return method;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The method wasn't found. Follow the link to the next list of
|
/* The method wasn't found. Follow the link to the next list of
|
||||||
|
@ -244,6 +348,7 @@ search_for_method_in_list (struct objc_method_list *list, SEL op)
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif /* NeXT runtime */
|
||||||
|
|
||||||
static BOOL class_is_kind_of(Class self, Class aClassObject)
|
static BOOL class_is_kind_of(Class self, Class aClassObject)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,9 +48,9 @@ __objc_class_name_GSDictionaryObjectEnumerator
|
||||||
__objc_class_name_GSMutableDictionary
|
__objc_class_name_GSMutableDictionary
|
||||||
__objc_class_name_NSGDictionary
|
__objc_class_name_NSGDictionary
|
||||||
__objc_class_name_NSGMutableDictionary
|
__objc_class_name_NSGMutableDictionary
|
||||||
|
__objc_class_name_GSFFCallInvocation
|
||||||
__objc_class_name_GSHTTPURLHandle
|
__objc_class_name_GSHTTPURLHandle
|
||||||
__objc_class_name_GSMimeBase64DecoderContext
|
__objc_class_name_GSMimeBase64DecoderContext
|
||||||
__objc_class_name_GSMimeBinaryDecoderContext
|
|
||||||
__objc_class_name_GSMimeChunkedDecoderContext
|
__objc_class_name_GSMimeChunkedDecoderContext
|
||||||
__objc_class_name_GSMimeCodingContext
|
__objc_class_name_GSMimeCodingContext
|
||||||
__objc_class_name_GSMimeDocument
|
__objc_class_name_GSMimeDocument
|
||||||
|
@ -84,6 +84,14 @@ __objc_class_name_GSPointerValue
|
||||||
__objc_class_name_GSRangeValue
|
__objc_class_name_GSRangeValue
|
||||||
__objc_class_name_GSRectValue
|
__objc_class_name_GSRectValue
|
||||||
__objc_class_name_GSSizeValue
|
__objc_class_name_GSSizeValue
|
||||||
|
__objc_class_name_GSSAXHandler
|
||||||
|
__objc_class_name_GSXMLAttribute
|
||||||
|
__objc_class_name_GSXMLDocument
|
||||||
|
__objc_class_name_GSXMLDummy
|
||||||
|
__objc_class_name_GSXMLHandler
|
||||||
|
__objc_class_name_GSXMLNamespace
|
||||||
|
__objc_class_name_GSXMLNode
|
||||||
|
__objc_class_name_GSXMLParser
|
||||||
__objc_class_name_NSArchiver
|
__objc_class_name_NSArchiver
|
||||||
__objc_class_name_NSArray
|
__objc_class_name_NSArray
|
||||||
__objc_class_name_NSArrayEnumerator
|
__objc_class_name_NSArrayEnumerator
|
||||||
|
@ -184,6 +192,7 @@ __objc_class_name_NSMutableSet
|
||||||
__objc_class_name_NSSet
|
__objc_class_name_NSSet
|
||||||
__objc_class_name_NSMutableString
|
__objc_class_name_NSMutableString
|
||||||
__objc_class_name_NSString
|
__objc_class_name_NSString
|
||||||
|
__objc_class_name_NSConcreteWindowsTask
|
||||||
__objc_class_name_NSTask
|
__objc_class_name_NSTask
|
||||||
__objc_class_name_NSThread
|
__objc_class_name_NSThread
|
||||||
__objc_class_name_GSPlaceholderTimeZone
|
__objc_class_name_GSPlaceholderTimeZone
|
||||||
|
@ -207,6 +216,5 @@ __objc_class_name_NSUndoManager
|
||||||
__objc_class_name_PrivateUndoGroup
|
__objc_class_name_PrivateUndoGroup
|
||||||
__objc_class_name_NSUserDefaults
|
__objc_class_name_NSUserDefaults
|
||||||
__objc_class_name_GSPlaceholderValue
|
__objc_class_name_GSPlaceholderValue
|
||||||
__objc_class_name_GSXMLNode
|
|
||||||
__objc_class_name_GSXMLParser
|
|
||||||
__objc_class_name_NSValue
|
__objc_class_name_NSValue
|
||||||
|
__objc_class_name_WindowsFileHandle
|
||||||
|
|
|
@ -583,7 +583,7 @@ method_types_get_first_argument (struct objc_method* m,
|
||||||
const char** type)
|
const char** type)
|
||||||
{
|
{
|
||||||
*type = m->method_types;
|
*type = m->method_types;
|
||||||
return method_get_next_argument (argframe, type);
|
return method_types_get_next_argument (argframe, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue