Changes to support clang's __attribute__((objc_root_class)).

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35412 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
thebeing 2012-08-16 12:31:16 +00:00
parent 218132903e
commit d10498bd01
11 changed files with 10549 additions and 7607 deletions

View file

@ -1,3 +1,21 @@
2012-08-16 Niels Grewe <niels.grewe@halbordnung.de>
* configure.ac: Check for objc_root_class attribute
* configure: Regenerate
* config/objc-common.g: Annotate root classes.
* Headers/GNUstepBase/config.h.in: Regenerate
* Headers/GNUstepBase/GSConfig.h.in: Add macro for root class
attribute availability.
* Headers/GNUstepBase/GSVersionMacros.h: Define GS_ROOT_CLASS
depending on whether the compiler supports it.
* Headers/Foundation/NSObject.h: Mark NSObject as a root class.
* Headers/Foundation/NSProxy.h: Mark NSProxy as a root class.
* Source/NSDistantObject: Mark GSDistantObjectPlaceholder as a
root class.
* Source/NSObject.m: Mark NSZombie as a root class.
Changes to support clang's __attribute__((objc_root_class)).
2012-08-10 Richard Frith-Macdonald <rfm@gnu.org> 2012-08-10 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSScanner.m: Fix error in comment * Source/NSScanner.m: Fix error in comment

View file

@ -283,7 +283,7 @@ extern "C" {
@end @end
@interface NSObject <NSObject> GS_ROOT_CLASS @interface NSObject <NSObject>
{ {
/** /**
* Points to instance's class. Used by runtime to access method * Points to instance's class. Used by runtime to access method

View file

@ -32,7 +32,7 @@
extern "C" { extern "C" {
#endif #endif
@interface NSProxy <NSObject> GS_ROOT_CLASS @interface NSProxy <NSObject>
{ {
@public @public
Class isa; Class isa;

View file

@ -227,6 +227,7 @@ typedef struct {
#define GS_USE_MDNS @HAVE_MDNS@ #define GS_USE_MDNS @HAVE_MDNS@
#define GS_USE_ICU @HAVE_ICU@ #define GS_USE_ICU @HAVE_ICU@
#define GS_USE_LIBDISPATCH @HAVE_LIBDISPATCH@ #define GS_USE_LIBDISPATCH @HAVE_LIBDISPATCH@
#define GS_HAVE_OBJC_ROOT_CLASS_ATTR @GS_HAVE_OBJC_ROOT_CLASS_ATTR@
#if defined(__WIN32__) || defined(_WIN32) || defined(__MS_WIN32__) #if defined(__WIN32__) || defined(_WIN32) || defined(__MS_WIN32__)
# if !defined(__WIN32__) # if !defined(__WIN32__)

View file

@ -3,24 +3,24 @@
Written by: Richard Frith-Macdonald <rfm@gnu.org> Written by: Richard Frith-Macdonald <rfm@gnu.org>
Date: Oct, October 2006 Date: Oct, October 2006
This file is part of GNUstep. This file is part of GNUstep.
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version. version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details. Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#ifndef __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ #ifndef __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_
#define __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ #define __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_
@ -91,7 +91,7 @@
* two digits are the major version number, the second two are the minor * two digits are the major version number, the second two are the minor
* version number and the last two are the subminor number (all left padded * version number and the last two are the subminor number (all left padded
* with a zero where necessary). However, for convenience you can also * with a zero where necessary). However, for convenience you can also
* use any of several predefined constants ... * use any of several predefined constants ...
* <ref type="macro" id="GS_API_NONE">GS_API_NONE</ref>, * <ref type="macro" id="GS_API_NONE">GS_API_NONE</ref>,
* <ref type="macro" id="GS_API_LATEST">GS_API_LATEST</ref>, * <ref type="macro" id="GS_API_LATEST">GS_API_LATEST</ref>,
* <ref type="macro" id="GS_API_OSSPEC">GS_API_OSSPEC</ref>, * <ref type="macro" id="GS_API_OSSPEC">GS_API_OSSPEC</ref>,
@ -124,7 +124,7 @@
* two digits are the major version number, the second two are the minor * two digits are the major version number, the second two are the minor
* version number and the last two are the subminor number (all left padded * version number and the last two are the subminor number (all left padded
* with a zero where necessary). However, for convenience you can also * with a zero where necessary). However, for convenience you can also
* use any of several predefined constants ... * use any of several predefined constants ...
* <ref type="macro" id="GS_API_NONE">GS_API_NONE</ref>, * <ref type="macro" id="GS_API_NONE">GS_API_NONE</ref>,
* <ref type="macro" id="GS_API_LATEST">GS_API_LATEST</ref>, * <ref type="macro" id="GS_API_LATEST">GS_API_LATEST</ref>,
* <ref type="macro" id="GS_API_OSSPEC">GS_API_OSSPEC</ref>, * <ref type="macro" id="GS_API_OSSPEC">GS_API_OSSPEC</ref>,
@ -297,7 +297,7 @@ static inline void gs_consumed(id NS_CONSUMED __attribute__ ((unused))o) { retur
#if defined(GNUSTEP_WITH_DLL) #if defined(GNUSTEP_WITH_DLL)
#if BUILD_libgnustep_base_DLL #if BUILD_libgnustep_base_DLL
# #
# if defined(__MINGW__) # if defined(__MINGW__)
@ -305,7 +305,7 @@ static inline void gs_consumed(id NS_CONSUMED __attribute__ ((unused))o) { retur
* __declspec(dllexport) is not needed. * __declspec(dllexport) is not needed.
*/ */
# define GS_EXPORT extern # define GS_EXPORT extern
# define GS_DECLARE # define GS_DECLARE
# else # else
# define GS_EXPORT __declspec(dllexport) # define GS_EXPORT __declspec(dllexport)
# define GS_DECLARE __declspec(dllexport) # define GS_DECLARE __declspec(dllexport)
@ -314,11 +314,11 @@ static inline void gs_consumed(id NS_CONSUMED __attribute__ ((unused))o) { retur
# define GS_EXPORT extern __declspec(dllimport) # define GS_EXPORT extern __declspec(dllimport)
# define GS_DECLARE __declspec(dllimport) # define GS_DECLARE __declspec(dllimport)
#endif #endif
#else /* GNUSTEP_WITH[OUT]_DLL */ #else /* GNUSTEP_WITH[OUT]_DLL */
# define GS_EXPORT extern # define GS_EXPORT extern
# define GS_DECLARE # define GS_DECLARE
#endif #endif
@ -342,4 +342,16 @@ static inline void gs_consumed(id NS_CONSUMED __attribute__ ((unused))o) { retur
#endif #endif
/*
* Attribute definition for root classes, annotates the interface declaration of
* the class.
*/
#ifndef GS_ROOT_CLASS
# if GS_HAVE_OBJC_ROOT_CLASS_ATTR || __has_feature(attribute_objc_root_class)
# define GS_ROOT_CLASS __attribute__((objc_root_class))
# else
# define GS_ROOT_CLASS
# endif
#endif
#endif /* __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ */ #endif /* __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ */

View file

@ -388,6 +388,9 @@
/* Define to 1 if you have the <objc/objc.h> header file. */ /* Define to 1 if you have the <objc/objc.h> header file. */
#undef HAVE_OBJC_OBJC_H #undef HAVE_OBJC_OBJC_H
/* Says whether the objc_root_class attribute works */
#undef HAVE_OBJC_ROOT_CLASS_ATTRIBUTE
/* Define to 1 if you have the <objc/runtime.h> header file. */ /* Define to 1 if you have the <objc/runtime.h> header file. */
#undef HAVE_OBJC_RUNTIME_H #undef HAVE_OBJC_RUNTIME_H

View file

@ -129,7 +129,7 @@ enum proxyLocation
* instance, we will get a pre-existing one, so we don't want to go * instance, we will get a pre-existing one, so we don't want to go
* allocating the memory for a new instance unless absolutely necessary. * allocating the memory for a new instance unless absolutely necessary.
*/ */
@interface GSDistantObjectPlaceHolder GS_ROOT_CLASS @interface GSDistantObjectPlaceHolder
+ (id) initWithCoder: (NSCoder*)aCoder; + (id) initWithCoder: (NSCoder*)aCoder;
+ (id) initWithLocal: (id)anObject connection: (NSConnection*)aConnection; + (id) initWithLocal: (id)anObject connection: (NSConnection*)aConnection;
+ (id) initWithTarget: (unsigned)target connection: (NSConnection*)aConnection; + (id) initWithTarget: (unsigned)target connection: (NSConnection*)aConnection;

View file

@ -108,7 +108,7 @@ static Class NSConstantStringClass;
@class NSDataMalloc; @class NSDataMalloc;
@class NSMutableDataMalloc; @class NSMutableDataMalloc;
@interface NSZombie GS_ROOT_CLASS @interface NSZombie
{ {
Class isa; Class isa;
} }
@ -430,7 +430,7 @@ typedef struct obj_layout *obj;
/** /**
* If -base is compiled in GC mode, then we want to still support manual * If -base is compiled in GC mode, then we want to still support manual
* reference counting if we are linked with non-GC code. * reference counting if we are linked with non-GC code.
*/ */
static BOOL GSDecrementExtraRefCountWasZero(id anObject); static BOOL GSDecrementExtraRefCountWasZero(id anObject);
@ -549,7 +549,7 @@ NSExtraRefCount(id anObject)
/** /**
* If -base is compiled in GC mode, then we want to still support manual * If -base is compiled in GC mode, then we want to still support manual
* reference counting if we are linked with non-GC code. * reference counting if we are linked with non-GC code.
*/ */
static void GSIncrementExtraRefCount(id anObject); static void GSIncrementExtraRefCount(id anObject);

View file

@ -16,10 +16,17 @@
#include <objc/hooks.h> #include <objc/hooks.h>
#endif #endif
#if HAVE_OBJC_ROOT_CLASS_ATTRIBUTE
#define GS_OBJC_ROOT_CLASS __attribute__((objc_root_class))
#else
#define GS_OBJC_ROOT_CLASS
#endif
/* Provide an implementation of NXConstantString for an old libobjc when /* Provide an implementation of NXConstantString for an old libobjc when
built stand-alone without an NXConstantString implementation. */ built stand-alone without an NXConstantString implementation. */
#if !defined(NeXT_RUNTIME) && !defined(__GNUSTEP_RUNTIME__) #if !defined(NeXT_RUNTIME) && !defined(__GNUSTEP_RUNTIME__)
@implementation NXConstantString GS_OBJC_ROOT_CLASS @implementation NXConstantString
- (const char*) cString - (const char*) cString
{ {
return 0; return 0;
@ -34,7 +41,7 @@
/* Provide dummy implementations for NSObject and NSConstantString /* Provide dummy implementations for NSObject and NSConstantString
* for libobjc2 which needs them. * for libobjc2 which needs them.
*/ */
@interface NSObject GS_OBJC_ROOT_CLASS @interface NSObject
{ {
id isa; id isa;
} }

18059
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -1669,6 +1669,26 @@ AC_CHECK_LIB(rt, sched_yield)
#-------------------------------------------------------------------- #--------------------------------------------------------------------
AC_CHECK_FUNCS(nanosleep usleep Sleep) AC_CHECK_FUNCS(nanosleep usleep Sleep)
AC_MSG_CHECKING(for objc_root_class attribute support)
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror $OBJCFLAGS -x objective-c"
AC_COMPILE_IFELSE([
__attribute__((objc_root_class)) @interface RootObject
@end
@implementation RootObject
@end],
AC_MSG_RESULT([found])
gs_objc_root_class_attr=1,
AC_MSG_RESULT([not present])
gs_objc_root_class_attr=0
)
GS_HAVE_OBJC_ROOT_CLASS_ATTR=$gs_objc_root_class_attr
AC_SUBST(GS_HAVE_OBJC_ROOT_CLASS_ATTR)
AC_DEFINE_UNQUOTED(HAVE_OBJC_ROOT_CLASS_ATTRIBUTE,$gs_objc_root_class_attr,
[Says whether the objc_root_class attribute works])
CFLAGS=$saved_CFLAGS
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Check whether Objective-C /really/ works # Check whether Objective-C /really/ works
#-------------------------------------------------------------------- #--------------------------------------------------------------------