mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 17:12:03 +00:00
Updates for darwin
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9573 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
68585ebb23
commit
9670ec5491
9 changed files with 482 additions and 743 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2001-04-12 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
|
* Headers/gnustep/base/NSLock.h: Don't include thr.h if NeXT_RUNTIME.
|
||||||
|
* Headers/gnustep/base/NSThread.h: Likewise.
|
||||||
|
* Headers/gnustep/base/NSObjCRuntime: Include objc-gnu2next if
|
||||||
|
NeXT_RUNTIME, usr common objc functions for compatibility.
|
||||||
|
* Headers/gnustep/base/objc-gnu2next.h: Update, simplify.
|
||||||
|
|
||||||
|
* Documentation/gsdoc/NSRecursiveLock.gsdoc: Update.
|
||||||
|
|
||||||
2001-04-12 Richard Frith-Macdonald <rfm@gnu.org>
|
2001-04-12 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSString.m: For efficiency, use _DefaultStringEncoding
|
* Source/NSString.m: For efficiency, use _DefaultStringEncoding
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
<gsdoc base="NSRecursiveLock" prev="NSProxy" next="NSRunLoop" up="Base">
|
<gsdoc base="NSRecursiveLock" prev="NSProxy" next="NSRunLoop" up="Base">
|
||||||
<head>
|
<head>
|
||||||
<title>NSRecursiveLock</title>
|
<title>NSRecursiveLock</title>
|
||||||
<author name="Richard Frith-Macdonald">
|
<author name="Adam Fedor">
|
||||||
<email address="rfm@gnu.org"/>
|
<email address="fedor@gnu.org"/>
|
||||||
<url url="http://www.gnustep.org/developers/whoiswho.html"/>
|
<url url="http://www.gnustep.org/developers/whoiswho.html"/>
|
||||||
</author>
|
</author>
|
||||||
<version>$Revision$</version>
|
<version>$Revision$</version>
|
||||||
|
@ -17,15 +17,26 @@
|
||||||
<declared>Foundation/NSLock.h</declared>
|
<declared>Foundation/NSLock.h</declared>
|
||||||
<conform>NSLocking</conform>
|
<conform>NSLocking</conform>
|
||||||
<desc>
|
<desc>
|
||||||
|
See NSLock for more information about what a lock is. A recursive
|
||||||
|
lock extends NSLock in that you can lock a recursive lock multiple
|
||||||
|
times. Each lock must be balanced by a cooresponding unlock, and the
|
||||||
|
lock is not released for another thread to aquire until the last
|
||||||
|
unlock call is made (cooresponding to the fist lock message).
|
||||||
</desc>
|
</desc>
|
||||||
<method type="BOOL">
|
<method type="BOOL">
|
||||||
<sel>lockBeforeDate:</sel>
|
<sel>lockBeforeDate:</sel>
|
||||||
<arg type="NSDate*">limit</arg>
|
<arg type="NSDate*">limit</arg>
|
||||||
<desc>
|
<desc>
|
||||||
|
Attempts to aquire a lock before the date limit passes. It returns
|
||||||
|
YES if it can. It returns NO if it cannot
|
||||||
|
(but it waits until the time limit is up before returning NO).
|
||||||
</desc>
|
</desc>
|
||||||
</method>
|
</method>
|
||||||
<method type="BOOL">
|
<method type="BOOL">
|
||||||
<sel>tryLock</sel>
|
<sel>tryLock</sel>
|
||||||
|
Attempts to aquire a lock, but returns NO immediately if the lock
|
||||||
|
cannot be aquired. It returns YES if the lock is aquired. Can be
|
||||||
|
called multiple times to make nested locks.
|
||||||
<desc>
|
<desc>
|
||||||
</desc>
|
</desc>
|
||||||
</method>
|
</method>
|
||||||
|
|
|
@ -32,7 +32,9 @@
|
||||||
#define _GNUstep_H_NSLock
|
#define _GNUstep_H_NSLock
|
||||||
|
|
||||||
#include <Foundation/NSObject.h>
|
#include <Foundation/NSObject.h>
|
||||||
|
#ifndef NeXT_RUNTIME
|
||||||
#include <objc/thr.h>
|
#include <objc/thr.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NSLocking protocol
|
* NSLocking protocol
|
||||||
|
|
|
@ -84,6 +84,8 @@ GS_EXPORT BOOL GSInstanceVariableInfo(id obj, NSString *iVarName,
|
||||||
GS_EXPORT BOOL GSGetInstanceVariable(id obj, NSString *name, void* data);
|
GS_EXPORT BOOL GSGetInstanceVariable(id obj, NSString *name, void* data);
|
||||||
GS_EXPORT BOOL GSSetInstanceVariable(id obj, NSString *name, const void* data);
|
GS_EXPORT BOOL GSSetInstanceVariable(id obj, NSString *name, const void* data);
|
||||||
|
|
||||||
|
#include <objc-gnu2next.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GSObjCClass() return the class of an instance.
|
* GSObjCClass() return the class of an instance.
|
||||||
* The argument to this function must NOT be nil.
|
* The argument to this function must NOT be nil.
|
||||||
|
@ -91,7 +93,7 @@ GS_EXPORT BOOL GSSetInstanceVariable(id obj, NSString *name, const void* data);
|
||||||
FOUNDATION_STATIC_INLINE Class
|
FOUNDATION_STATIC_INLINE Class
|
||||||
GSObjCClass(id obj)
|
GSObjCClass(id obj)
|
||||||
{
|
{
|
||||||
return obj->class_pointer;
|
return object_get_class(objc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -101,7 +103,7 @@ GSObjCClass(id obj)
|
||||||
FOUNDATION_STATIC_INLINE BOOL
|
FOUNDATION_STATIC_INLINE BOOL
|
||||||
GSObjCIsInstance(id obj)
|
GSObjCIsInstance(id obj)
|
||||||
{
|
{
|
||||||
return CLS_ISCLASS(obj->class_pointer);
|
return CLS_ISCLASS(object_get_class(objc));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -125,7 +127,7 @@ GSObjCIsKindOf(Class this, Class other)
|
||||||
FOUNDATION_STATIC_INLINE const char*
|
FOUNDATION_STATIC_INLINE const char*
|
||||||
GSObjCName(Class this)
|
GSObjCName(Class this)
|
||||||
{
|
{
|
||||||
return this->name;
|
return class_get_class_name(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
FOUNDATION_STATIC_INLINE const char*
|
FOUNDATION_STATIC_INLINE const char*
|
||||||
|
@ -149,7 +151,7 @@ GSObjCSuper(Class this)
|
||||||
FOUNDATION_STATIC_INLINE int
|
FOUNDATION_STATIC_INLINE int
|
||||||
GSObjCVersion(Class this)
|
GSObjCVersion(Class this)
|
||||||
{
|
{
|
||||||
return this->version;
|
return class_get_version(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -25,7 +25,9 @@
|
||||||
#ifndef __NSThread_h_GNUSTEP_BASE_INCLUDE
|
#ifndef __NSThread_h_GNUSTEP_BASE_INCLUDE
|
||||||
#define __NSThread_h_GNUSTEP_BASE_INCLUDE
|
#define __NSThread_h_GNUSTEP_BASE_INCLUDE
|
||||||
|
|
||||||
|
#ifndef NeXT_RUNTIME
|
||||||
#include <objc/thr.h>
|
#include <objc/thr.h>
|
||||||
|
#endif
|
||||||
#include <Foundation/NSDictionary.h>
|
#include <Foundation/NSDictionary.h>
|
||||||
#include <Foundation/NSDate.h>
|
#include <Foundation/NSDate.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
|
|
|
@ -26,11 +26,10 @@
|
||||||
#ifndef __objc_gnu2next_h_GNUSTEP_BASE_INCLUDE
|
#ifndef __objc_gnu2next_h_GNUSTEP_BASE_INCLUDE
|
||||||
#define __objc_gnu2next_h_GNUSTEP_BASE_INCLUDE
|
#define __objc_gnu2next_h_GNUSTEP_BASE_INCLUDE
|
||||||
|
|
||||||
#include <base/preface.h>
|
|
||||||
|
|
||||||
#if NeXT_RUNTIME
|
#if NeXT_RUNTIME
|
||||||
|
|
||||||
#include <objc/objc-class.h>
|
#include <objc/objc-class.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#define arglist_t marg_list
|
#define arglist_t marg_list
|
||||||
#define retval_t void*
|
#define retval_t void*
|
||||||
|
@ -59,6 +58,11 @@
|
||||||
#define class_create_instance(CLASS) class_createInstance(CLASS, 0)
|
#define class_create_instance(CLASS) class_createInstance(CLASS, 0)
|
||||||
#define sel_get_name(ASEL) sel_getName(ASEL)
|
#define sel_get_name(ASEL) sel_getName(ASEL)
|
||||||
#define sel_get_uid(METHODNAME) sel_getUid(METHODNAME)
|
#define sel_get_uid(METHODNAME) sel_getUid(METHODNAME)
|
||||||
|
|
||||||
|
/* FIXME: Any equivalent for this ? */
|
||||||
|
#define sel_get_type(SELECTOR) \
|
||||||
|
(NULL)
|
||||||
|
|
||||||
#define class_get_instance_method(CLASSPOINTER, SEL) \
|
#define class_get_instance_method(CLASSPOINTER, SEL) \
|
||||||
class_getInstanceMethod(CLASSPOINTER, SEL)
|
class_getInstanceMethod(CLASSPOINTER, SEL)
|
||||||
#define class_get_class_method(CLASSPOINTER, SEL) \
|
#define class_get_class_method(CLASSPOINTER, SEL) \
|
||||||
|
@ -88,187 +92,9 @@
|
||||||
#define objc_msg_lookup(OBJ,SEL) \
|
#define objc_msg_lookup(OBJ,SEL) \
|
||||||
(class_getInstanceMethod(object_get_class(OBJ), SEL)->method_imp)
|
(class_getInstanceMethod(object_get_class(OBJ), SEL)->method_imp)
|
||||||
|
|
||||||
#if 1
|
|
||||||
void objc_fatal(const char* msg);
|
|
||||||
#else
|
|
||||||
#define objc_fatal(FMT, args...) \
|
|
||||||
do { fprintf (stderr, (FMT), ##args); abort(); } while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define OBJC_READONLY 1
|
#define OBJC_READONLY 1
|
||||||
#define OBJC_WRITEONLY 2
|
#define OBJC_WRITEONLY 2
|
||||||
|
|
||||||
|
|
||||||
/* Methods defined by the GNU runtime, which libobjects will provide
|
|
||||||
if the GNU runtime isn't being used. */
|
|
||||||
|
|
||||||
int objc_sizeof_type(const char* type);
|
|
||||||
int objc_alignof_type(const char* type);
|
|
||||||
int objc_aligned_size (const char* type);
|
|
||||||
int objc_promoted_size (const char* type);
|
|
||||||
inline const char* objc_skip_type_qualifiers (const char* type);
|
|
||||||
const char* objc_skip_typespec (const char* type);
|
|
||||||
inline const char* objc_skip_offset (const char* type);
|
|
||||||
const char* objc_skip_argspec (const char* type);
|
|
||||||
unsigned objc_get_type_qualifiers (const char* type);
|
|
||||||
|
|
||||||
/* The following from GNU's objc/objc-api.h */
|
|
||||||
|
|
||||||
/* For functions which return Method_t */
|
|
||||||
#define METHOD_NULL (Method_t)0
|
|
||||||
|
|
||||||
static inline BOOL
|
|
||||||
class_is_class(Class* class)
|
|
||||||
{
|
|
||||||
return CLS_ISCLASS(class);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline BOOL
|
|
||||||
class_is_meta_class(Class* class)
|
|
||||||
{
|
|
||||||
return CLS_ISMETA(class);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline BOOL
|
|
||||||
object_is_class(id object)
|
|
||||||
{
|
|
||||||
return CLS_ISCLASS((Class*)object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline BOOL
|
|
||||||
object_is_instance(id object)
|
|
||||||
{
|
|
||||||
return (object!=nil)&&CLS_ISCLASS(object_get_class(object));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline BOOL
|
|
||||||
object_is_meta_class(id object)
|
|
||||||
{
|
|
||||||
return CLS_ISMETA((Class*)object);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* The following from GNU's objc/list.h */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
struct objc_list {
|
|
||||||
void *head;
|
|
||||||
struct objc_list *tail;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Return a cons cell produced from (head . tail) */
|
|
||||||
|
|
||||||
static inline struct objc_list*
|
|
||||||
list_cons(void* head, struct objc_list* tail)
|
|
||||||
{
|
|
||||||
struct objc_list* cell;
|
|
||||||
|
|
||||||
cell = (struct objc_list*)objc_malloc(sizeof(struct objc_list));
|
|
||||||
cell->head = head;
|
|
||||||
cell->tail = tail;
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the length of a list, list_length(NULL) returns zero */
|
|
||||||
|
|
||||||
static inline int
|
|
||||||
list_length(struct objc_list* list)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
while(list)
|
|
||||||
{
|
|
||||||
i += 1;
|
|
||||||
list = list->tail;
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the Nth element of LIST, where N count from zero. If N
|
|
||||||
larger than the list length, NULL is returned */
|
|
||||||
|
|
||||||
static inline void*
|
|
||||||
list_nth(int index, struct objc_list* list)
|
|
||||||
{
|
|
||||||
while(index-- != 0)
|
|
||||||
{
|
|
||||||
if(list->tail)
|
|
||||||
list = list->tail;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return list->head;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove the element at the head by replacing it by its successor */
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
list_remove_head(struct objc_list** list)
|
|
||||||
{
|
|
||||||
if ((*list)->tail)
|
|
||||||
{
|
|
||||||
struct objc_list* tail = (*list)->tail; /* fetch next */
|
|
||||||
*(*list) = *tail;/* copy next to list head */
|
|
||||||
objc_free(tail);/* free next */
|
|
||||||
}
|
|
||||||
else/* only one element in list */
|
|
||||||
{
|
|
||||||
objc_free(*list);
|
|
||||||
(*list) = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Remove the element with `car' set to ELEMENT */
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
list_remove_elem(struct objc_list** list, void* elem)
|
|
||||||
{
|
|
||||||
while (*list) {
|
|
||||||
if ((*list)->head == elem)
|
|
||||||
list_remove_head(list);
|
|
||||||
list = &((*list)->tail);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Map FUNCTION over all elements in LIST */
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
list_mapcar(struct objc_list* list, void(*function)(void*))
|
|
||||||
{
|
|
||||||
while(list)
|
|
||||||
{
|
|
||||||
(*function)(list->head);
|
|
||||||
list = list->tail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return element that has ELEM as car */
|
|
||||||
|
|
||||||
static inline struct objc_list**
|
|
||||||
list_find(struct objc_list** list, void* elem)
|
|
||||||
{
|
|
||||||
while(*list)
|
|
||||||
{
|
|
||||||
if ((*list)->head == elem)
|
|
||||||
return list;
|
|
||||||
list = &((*list)->tail);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free list (backwards recursive) */
|
|
||||||
|
|
||||||
static void
|
|
||||||
list_free(struct objc_list* list)
|
|
||||||
{
|
|
||||||
if(list)
|
|
||||||
{
|
|
||||||
list_free(list->tail);
|
|
||||||
objc_free(list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* NeXT_RUNTIME */
|
#endif /* NeXT_RUNTIME */
|
||||||
|
|
||||||
#endif /* __objc_gnu2next_h_GNUSTEP_BASE_INCLUDE */
|
#endif /* __objc_gnu2next_h_GNUSTEP_BASE_INCLUDE */
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
/* Dummy NXConstantString impl for so libobjc that doesn't include it */
|
/* Dummy NXConstantString impl for so libobjc that doesn't include it */
|
||||||
|
#ifndef NeXT_RUNTIME
|
||||||
#include <objc/NXConstStr.h>
|
#include <objc/NXConstStr.h>
|
||||||
@implementation NXConstantString
|
@implementation NXConstantString
|
||||||
@end
|
@end
|
||||||
|
#endif
|
||||||
|
|
||||||
@interface Test
|
@interface Test
|
||||||
static int test_result;
|
static int test_result;
|
||||||
|
|
|
@ -111,14 +111,8 @@ if test "$NeXTCC" != yes; then
|
||||||
ac_ext=$saved_ac_ext
|
ac_ext=$saved_ac_ext
|
||||||
if test $NeXT_runtime = 1; then
|
if test $NeXT_runtime = 1; then
|
||||||
AC_MSG_RESULT(no: NeXT runtime)
|
AC_MSG_RESULT(no: NeXT runtime)
|
||||||
echo "Sorry GNUstep does not yet work with the NeXT runtime."
|
|
||||||
echo "Type \"setenv CC gcc -fgnu-runtime\", and run ./configure again."
|
|
||||||
echo "If you are interested in having GNUstep work with the NeXT"
|
|
||||||
echo "runtime, contact Andrew McCallum <mccallum@gnu.ai.mit.edu>."
|
|
||||||
AC_MSG_ERROR(Unsupported Objective C runtime.)
|
|
||||||
# Not reached, for now...
|
|
||||||
LIBOBJC=''
|
LIBOBJC=''
|
||||||
CC="$CC -fnext-runtime"
|
CC="$CC -fnext-runtime -DNeXT_RUNTIME"
|
||||||
# Make sure that we get NeXTs objc/*.h files
|
# Make sure that we get NeXTs objc/*.h files
|
||||||
NEXT_INCLUDES='$(NEXT_NEXT_INCLUDES)'
|
NEXT_INCLUDES='$(NEXT_NEXT_INCLUDES)'
|
||||||
OBJS_INSTALL='$(GNU_OBJS)'
|
OBJS_INSTALL='$(GNU_OBJS)'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue