diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ea8cd789207..f8a1084c4aa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,43 @@ +2019-06-15 Iain Sandoe + + PR objc/90709 + * objc-obj-c++-shared/CF-CFString.h: New. + * objc-obj-c++-shared/F-NSArray.h: New. + * objc-obj-c++-shared/F-NSAutoreleasePool.h: New. + * objc-obj-c++-shared/F-NSObject.h: New. + * objc-obj-c++-shared/F-NSString.h: New. + * objc-obj-c++-shared/F-NSValue.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFArray.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFAvailability.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFBase.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFCharacterSet.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFData.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFDictionary.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFLocale.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFString.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSArray.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSAutoreleasePool.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSDate.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSEnumerator.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSGeometry.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSObject.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSRange.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSString.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSValue.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSZone.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/GNUstep.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/GSBlocks.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/GSConfig.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/GSObjCRuntime.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/GSVersionMacros.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/NSArray+GNUstepBase.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/NSMutableString+GNUstepBase.h: + New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/NSNumber+GNUstepBase.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/NSObject+GNUstepBase.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/NSString+GNUstepBase.h: New. + 2019-06-15 Jakub Jelinek PR middle-end/90779 diff --git a/gcc/testsuite/objc-obj-c++-shared/CF-CFString.h b/gcc/testsuite/objc-obj-c++-shared/CF-CFString.h new file mode 100644 index 00000000000..626001bb1fa --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/CF-CFString.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef _OBJC_CF_CFSTRING_H_ +#define _OBJC_CF_CFSTRING_H_ + +/* This is a workaround to PR90709 for the NeXT runtime. + If we're on a system version that has headers with items we can't + consume, then use the GNUStep header instead. +*/ + +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 +# import "GNUStep/CoreFoundation/CFString.h" +#else +# import +#endif + +#endif /* _OBJC_CF_CFSTRING_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/F-NSArray.h b/gcc/testsuite/objc-obj-c++-shared/F-NSArray.h new file mode 100644 index 00000000000..99b6189c103 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/F-NSArray.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef _OBJC_F_NSARRAY_H_ +#define _OBJC_F_NSARRAY_H_ + +/* This is a workaround to PR90709 for the NeXT runtime. + If we're on a system version that has headers with items we can't + consume, then use the GNUStep header instead. +*/ + +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 +# import "GNUStep/Foundation/NSArray.h" +#else +# import +#endif + +#endif /* _OBJC_F_NSARRAY_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/F-NSAutoreleasePool.h b/gcc/testsuite/objc-obj-c++-shared/F-NSAutoreleasePool.h new file mode 100644 index 00000000000..17599e8dfa0 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/F-NSAutoreleasePool.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef _OBJC_F_NSAUTORELEASEPOOL_H_ +#define _OBJC_F_NSAUTORELEASEPOOL_H_ + +/* This is a workaround to PR90709 for the NeXT runtime. + If we're on a system version that has headers with items we can't + consume, then use the GNUStep header instead. +*/ + +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 +# import "GNUStep/Foundation/NSAutoreleasePool.h" +#else +# import +#endif + +#endif /* _OBJC_F_NSAUTORELEASEPOOL_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/F-NSObject.h b/gcc/testsuite/objc-obj-c++-shared/F-NSObject.h new file mode 100644 index 00000000000..a372d607b1d --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/F-NSObject.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef _OBJC_F_NSOBJECT_H_ +#define _OBJC_F_NSOBJECT_H_ + +/* This is a workaround to PR90709 for the NeXT runtime. + If we're on a system version that has headers with items we can't + consume, then use the GNUStep header instead. +*/ + +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 +# import "GNUStep/Foundation/NSObject.h" +#else +# import +#endif + +#endif /* _OBJC_F_NSOBJECT_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/F-NSString.h b/gcc/testsuite/objc-obj-c++-shared/F-NSString.h new file mode 100644 index 00000000000..5c29398eab7 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/F-NSString.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef _OBJC_F_NSSTRING_H_ +#define _OBJC_F_NSSTRING_H_ + +/* This is a workaround to PR90709 for the NeXT runtime. + If we're on a system version that has headers with items we can't + consume, then use the GNUStep header instead. +*/ + +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 +# import "GNUStep/Foundation/NSString.h" +#else +# import +#endif + +#endif /* _OBJC_F_NSSTRING_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/F-NSValue.h b/gcc/testsuite/objc-obj-c++-shared/F-NSValue.h new file mode 100644 index 00000000000..fbe2ab34592 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/F-NSValue.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef _OBJC_F_NSSTRING_H_ +#define _OBJC_F_NSSTRING_H_ + +/* This is a workaround to PR90709 for the NeXT runtime. + If we're on a system version that has headers with items we can't + consume, then use the GNUStep header instead. +*/ + +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 +# import "GNUStep/Foundation/NSValue.h" +#else +# import +#endif + +#endif /* _OBJC_F_NSSTRING_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFArray.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFArray.h new file mode 100644 index 00000000000..0145855dbb4 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFArray.h @@ -0,0 +1,191 @@ +/* CFArray.h + + Copyright (C) 2010 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: January, 2010 + + This file is part of CoreBase. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#ifndef __COREFOUNDATION_CFARRAY_H__ +#define __COREFOUNDATION_CFARRAY_H__ + +#include "CFBase.h" + +CF_EXTERN_C_BEGIN +/** \ingroup CFArrayRef + \brief Reference to an immutable array object. + */ +typedef const struct __CFArray *CFArrayRef; +/** + \ingroup CFMutableArrayRef + \brief Reference to a mutable array object. + */ +typedef struct __CFArray *CFMutableArrayRef; + +/** \defgroup CFArrayRef CFArray Reference + \brief A CFArray and its mutable type, \ref CFMutableArrayRef + "CFMutableArray", are simple, low overhead, ordered containers for + objects. + \details + \#include + \{ + */ + +/** \name Callbacks + \{ + */ +typedef void (*CFArrayApplierFunction) (const void *value, void *context); +typedef CFStringRef (*CFArrayCopyDescriptionCallBack) (const void *value); +typedef void (*CFArrayReleaseCallBack) (CFAllocatorRef allocator, + const void *value); +typedef const void *(*CFArrayRetainCallBack) (CFAllocatorRef allocator, + const void *value); +typedef Boolean (*CFArrayEqualCallBack) (const void *value1, + const void *value2); +/** \} */ + +/** \brief Structure with CFArray callbacks. + */ +typedef struct _CFArrayCallBacks CFArrayCallBacks; +struct _CFArrayCallBacks +{ + CFIndex version; /**< Structure's version number. Current version is 0. */ + CFArrayRetainCallBack retain; + /**< The callback used to retain values added to the array. If NULL, + values are not retained. */ + CFArrayReleaseCallBack release; + CFArrayCopyDescriptionCallBack copyDescription; + CFArrayEqualCallBack equal; +}; + +/** \name Predefined Callback Structures + \{ + */ +CF_EXPORT const CFArrayCallBacks kCFTypeArrayCallBacks; +/** \} */ + + + +/** \name Creating an Array + \{ + */ +CF_EXPORT CFArrayRef +CFArrayCreate (CFAllocatorRef allocator, const void **values, + CFIndex numValues, const CFArrayCallBacks * callBacks); + +CF_EXPORT CFArrayRef +CFArrayCreateCopy (CFAllocatorRef allocator, CFArrayRef theArray); +/** \} */ + +/** \name Examining an Array + \{ + */ +CF_EXPORT CFIndex +CFArrayBSearchValues (CFArrayRef theArray, CFRange range, const void *value, + CFComparatorFunction comparator, void *context); + +CF_EXPORT Boolean +CFArrayContainsValue (CFArrayRef theArray, CFRange range, const void *value); + +CF_EXPORT CFIndex CFArrayGetCount (CFArrayRef theArray); + +CF_EXPORT CFIndex +CFArrayGetCountOfValue (CFArrayRef theArray, CFRange range, const void *value); + +CF_EXPORT CFIndex +CFArrayGetFirstIndexOfValue (CFArrayRef theArray, CFRange range, + const void *value); + +CF_EXPORT CFIndex +CFArrayGetLastIndexOfValue (CFArrayRef theArray, CFRange range, + const void *value); + +CF_EXPORT void +CFArrayGetValues (CFArrayRef theArray, CFRange range, const void **values); + +CF_EXPORT const void *CFArrayGetValueAtIndex (CFArrayRef theArray, CFIndex idx); +/** \} */ + +/** \name Applying a Function to Elements + \{ + */ +CF_EXPORT void +CFArrayApplyFunction (CFArrayRef theArray, CFRange range, + CFArrayApplierFunction applier, void *context); +/** \} */ + +/** \name Getting the CFArray Type ID + \{ + */ +CF_EXPORT CFTypeID CFArrayGetTypeID (void); +/** \} */ + +/** \} */ + +/** \defgroup CFMutableArrayRef CFMutableArray Reference + \details \#include + \{ + */ +CF_EXPORT void +CFArrayAppendArray (CFMutableArrayRef theArray, CFArrayRef otherArray, + CFRange otherRange); + +CF_EXPORT void +CFArrayAppendValue (CFMutableArrayRef theArray, const void *value); + +CF_EXPORT CFMutableArrayRef +CFArrayCreateMutable (CFAllocatorRef allocator, CFIndex capacity, + const CFArrayCallBacks * callBacks); + +CF_EXPORT CFMutableArrayRef +CFArrayCreateMutableCopy (CFAllocatorRef allocator, CFIndex capacity, + CFArrayRef theArray); + +CF_EXPORT void +CFArrayExchangeValuesAtIndices (CFMutableArrayRef theArray, CFIndex idx1, + CFIndex idx2); + +CF_EXPORT void +CFArrayInsertValueAtIndex (CFMutableArrayRef theArray, CFIndex idx, + const void *value); + +CF_EXPORT void CFArrayRemoveAllValues (CFMutableArrayRef theArray); + +CF_EXPORT void +CFArrayRemoveValueAtIndex (CFMutableArrayRef theArray, CFIndex idx); + +CF_EXPORT void +CFArrayReplaceValues (CFMutableArrayRef theArray, CFRange range, + const void **newValues, CFIndex newCount); + +CF_EXPORT void +CFArraySetValueAtIndex (CFMutableArrayRef theArray, CFIndex idx, + const void *value); + +CF_EXPORT void +CFArraySortValues (CFMutableArrayRef theArray, CFRange range, + CFComparatorFunction comparator, void *context); + +/** \} */ + +CF_EXTERN_C_END +#endif /* __COREFOUNDATION_CFARRAY_H__ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFAvailability.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFAvailability.h new file mode 100644 index 00000000000..855ff5c48a9 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFAvailability.h @@ -0,0 +1,52 @@ +/* CFAvailability.h + + Copyright (C) 2017 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: August, 2017 + + This file is part of the GNUstep CoreBase Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#ifndef __COREFOUNDATION_CFAVAILABILITY_H__ +#define __COREFOUNDATION_CFAVAILABILITY_H__ + +/* Compiler features */ +#ifndef __has_feature +#define __has_feature(x) 0 +#endif +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif +#ifndef __has_extension +#define __has_extension(x) __has_feature +#endif + +/* CFEnum macro for type definitions */ +#if (__cplusplus && __cplusplus >= 201103L) +#define CF_ENUM(_type, _name) _type _name; enum : _type +#define CF_OPTIONS(_type, _name) _type _name; enum : _type +#else +#define CF_ENUM(_type, _name) _type _name; enum +#define CF_OPTIONS(_type, _name) _type _name; enum +#endif + +#endif /* __COREFOUNDATION_CFAVAILABILITY_H__ */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFBase.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFBase.h new file mode 100644 index 00000000000..2df7b2925b2 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFBase.h @@ -0,0 +1,464 @@ +/* CFBase.h + + Copyright (C) 2010 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: January, 2010 + + This file is part of the GNUstep CoreBase Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#ifndef __COREFOUNDATION_CFBASE_H__ +#define __COREFOUNDATION_CFBASE_H__ + +/* CoreFoundation defines __LITTLE_ENDIAN__ or __BIG_ENDIAN__ so we'll + * do the same here for compatibility. + */ +#if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) +#define __LITTLE_ENDIAN__ 1 +#endif + +#include "CFAvailability.h" +#include "../GNUstepBase/GSVersionMacros.h" + +/* + * CoreFoundation types + */ +typedef unsigned char Boolean; +typedef unsigned char UInt8; +typedef signed char SInt8; +typedef unsigned short UInt16; +typedef signed short SInt16; +typedef unsigned int UInt32; +typedef signed int SInt32; +typedef unsigned long long UInt64; +typedef signed long long SInt64; +typedef SInt32 OSStatus; + +typedef float Float32; +typedef double Float64; +typedef UInt16 UniChar; +typedef UInt8 *StringPtr; +typedef const StringPtr *ConstStringPtr; +typedef UInt8 Str255[256]; +typedef const Str255 *ConstStr255Param; +typedef SInt16 OSErr; +typedef SInt16 RegionCode; +typedef SInt16 LangCode; +typedef SInt16 ScriptCode; +typedef UInt32 FourCharCode; +#ifndef OSTYPE_DECLARED +typedef FourCharCode OSType; +#define OSTYPE_DECLARED +#endif +typedef UInt8 Byte; +typedef SInt8 SignedByte; + +#ifndef UTF32Char /* UTF32Char is also defined in GSConfig.h */ +typedef UInt32 UTF32Char; +#endif +typedef UInt16 UTF16Char; +typedef UInt8 UTF8Char; + +#if !defined(CF_EXTERN_C_BEGIN) +#if defined(__cplusplus) +#define CF_EXTERN_C_BEGIN extern "C" { +#define CF_EXTERN_C_END } +#else +#define CF_EXTERN_C_BEGIN +#define CF_EXTERN_C_END +#endif +#endif + +#if defined(_WIN32) +#if defined(BUILDING_SELF) +#if defined(__cplusplus) +#define CF_EXPORT extern "C" __declspec(dllexport) +#else +#define CF_EXPORT extern __declspec(dllexport) +#endif +#else +#if defined(__cplusplus) +#define CF_EXPORT extern "C" __declspec(dllimport) +#else +#define CF_EXPORT extern __declspec(dllimport) +#endif +#endif +#else +#if defined(__cplusplus) +#define CF_EXPORT extern "C" +#else +#define CF_EXPORT extern +#endif +#endif + +#if !defined(__bool_true_false_are_defined) +#define true 1 +#define false 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#if !defined(CF_INLINE) +#if defined(__GNUC__) && (__GNUC__ >= 4) +#define CF_INLINE static __inline__ __attribute__((always_inline)) +#elif defined(__GNUC__) +#define CF_INLINE static __inline__ +#elif defined(__MWERKS__) || defined(__cplusplus) +#define CF_INLINE static inline +#elif defined(_MSC_VER) +#define CF_INLINE static __inline +#elif _WIN32 +#define CF_INLINE static __inline__ +#else +#define CF_INLINE static inline +#endif +#endif + +#if defined(__GNUC__) || defined(__llvm__) +#define GS_PURE_FUNCTION __attribute__((pure)) +#else +#define GS_PURE_FUNCTION +#endif + +CF_EXTERN_C_BEGIN +/** \defgroup CFTypeRef CFType Reference + \{ + */ +typedef unsigned long CFTypeID; +typedef const void *CFTypeRef; +/** @} + */ + +/** \defgroup BaseUtils Base Utilities + \{ + */ +/** An integer value to store a hash code. */ +typedef unsigned long CFHashCode; +/** A bitfield for passing information to functions. Can hold as many bits + as a word. + */ +typedef unsigned long CFOptionFlags; +/** A signed integer representing an index, size, length or count. */ +typedef signed long CFIndex; + +/** A structure that represents a range of items in a container, such as + an array. + */ +typedef struct CFRange CFRange; +struct CFRange +{ + CFIndex location; + /**< An integer representing the start location of the range, inclusive. */ + CFIndex length; + /**< An integer representing the total number of items in the range */ +}; + +/** Creates a CFRange structure. + \param location The starting location. + \param length The length. + \return An initialized CFRange structure. + */ +CF_INLINE CFRange +CFRangeMake (CFIndex location, CFIndex length) +{ + CFRange range; + + range.location = location; + range.length = length; + return range; +} + +/* Returned by comparison functions */ +typedef enum +{ + kCFCompareLessThan = -1, + kCFCompareEqualTo = 0, + kCFCompareGreaterThan = 1 +} CFComparisonResult; + +/* Return when a value is not found */ +enum +{ + kCFNotFound = -1 +}; + +/* Definition for standard comparison function callback. */ +typedef CFComparisonResult (*CFComparatorFunction) (const void *val1, + const void *val2, + void *context); + +/* CoreFoundation version numbers */ +/** \name Library Version Numbers + \{ + */ +CF_EXPORT const double kCFCoreFoundationVersionNumber; +#define kCFCoreFoundationVersionNumber10_0 196.40 +#define kCFCoreFoundationVersionNumber10_0_3 196.50 +#define kCFCoreFoundationVersionNumber10_1 226.00 +#define kCFCoreFoundationVersionNumber10_1_1 226.00 +#define kCFCoreFoundationVersionNumber10_1_2 227.20 +#define kCFCoreFoundationVersionNumber10_1_3 227.20 +#define kCFCoreFoundationVersionNumber10_1_4 227.30 +#define kCFCoreFoundationVersionNumber10_2 263.00 +#define kCFCoreFoundationVersionNumber10_2_1 263.10 +#define kCFCoreFoundationVersionNumber10_2_2 263.10 +#define kCFCoreFoundationVersionNumber10_2_3 263.30 +#define kCFCoreFoundationVersionNumber10_2_4 263.30 +#define kCFCoreFoundationVersionNumber10_2_5 263.50 +#define kCFCoreFoundationVersionNumber10_2_6 263.50 +#define kCFCoreFoundationVersionNumber10_2_7 263.50 +#define kCFCoreFoundationVersionNumber10_2_8 263.50 +#define kCFCoreFoundationVersionNumber10_3 299.00 +#define kCFCoreFoundationVersionNumber10_3_1 299.00 +#define kCFCoreFoundationVersionNumber10_3_2 299.00 +#define kCFCoreFoundationVersionNumber10_3_3 299.30 +#define kCFCoreFoundationVersionNumber10_3_4 299.31 +#define kCFCoreFoundationVersionNumber10_3_5 299.31 +#define kCFCoreFoundationVersionNumber10_3_6 299.32 +#define kCFCoreFoundationVersionNumber10_3_7 299.33 +#define kCFCoreFoundationVersionNumber10_3_8 299.33 +#define kCFCoreFoundationVersionNumber10_3_9 299.35 +#define kCFCoreFoundationVersionNumber10_4 368.00 +#define kCFCoreFoundationVersionNumber10_4_1 368.10 +#define kCFCoreFoundationVersionNumber10_4_2 368.11 +#define kCFCoreFoundationVersionNumber10_4_3 368.18 +#define kCFCoreFoundationVersionNumber10_4_4_Intel 368.26 +#define kCFCoreFoundationVersionNumber10_4_4_PowerPC 368.25 +#define kCFCoreFoundationVersionNumber10_4_5_Intel 368.26 +#define kCFCoreFoundationVersionNumber10_4_5_PowerPC 368.25 +#define kCFCoreFoundationVersionNumber10_4_6_Intel 368.26 +#define kCFCoreFoundationVersionNumber10_4_6_PowerPC 368.25 +#define kCFCoreFoundationVersionNumber10_4_7 368.27 +#define kCFCoreFoundationVersionNumber10_4_8 368.27 +#define kCFCoreFoundationVersionNumber10_4_9 368.28 +#define kCFCoreFoundationVersionNumber10_4_10 368.28 +#define kCFCoreFoundationVersionNumber10_4_11 368.31 +#define kCFCoreFoundationVersionNumber10_5 476.00 +#define kCFCoreFoundationVersionNumber10_5_1 476.00 +#define kCFCoreFoundationVersionNumber10_5_2 476.10 +#define kCFCoreFoundationVersionNumber10_5_3 476.13 +#define kCFCoreFoundationVersionNumber10_5_4 476.14 +#define kCFCoreFoundationVersionNumber10_5_5 476.15 +#define kCFCoreFoundationVersionNumber10_5_6 476.17 +/** \} */ +/** \} */ + +#if __has_feature(attribute_cf_returns_retained) +#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) +#else +#define CF_RETURNS_RETAINED +#endif + +#if __has_feature(attribute_cf_returns_not_retained) +#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) +#else +#define CF_RETURNS_NOT_RETAINED +#endif + +/** \ingroup CFPropertyListRef + */ +typedef CFTypeRef CFPropertyListRef; + +/** \ingroup CFStringRef + */ +typedef const struct __CFString *CFStringRef; +/** \ingroup CFMutableStringRef + */ +typedef struct __CFString *CFMutableStringRef; + + + +/** \defgroup CFAllocatorRef CFAllocator Reference + \brief CFAllocator is an opaque type used to allocate and deallocate + memory. + \{ + */ +/** \brief A reference to a CFAllocator object. + */ +typedef const struct __CFAllocator *CFAllocatorRef; + +typedef void *(*CFAllocatorAllocateCallBack) (CFIndex allocSize, + CFOptionFlags hint, void *info); +typedef void (*CFAllocatorDeallocateCallBack) (void *ptr, void *info); +typedef void *(*CFAllocatorReallocateCallBack) (void *ptr, + CFIndex newsize, + CFOptionFlags hint, void *info); +typedef CFIndex (*CFAllocatorPreferredSizeCallBack) (CFIndex size, + CFOptionFlags hint, + void *info); +typedef const void *(*CFAllocatorRetainCallBack) (const void *info); +typedef void (*CFAllocatorReleaseCallBack) (const void *info); +typedef CFStringRef (*CFAllocatorCopyDescriptionCallBack) (const void *info); + +struct _CFAllocatorContext +{ + CFIndex version; + void *info; + CFAllocatorRetainCallBack retain; + CFAllocatorReleaseCallBack release; + CFAllocatorCopyDescriptionCallBack copyDescription; + CFAllocatorAllocateCallBack allocate; + CFAllocatorReallocateCallBack reallocate; + CFAllocatorDeallocateCallBack deallocate; + CFAllocatorPreferredSizeCallBack preferredSize; +}; +typedef struct _CFAllocatorContext CFAllocatorContext; + +/** The default allocator and is equivalent to NULL. + \see CFAllocatorGetDefault() + \see CFAllocatorSetDefault() + */ +CF_EXPORT CFAllocatorRef kCFAllocatorDefault; +/** The default system allocator is used internally by GNUstep and is the + default allocator if none is been defined. + \see CFAllocatorSetDefault() + */ +CF_EXPORT CFAllocatorRef kCFAllocatorSystemDefault; +/** An allocator that uses the system's malloc, realloc and free functions. + */ +CF_EXPORT CFAllocatorRef kCFAllocatorMalloc; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +/** Equivalent to kCFAllocatorSystemDefault + */ +CF_EXPORT CFAllocatorRef kCFAllocatorMallocZone; +#endif +/** The NULL allocator does perform any operations. Can be passed as + a deallocator if you do not want GNUstep to deallocate the data. + */ +CF_EXPORT CFAllocatorRef kCFAllocatorNull; +/** This is a special case allocator directing CFAllocatorCreate() to use + the given CFAllocatorContext structure to allocate the new allocator. + */ +CF_EXPORT CFAllocatorRef kCFAllocatorUseContext; + +/** Create a new CFAllocator. + \param allocator The allocator used to create this allocator or + kCFAllocatorUseContext to use the functions in \b context. + \param context The new allocator's context functions. + \return A new CFAllocator or NULL in case of failure. + \see CFAllocatorContext + */ +CF_EXPORT CFAllocatorRef +CFAllocatorCreate (CFAllocatorRef allocator, CFAllocatorContext * context); + +/** Allocate new memory. + \param allocator The CFAllocator to use. + \param size The number of bytes to allocate. + \param hint Option flags. Currently unused and should be 0. + \return Newly allocated memory of NULL in case of failure. + \see CFAllocatorDeallocate() + */ +CF_EXPORT void *CFAllocatorAllocate (CFAllocatorRef allocator, CFIndex size, + CFOptionFlags hint); + +/** Deallocate the memory pointed to by \b ptr. + \param allocator The CFAllocator to use. + \param ptr A pointer previously allocated by CFAllocatorAllocate(). + \see CFAllocatorAllocate() + */ +CF_EXPORT void CFAllocatorDeallocate (CFAllocatorRef allocator, void *ptr); + +CF_EXPORT CFIndex +CFAllocatorGetPreferredSizeForSize (CFAllocatorRef allocator, CFIndex size, + CFOptionFlags hint); + +CF_EXPORT void *CFAllocatorReallocate (CFAllocatorRef allocator, void *ptr, + CFIndex newsize, CFOptionFlags hint); + +CF_EXPORT CFAllocatorRef CFAllocatorGetDefault (void); + +CF_EXPORT void CFAllocatorSetDefault (CFAllocatorRef allocator); + +CF_EXPORT void +CFAllocatorGetContext (CFAllocatorRef allocator, CFAllocatorContext * context); + +CF_EXPORT CFTypeID CFAllocatorGetTypeID (void); +/** \} */ + + + +/** \ingroup CFTypeRef + \{ + */ +/* These function will be implemented in CFRuntime.c since they + require runtime support. */ +CF_EXPORT CFStringRef CFCopyDescription (CFTypeRef cf); + +CF_EXPORT CFStringRef CFCopyTypeIDDescription (CFTypeID typeID); + +CF_EXPORT Boolean CFEqual (CFTypeRef cf1, CFTypeRef cf2); + +CF_EXPORT CFAllocatorRef CFGetAllocator (CFTypeRef cf); + +CF_EXPORT CFIndex CFGetRetainCount (CFTypeRef cf); + +CF_EXPORT CFTypeID CFGetTypeID (CFTypeRef cf); + +CF_EXPORT CFHashCode CFHash (CFTypeRef cf); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT CFTypeRef CFMakeCollectable (CFTypeRef cf); +#endif + +CF_EXPORT void CFRelease (CFTypeRef cf); + +CF_EXPORT CFTypeRef CFRetain (CFTypeRef cf); + +CF_EXPORT CFTypeRef CFAutorelease(CFTypeRef arg); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST) +CF_EXPORT void *_CFBridgingRelease (CFTypeRef cf); +CF_EXPORT CFTypeRef _CFBridgingRetain (void *obj); + +#if __has_feature(objc_arc) +#define CFBridgingRetain(x) (__bridge_retained CFTypeRef)(x) +#define CFBridgingRelease(x) (__bridge_transfer id)(x) +#elif __OBJC__ +#define CFBridgingRetain(x) _CFBridgingRetain((void *)(x)) +#define CFBridgingRelease(x) (id)_CFBridgingRelease((x)) +#else +#define CFBridgingRetain(x) _CFBridgingRetain((void *)(x)) +#define CFBridgingRelease(x) _CFBridgingRelease((x)) +#endif +#endif +/** \} */ + + + +/** \defgroup CFNullRef CFNull Reference + \{ + */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) +typedef struct __CFNull *CFNullRef; + +CF_EXPORT CFNullRef kCFNull; + +CFTypeID CFNullGetTypeID (void); +#endif +/** \} */ + +CF_EXTERN_C_END +#endif /* __COREFOUNDATION_CFBASE_H__ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFCharacterSet.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFCharacterSet.h new file mode 100644 index 00000000000..1cb6c66cac8 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFCharacterSet.h @@ -0,0 +1,173 @@ +/* CFCharacterSet.h + + Copyright (C) 2012 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: January, 2012 + + This file is part of the GNUstep CoreBase Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __COREFOUNDATION_CFCHARACTERSET_H__ +#define __COREFOUNDATION_CFCHARACTERSET_H__ + +#include "CFBase.h" +#include "CFData.h" + +CF_EXTERN_C_BEGIN + +/** \ingroup CFCharacterSetRef */ +typedef const struct __CFCharacterSet * CFCharacterSetRef; +/** \ingroup CFMutableCharacterSetRef */ +typedef struct __CFCharacterSet * CFMutableCharacterSetRef; + +/** \defgroup CFCharacterSetRef CFCharacterSet Reference + \{ + */ +typedef enum +{ + kCFCharacterSetControl = 1, + kCFCharacterSetWhitespace, + kCFCharacterSetWhitespaceAndNewline, + kCFCharacterSetDecimalDigit, + kCFCharacterSetLetter, + kCFCharacterSetLowercaseLetter, + kCFCharacterSetUppercaseLetter, + kCFCharacterSetNonBase, + kCFCharacterSetDecomposable, + kCFCharacterSetAlphaNumeric, + kCFCharacterSetPunctuation, +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) + kCFCharacterSetCapitalizedLetter = 13, +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) + kCFCharacterSetSymbol = 14, +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) + kCFCharacterSetNewline = 15, +#endif + kCFCharacterSetIllegal = 12 +} CFCharacterSetPredefinedSet; + + + +/** \name Creating Character Sets + \{ + */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) +CF_EXPORT CFCharacterSetRef +CFCharacterSetCreateCopy (CFAllocatorRef alloc, CFCharacterSetRef set); +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) +CF_EXPORT CFCharacterSetRef +CFCharacterSetCreateInvertedSet (CFAllocatorRef alloc, CFCharacterSetRef set); +#endif + +CF_EXPORT CFCharacterSetRef +CFCharacterSetCreateWithCharactersInRange (CFAllocatorRef alloc, + CFRange range); + +CF_EXPORT CFCharacterSetRef +CFCharacterSetCreateWithCharactersInString (CFAllocatorRef alloc, + CFStringRef string); + +CF_EXPORT CFCharacterSetRef +CFCharacterSetCreateWithBitmapRepresentation (CFAllocatorRef alloc, + CFDataRef data); +/** \} */ + +/** \name Getting Predefined Character Sets + \{ + */ +CF_EXPORT CFCharacterSetRef +CFCharacterSetGetPredefined (CFCharacterSetPredefinedSet setIdentifier); +/** \} */ + +/** \name Querying Character Sets + \{ + */ +CF_EXPORT CFDataRef +CFCharacterSetCreateBitmapRepresentation (CFAllocatorRef alloc, + CFCharacterSetRef set); + +CF_EXPORT Boolean +CFCharacterSetIsCharacterMember (CFCharacterSetRef set, UniChar c); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) +CF_EXPORT Boolean +CFCharacterSetHasMemberInPlane (CFCharacterSetRef set, CFIndex plane); + +CF_EXPORT Boolean +CFCharacterSetIsLongCharacterMember (CFCharacterSetRef set, UTF32Char c); + +CF_EXPORT Boolean +CFCharacterSetIsSupersetOfSet (CFCharacterSetRef set, + CFCharacterSetRef otherSet); +#endif +/** \} */ + +/** \name Getting the Character Set Type Identifier + \{ + */ +CF_EXPORT CFTypeID +CFCharacterSetGetTypeID (void); +/** \} */ +/** \} */ + +/** \defgroup CFMutableCharacterSetRef CFMutableCharacterSet Reference + \{ + */ +CF_EXPORT CFMutableCharacterSetRef +CFCharacterSetCreateMutable (CFAllocatorRef alloc); + +CF_EXPORT CFMutableCharacterSetRef +CFCharacterSetCreateMutableCopy (CFAllocatorRef alloc, CFCharacterSetRef set); + +CF_EXPORT void +CFCharacterSetAddCharactersInRange (CFMutableCharacterSetRef set, + CFRange range); + +CF_EXPORT void +CFCharacterSetAddCharactersInString (CFMutableCharacterSetRef set, + CFStringRef string); + +CF_EXPORT void +CFCharacterSetRemoveCharactersInRange (CFMutableCharacterSetRef set, + CFRange range); + +CF_EXPORT void +CFCharacterSetRemoveCharactersInString (CFMutableCharacterSetRef set, + CFStringRef string); + +CF_EXPORT void +CFCharacterSetIntersect (CFMutableCharacterSetRef set, + CFCharacterSetRef otherSet); + +CF_EXPORT void +CFCharacterSetInvert (CFMutableCharacterSetRef set); + +CF_EXPORT void +CFCharacterSetUnion (CFMutableCharacterSetRef set, CFCharacterSetRef otherSet); +/** \} */ + +CF_EXTERN_C_END + +#endif /* __COREFOUNDATION_CFCHARACTERSET_H__ */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFData.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFData.h new file mode 100644 index 00000000000..9e98a6969cd --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFData.h @@ -0,0 +1,114 @@ +/* CFData.h + + Copyright (C) 2010 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: January, 2010 + + This file is part of CoreBase. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __COREFOUNDATION_CFDATA_H__ +#define __COREFOUNDATION_CFDATA_H__ + +#include "CFBase.h" + +CF_EXTERN_C_BEGIN +/** \ingroup CFDataRef */ +typedef const struct __CFData *CFDataRef; +/** \ingroup CFMutableDataRef */ +typedef struct __CFData *CFMutableDataRef; + +/** \defgroup CFDataRef CFData Reference + \{ + */ +/** \name Creating a CFData Object + \{ + */ +CF_EXPORT CFDataRef +CFDataCreate (CFAllocatorRef allocator, const UInt8 * bytes, CFIndex length); + +CF_EXPORT CFDataRef +CFDataCreateCopy (CFAllocatorRef allocator, CFDataRef theData); + +CF_EXPORT CFDataRef +CFDataCreateWithBytesNoCopy (CFAllocatorRef allocator, const UInt8 * bytes, + CFIndex length, CFAllocatorRef bytesDeallocator); +/** \} */ + +/** \name Examining a CFData Object + \{ + */ +CF_EXPORT const UInt8 *CFDataGetBytePtr (CFDataRef theData); + +CF_EXPORT void +CFDataGetBytes (CFDataRef theData, CFRange range, UInt8 * buffer); + +CF_EXPORT CFIndex CFDataGetLength (CFDataRef theData); +/** \} */ + +/** \name Getting the CFData Type ID + \{ + */ +CF_EXPORT CFTypeID CFDataGetTypeID (void); +/** \} */ +/** \} */ + +/** \defgroup CFMutableDataRef CFMutableData Reference + \{ + */ +/** \name Creating a Mutable Data Object + \{ + */ +CF_EXPORT CFMutableDataRef +CFDataCreateMutable (CFAllocatorRef allocator, CFIndex capacity); + +CF_EXPORT CFMutableDataRef +CFDataCreateMutableCopy (CFAllocatorRef allocator, CFIndex capacity, + CFDataRef theData); +/** \} */ + +/** \name Accessing Mutable Data + \{ + */ +CF_EXPORT UInt8 *CFDataGetMutableBytePtr (CFMutableDataRef theData); +/** \} */ + +/** \name Modifying a Mutable Data Object + \{ + */ +CF_EXPORT void +CFDataAppendBytes (CFMutableDataRef theData, const UInt8 * bytes, + CFIndex length); + +CF_EXPORT void CFDataDeleteBytes (CFMutableDataRef theData, CFRange range); + +CF_EXPORT void +CFDataReplaceBytes (CFMutableDataRef theData, CFRange range, + const UInt8 * newBytes, CFIndex newLength); + +CF_EXPORT void +CFDataIncreaseLength (CFMutableDataRef theData, CFIndex extraLength); + +CF_EXPORT void CFDataSetLength (CFMutableDataRef theData, CFIndex length); +/** \} */ +/** \} */ + +CF_EXTERN_C_END +#endif /* __COREFOUNDATION_CFDATA_H__ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFDictionary.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFDictionary.h new file mode 100644 index 00000000000..adc0dd8c4b0 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFDictionary.h @@ -0,0 +1,174 @@ +/* CFDictionary.h + + Copyright (C) 2010 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: January, 2010 + + This file is part of the GNUstep CoreBase Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __COREFOUNDATION_CFDICTIONARY_H__ +#define __COREFOUNDATION_CFDICTIONARY_H__ 1 + +#include "CFBase.h" + +CF_EXTERN_C_BEGIN +/** \ingroup CFDictionaryRef */ +typedef const struct __CFDictionary *CFDictionaryRef; +/** \ingroup CFMutableDictionaryRef */ +typedef struct __CFDictionary *CFMutableDictionaryRef; + +/** \defgroup CFDictionaryRef CFDictionary Reference + \{ + */ +typedef void (*CFDictionaryApplierFunction) (const void *key, + const void *value, void *context); + +typedef CFStringRef (*CFDictionaryCopyDescriptionCallBack) (const void *value); +typedef Boolean (*CFDictionaryEqualCallBack) (const void *value1, + const void *value2); +typedef CFHashCode (*CFDictionaryHashCallBack) (const void *value); +typedef void (*CFDictionaryReleaseCallBack) (CFAllocatorRef allocator, + const void *value); +typedef const void *(*CFDictionaryRetainCallBack) (CFAllocatorRef allocator, + const void *value); + +typedef struct _CFDictionaryKeyCallBacks CFDictionaryKeyCallBacks; +struct _CFDictionaryKeyCallBacks +{ + CFIndex version; + CFDictionaryRetainCallBack retain; + CFDictionaryReleaseCallBack release; + CFDictionaryCopyDescriptionCallBack copyDescription; + CFDictionaryEqualCallBack equal; + CFDictionaryHashCallBack hash; +}; + +typedef struct _CFDictionaryValueCallBacks CFDictionaryValueCallBacks; +struct _CFDictionaryValueCallBacks +{ + CFIndex version; + CFDictionaryRetainCallBack retain; + CFDictionaryReleaseCallBack release; + CFDictionaryCopyDescriptionCallBack copyDescription; + CFDictionaryEqualCallBack equal; +}; + +CF_EXPORT const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks; +CF_EXPORT const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; +CF_EXPORT const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; + +/** \name Creating a dictionary + \{ + */ +CF_EXPORT CFDictionaryRef +CFDictionaryCreate (CFAllocatorRef allocator, const void **keys, + const void **values, CFIndex numValues, + const CFDictionaryKeyCallBacks * keyCallBacks, + const CFDictionaryValueCallBacks * valueCallBacks); + +CF_EXPORT CFDictionaryRef +CFDictionaryCreateCopy (CFAllocatorRef allocator, CFDictionaryRef theDict); +/** \} */ + +/** \name Examining a dictionary + \{ + */ +CF_EXPORT Boolean +CFDictionaryContainsKey (CFDictionaryRef theDict, const void *key); + +CF_EXPORT Boolean +CFDictionaryContainsValue (CFDictionaryRef theDict, const void *value); + +CF_EXPORT CFIndex CFDictionaryGetCount (CFDictionaryRef theDict); + +CF_EXPORT CFIndex +CFDictionaryGetCountOfKey (CFDictionaryRef theDict, const void *key); + +CF_EXPORT CFIndex +CFDictionaryGetCountOfValue (CFDictionaryRef theDict, const void *value); + +CF_EXPORT void +CFDictionaryGetKeysAndValues (CFDictionaryRef theDict, const void **keys, + const void **values); + +CF_EXPORT const void *CFDictionaryGetValue (CFDictionaryRef theDict, + const void *key); + +CF_EXPORT Boolean +CFDictionaryGetValueIfPresent (CFDictionaryRef theDict, const void *key, + const void **value); +/** \} */ + +/** \name Applying a funcation to a dictionary + \{ + */ +CF_EXPORT void +CFDictionaryApplyFunction (CFDictionaryRef theDict, + CFDictionaryApplierFunction applier, void *context); +/** \} */ + +/** \name Getting the CFDictionary type ID + \{ + */ +CF_EXPORT CFTypeID CFDictionaryGetTypeID (void); +/** \} */ +/** \} */ + +/** \defgroup CFMutableDictionaryRef CFMutableDictionary Reference + \{ + */ +/** \name Creating a Mutable Dictionary + \{ + */ +CF_EXPORT CFMutableDictionaryRef +CFDictionaryCreateMutable (CFAllocatorRef allocator, CFIndex capacity, + const CFDictionaryKeyCallBacks * keyCallBacks, + const CFDictionaryValueCallBacks * valueCallBacks); + +CF_EXPORT CFMutableDictionaryRef +CFDictionaryCreateMutableCopy (CFAllocatorRef allocator, CFIndex capacity, + CFDictionaryRef theDict); +/** \} */ + +/** \name Modifying a Dictionary + \{ + */ +CF_EXPORT void +CFDictionaryAddValue (CFMutableDictionaryRef theDict, const void *key, + const void *value); + +CF_EXPORT void CFDictionaryRemoveAllValues (CFMutableDictionaryRef theDict); + +CF_EXPORT void +CFDictionaryRemoveValue (CFMutableDictionaryRef theDict, const void *key); + +CF_EXPORT void +CFDictionaryReplaceValue (CFMutableDictionaryRef theDict, const void *key, + const void *value); + +CF_EXPORT void +CFDictionarySetValue (CFMutableDictionaryRef theDict, const void *key, + const void *value); +/** \} */ +/** \} */ + +CF_EXTERN_C_END +#endif /* __COREFOUNDATION_CFDICTIONARY_H__ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFLocale.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFLocale.h new file mode 100644 index 00000000000..7ae082de886 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFLocale.h @@ -0,0 +1,249 @@ +/* CFLocale.h + + Copyright (C) 2010 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: March, 2011 + + This file is part of the GNUstep CoreBase Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __COREFOUNDATION_CFLOCALE__ +#define __COREFOUNDATION_CFLOCALE__ 1 + +#include "CFBase.h" + +#include "CFArray.h" +#include "CFDictionary.h" + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) + +CF_EXTERN_C_BEGIN + +/** \defgroup CFLocaleRef CFLocale Reference + \brief CFLocale provides basic functionality for language and/or region + specific operations. + + Locale-sensitive operations, such as collation, calendars and + capitalization, may use CFLocale objects to provide language and/or region + specific functionality. + + CFLocale is "toll-free bridged" to NSLocale. + + \{ + */ +typedef const struct __CFLocale *CFLocaleRef; + +/** + */ +enum +{ + kCFLocaleLanguageDirectionUnknown = 0, + kCFLocaleLanguageDirectionLeftToRight = 1, + kCFLocaleLanguageDirectionRightToLeft = 2, + kCFLocaleLanguageDirectionTopToBottom = 3, + kCFLocaleLanguageDirectionBottomToTop = 4 +}; +typedef CFIndex CFLocaleLanguageDirection; + +/** \name CFLocale Property Keys + \{ + */ +CF_EXPORT const CFStringRef kCFLocaleMeasurementSystem; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleDecimalSeparator; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleGroupingSeparator; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleCurrencySymbol; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleCurrencyCode; /* CFString */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT const CFStringRef kCFLocaleIdentifier; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleLanguageCode; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleCountryCode; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleScriptCode; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleVariantCode; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleExemplarCharacterSet; /* CFCharacterSet */ +CF_EXPORT const CFStringRef kCFLocaleCalendarIdentifier; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleCalendar; /* CFCalendar */ +CF_EXPORT const CFStringRef kCFLocaleCollationIdentifier; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleUsesMetricSystem; /* CFBoolean */ +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +CF_EXPORT const CFStringRef kCFLocaleCollatorIdentifier; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleQuotationBeginDelimiterKey; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleQuotationEndDelimiterKey; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleAlternateQuotationBeginDelimiterKey; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleAlternateQuotationEndDelimiterKey; /* CFString */ +#endif +/** \} */ + +/** \name CFCalendar Identifiers + \{ + */ +CF_EXPORT const CFStringRef kCFGregorianCalendar; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT const CFStringRef kCFBuddhistCalendar; +CF_EXPORT const CFStringRef kCFChineseCalendar; +CF_EXPORT const CFStringRef kCFHebrewCalendar; +CF_EXPORT const CFStringRef kCFIslamicCalendar; +CF_EXPORT const CFStringRef kCFIslamicCivilCalendar; +CF_EXPORT const CFStringRef kCFJapaneseCalendar; +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +CF_EXPORT const CFStringRef kCFRepublicOfChinaCalendar; +CF_EXPORT const CFStringRef kCFPersianCalendar; +CF_EXPORT const CFStringRef kCFIndianCalendar; +CF_EXPORT const CFStringRef kCFISO8601Calendar; +#endif +/** \} */ + +/** CFLocale Change Notification + */ +CF_EXPORT const CFStringRef kCFLocaleCurrentLocaleDidChangeNotification; + + + +/** \name Creating a Locale + \{ + */ +CF_EXPORT CFLocaleRef +CFLocaleCopyCurrent (void); + +CF_EXPORT CFLocaleRef +CFLocaleCreate (CFAllocatorRef allocator, + CFStringRef localeIdent); + +CF_EXPORT CFLocaleRef +CFLocaleCreateCopy (CFAllocatorRef allocator, + CFLocaleRef locale); + +CF_EXPORT CFLocaleRef +CFLocaleGetSystem (void); +/** \} */ + +/** \name Getting System Locale Information + \{ + */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT CFArrayRef +CFLocaleCopyAvailableLocaleIdentifiers (void); +#endif +/** \} */ + +/** \name Getting ISO Information + \{ + */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT CFArrayRef +CFLocaleCopyISOCountryCodes (void); + +CF_EXPORT CFArrayRef +CFLocaleCopyISOLanguageCodes (void); + +CF_EXPORT CFArrayRef +CFLocaleCopyISOCurrencyCodes (void); +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +CF_EXPORT CFArrayRef +CFLocaleCopyCommonISOCurrencyCodes (void); +#endif +/** \{ */ + +/** \name Accessing Language Information + \{ + */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +CF_EXPORT CFArrayRef +CFLocaleCopyPreferredLanguages (void); +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +CF_EXPORT CFLocaleLanguageDirection +CFLocaleGetLanguageCharacterDirection (CFStringRef isoLangCode); + +CF_EXPORT CFLocaleLanguageDirection +CFLocaleGetLanguageLineDirection (CFStringRef isoLangCode); +#endif +/** \} */ + +/** \name Getting Information About a Locale + \{ + */ +CF_EXPORT CFStringRef +CFLocaleCopyDisplayNameForPropertyValue (CFLocaleRef displayLocale, + CFStringRef key, + CFStringRef value); + +CF_EXPORT CFTypeRef +CFLocaleGetValue (CFLocaleRef locale, + CFStringRef key); + +CF_EXPORT CFStringRef +CFLocaleGetIdentifier (CFLocaleRef locale); +/** \} */ + +/** \name Getting and Creating Locale Identifiers + \{ + */ +CF_EXPORT CFStringRef +CFLocaleCreateCanonicalLocaleIdentifierFromString (CFAllocatorRef allocator, + CFStringRef localeIdent); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT CFStringRef +CFLocaleCreateCanonicalLanguageIdentifierFromString (CFAllocatorRef allocator, + CFStringRef localeIdent); + +CF_EXPORT CFDictionaryRef +CFLocaleCreateComponentsFromLocaleIdentifier (CFAllocatorRef allocator, + CFStringRef localeIdent); + +CF_EXPORT CFStringRef +CFLocaleCreateLocaleIdentifierFromComponents (CFAllocatorRef allocator, + CFDictionaryRef dictionary); +#endif +/** \} */ + +/** \name Windows Locale Codes + \{ + */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +CF_EXPORT CFStringRef +CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode (CFAllocatorRef allocator, + UInt32 lcid); + +CF_EXPORT UInt32 +CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier (CFStringRef localeIdent); +#endif +/** \} */ + +/** \name Getting the CFLocale Type ID + \{ + */ +CF_EXPORT CFTypeID +CFLocaleGetTypeID (void); +/** \} */ + +/** \} */ + +CF_EXTERN_C_END + +#endif /* OS_API_VERSION >= MAC_OS_X_VERSION_10_3 */ + +#endif /* __COREFOUNDATION_CFLOCALE__ */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFString.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFString.h new file mode 100644 index 00000000000..42e4967ce90 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFString.h @@ -0,0 +1,593 @@ +/* CFString.h + + Copyright (C) 2010 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: January, 2010 + + This file is part of CoreBase. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __COREFOUNDATION_CFSTRING_H__ +#define __COREFOUNDATION_CFSTRING_H__ + +#include "CFBase.h" +#include "CFArray.h" +#include "CFCharacterSet.h" +#include "CFData.h" +#include "CFDictionary.h" +#include "CFLocale.h" + +#include + +CF_EXTERN_C_BEGIN + +/** \defgroup CFStringRef CFString Reference + \brief The CFString type defines opaque objects representing strings. + + CFString is "toll-free bridged" to NSString. + + \{ + */ + +/* + * Data Types + */ +typedef UInt32 CFStringEncoding; + +/* + * Constants + */ +typedef enum +{ + kCFCompareCaseInsensitive = 1, + kCFCompareBackwards = 4, + kCFCompareAnchored = 8, + kCFCompareNonliteral = 16, + kCFCompareLocalized = 32, + kCFCompareNumerically = 64, +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) + kCFCompareDiacriticInsensitive = 128, + kCFCompareWidthInsensitive = 256, + kCFCompareForcedOrdering = 512 +#endif +} CFStringCompareFlags; + +enum CFStringBuiltInEncodings +{ + kCFStringEncodingMacRoman = 0, + kCFStringEncodingWindowsLatin1 = 0x0500, + kCFStringEncodingISOLatin1 = 0x0201, + kCFStringEncodingNextStepLatin = 0x0B01, + kCFStringEncodingASCII = 0x0600, + kCFStringEncodingUnicode = 0x0100, + kCFStringEncodingUTF8 = 0x08000100, + kCFStringEncodingNonLossyASCII = 0x0BFF, +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) + kCFStringEncodingUTF16 = 0x0100, + kCFStringEncodingUTF16BE = 0x10000100, + kCFStringEncodingUTF16LE = 0x14000100, + kCFStringEncodingUTF32 = 0x0c000100, + kCFStringEncodingUTF32BE = 0x18000100, + kCFStringEncodingUTF32LE = 0x1c000100 +#endif +}; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) +# define kCFStringEncodingInvalidId (0xffffffffU) +#endif + +/** \def CFSTR(x) + \brief Creates a constant string object. + + \note This macro will create the constant string at runtime. + */ +/* The 'pure' attribute tells the compiler that this function will always + return the same result with the same input. If it has any skill, then + constant propagation passes will magically make sure that this function is + called as few times as possible. */ +CF_EXPORT CFStringRef +__CFStringMakeConstantString (const char *str) GS_PURE_FUNCTION; +//#define CFSTR(x) __CFStringMakeConstantString("" x "") + +#ifdef __CONSTANT_CFSTRINGS__ +#define CFSTR(x) ((CFStringRef) __builtin___CFStringMakeConstantString ("" x "")) +#else +#define CFSTR(x) __CFStringMakeConstantString("" x "") +#endif + +/** \name Creating a CFString + \{ + */ +CF_EXPORT CFArrayRef +CFStringCreateArrayBySeparatingStrings (CFAllocatorRef alloc, + CFStringRef theString, CFStringRef separatorString); + +CF_EXPORT CFStringRef +CFStringCreateByCombiningStrings (CFAllocatorRef alloc, CFArrayRef theArray, + CFStringRef separatorString); + +CF_EXPORT CFStringRef +CFStringCreateCopy (CFAllocatorRef alloc, CFStringRef theString); + +CF_EXPORT CFStringRef +CFStringCreateFromExternalRepresentation (CFAllocatorRef alloc, CFDataRef data, + CFStringEncoding encoding); + +CF_EXPORT CFStringRef +CFStringCreateWithBytes (CFAllocatorRef alloc, const UInt8 *bytes, + CFIndex numBytes, CFStringEncoding encoding, Boolean isExternalRepresentation); + +CF_EXPORT CFStringRef +CFStringCreateWithCharacters (CFAllocatorRef alloc, const UniChar *chars, + CFIndex numChars); + +CF_EXPORT CFStringRef +CFStringCreateWithCharactersNoCopy (CFAllocatorRef alloc, const UniChar *chars, + CFIndex numChars, CFAllocatorRef contentsDeallocator); + +CF_EXPORT CFStringRef +CFStringCreateWithCString (CFAllocatorRef alloc, const char *cStr, + CFStringEncoding encoding); + +CF_EXPORT CFStringRef +CFStringCreateWithCStringNoCopy (CFAllocatorRef alloc, const char *cStr, + CFStringEncoding encoding, CFAllocatorRef contentsDeallocator); + +CF_EXPORT CFStringRef +CFStringCreateWithFormat (CFAllocatorRef alloc, CFDictionaryRef formatOptions, + CFStringRef format, ...); + +CF_EXPORT CFStringRef +CFStringCreateWithFormatAndArguments (CFAllocatorRef alloc, + CFDictionaryRef formatOptions, CFStringRef format, va_list arguments); + +CF_EXPORT CFStringRef +CFStringCreateWithSubstring (CFAllocatorRef alloc, CFStringRef str, + CFRange range); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT CFStringRef +CFStringCreateWithFileSystemRepresentation (CFAllocatorRef alloc, + const char *buffer); +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +CF_EXPORT CFStringRef +CFStringCreateWithBytesNoCopy (CFAllocatorRef alloc, const UInt8 *bytes, + CFIndex numBytes, CFStringEncoding encoding, Boolean isExternalReprentation, + CFAllocatorRef contentsDeallocator); +#endif +/** \} */ + +/** \name Searching CFStrings + \{ + */ +CF_EXPORT CFArrayRef +CFStringCreateArrayWithFindResults (CFAllocatorRef alloc, CFStringRef theString, + CFStringRef stringToFind, CFRange rangeToSearch, + CFStringCompareFlags compareOptions); + +CF_EXPORT CFRange +CFStringFind (CFStringRef theString, CFStringRef stringToFind, + CFStringCompareFlags compareOptions); + +CF_EXPORT Boolean +CFStringFindWithOptions (CFStringRef theString, CFStringRef stringToFind, + CFRange rangeToSearch, CFStringCompareFlags searchOptions, CFRange *result); + +CF_EXPORT Boolean +CFStringFindWithOptionsAndLocale (CFStringRef theString,CFStringRef stringToFind, + CFRange rangeToSearch, CFStringCompareFlags searchOptions, + CFLocaleRef locale, CFRange *result); + +CF_EXPORT void +CFStringGetLineBounds (CFStringRef theString, CFRange range, + CFIndex *lineBeginIndex, CFIndex *lineEndIndex, CFIndex *contentsEndIndex); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) +CF_EXPORT Boolean +CFStringFindCharacterFromSet (CFStringRef theString, CFCharacterSetRef theSet, + CFRange rangeToSearch, CFStringCompareFlags searchOptions, CFRange *result); +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +CF_EXPORT void +CFStringGetParagraphBounds (CFStringRef string, CFRange range, + CFIndex *parBeginIndex, CFIndex *parEndIndex, CFIndex *contentsEndIndex); +#endif +/** \} */ + +/** \name Comparing String + \{ + */ +CF_EXPORT CFComparisonResult +CFStringCompare (CFStringRef theString1, CFStringRef theString2, + CFStringCompareFlags compareOptions); + +CF_EXPORT CFComparisonResult +CFStringCompareWithOptions (CFStringRef theString1, CFStringRef theString2, + CFRange rangeToCOmpare, CFStringCompareFlags compareOptions); + +CF_EXPORT Boolean +CFStringHasPrefix (CFStringRef theString, CFStringRef prefix); + +CF_EXPORT Boolean +CFStringHasSuffix (CFStringRef theString, CFStringRef suffix); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +CF_EXPORT CFComparisonResult +CFStringCompareWithOptionsAndLocale (CFStringRef theString1, + CFStringRef theString2, CFRange rangeToCOmpare, + CFStringCompareFlags compareOptions, CFLocaleRef locale); +#endif +/** \} */ + +/** \name Accessing Characters + \{ + */ +CF_EXPORT CFDataRef +CFStringCreateExternalRepresentation (CFAllocatorRef alloc, + CFStringRef theString, CFStringEncoding encoding, UInt8 lossByte); + +CF_EXPORT CFIndex +CFStringGetBytes (CFStringRef theString, CFRange range, + CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, + UInt8 *buffer, CFIndex maxBufLen, CFIndex *usedBufLen); + +CF_EXPORT UniChar +CFStringGetCharacterAtIndex (CFStringRef theString, CFIndex idx); + +CF_EXPORT void +CFStringGetCharacters (CFStringRef theString, CFRange range, UniChar *buffer); + +CF_EXPORT const UniChar * +CFStringGetCharactersPtr (CFStringRef theString); + +CF_EXPORT Boolean +CFStringGetCString (CFStringRef theString, char *buffer, CFIndex bufferSize, + CFStringEncoding encoding); + +CF_EXPORT const char * +CFStringGetCStringPtr (CFStringRef theString, CFStringEncoding encoding); + +CF_EXPORT CFIndex +CFStringGetLength (CFStringRef str); + +CF_EXPORT CFRange +CFStringGetRangeOfComposedCharactersAtIndex (CFStringRef theString, + CFIndex theIndex); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +CF_EXPORT UTF32Char +CFStringGetLongCharacterForSurrogatePair (UniChar surrogateHigh, + UniChar surrogateLow); + +CF_EXPORT Boolean +CFStringGetSurrogatePairForLongCharacter (UTF32Char character, + UniChar *surrogates); + +CF_EXPORT Boolean +CFStringIsSurrogateHighCharacter (UniChar character); + +CF_EXPORT Boolean +CFStringIsSurrogateLowCharacter (UniChar character); +#endif +/** \} */ + +/** \name Working with Encodings + \{ + */ +CF_EXPORT CFStringRef +CFStringConvertEncodingToIANACharSetName (CFStringEncoding encoding); + +CF_EXPORT unsigned long +CFStringConvertEncodingToNSStringEncoding (CFStringEncoding encoding); + +UInt32 +CFStringConvertEncodingToWindowsCodepage (CFStringEncoding encoding); + +CF_EXPORT CFStringEncoding +CFStringConvertIANACharSetNameToEncoding (CFStringRef theString); + +CF_EXPORT CFStringEncoding +CFStringConvertNSStringEncodingToEncoding (unsigned long encoding); + +CF_EXPORT CFStringEncoding +CFStringConvertWindowsCodepageToEncoding (UInt32 codepage); + +CF_EXPORT CFStringEncoding +CFStringGetFastestEncoding (CFStringRef theString); + +CF_EXPORT const CFStringEncoding * +CFStringGetListOfAvailableEncodings (void); + +CF_EXPORT CFIndex +CFStringGetMaximumSizeForEncoding (CFIndex length, CFStringEncoding encoding); + +CF_EXPORT CFStringEncoding +CFStringGetMostCompatibleMacStringEncoding (CFStringEncoding encoding); + +CF_EXPORT CFStringRef +CFStringGetNameOfEncoding (CFStringEncoding encoding); + +CF_EXPORT CFStringEncoding +CFStringGetSmallestEncoding (CFStringRef theString); + +CF_EXPORT CFStringEncoding +CFStringGetSystemEncoding (void); + +CF_EXPORT Boolean +CFStringIsEncodingAvailable (CFStringEncoding encoding); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT Boolean +CFStringGetFileSystemRepresentation (CFStringRef string, char *buffer, + CFIndex maxBufLen); + +CF_EXPORT CFIndex +CFStringGetMaximumSizeOfFileSystemRepresentation (CFStringRef string); +#endif +/** \} */ + +/** \name Getting Numeric Values + \{ + */ +CF_EXPORT double +CFStringGetDoubleValue (CFStringRef str); + +CF_EXPORT SInt32 +CFStringGetIntValue (CFStringRef str); +/** \} */ + +/** \name Getting String Properties + \{ + */ +CF_EXPORT void +CFShow (CFTypeRef obj); + +CF_EXPORT void +CFShowStr (CFStringRef str); + +CF_EXPORT CFTypeID +CFStringGetTypeID (void); +/** \} */ + + + +/** \name Pascal Strings + \{ + */ +CF_EXPORT CFStringRef +CFStringCreateWithPascalString (CFAllocatorRef alloc, ConstStr255Param pStr, + CFStringEncoding encoding); + +CF_EXPORT CFStringRef +CFStringCreateWithPascalStringNoCopy (CFAllocatorRef alloc, + ConstStr255Param pStr, CFStringEncoding encoding, + CFAllocatorRef contentsDeallocate); + +CF_EXPORT Boolean +CFStringGetPascalString (CFStringRef theString, StringPtr buffer, + CFIndex bufferSize, CFStringEncoding encoding); + +CF_EXPORT ConstStringPtr +CFStringGetPascalStringPtr (CFStringRef theString, CFStringEncoding encoding); +/** \} */ +/** \} */ + + + +/** \defgroup CFMutableStringRef CFMutableString Reference + * \{ + */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) +typedef enum +{ + kCFStringNormalizationFormD = 0, + kCFStringNormalizationFormKD = 1, + kCFStringNormalizationFormC = 2, + kCFStringNormalizationFormKC = 3 +} CFStringNormalizationForm; +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT const CFStringRef kCFStringTransformStripCombiningMarks; +CF_EXPORT const CFStringRef kCFStringTransformToLatin; +CF_EXPORT const CFStringRef kCFStringTransformFullwidthHalfwidth; +CF_EXPORT const CFStringRef kCFStringTransformLatinKatakana; +CF_EXPORT const CFStringRef kCFStringTransformLatinHiragana; +CF_EXPORT const CFStringRef kCFStringTransformHiraganaKatakana; +CF_EXPORT const CFStringRef kCFStringTransformMandarinLatin; +CF_EXPORT const CFStringRef kCFStringTransformLatinHangul; +CF_EXPORT const CFStringRef kCFStringTransformLatinArabic; +CF_EXPORT const CFStringRef kCFStringTransformLatinHebrew; +CF_EXPORT const CFStringRef kCFStringTransformLatinThai; +CF_EXPORT const CFStringRef kCFStringTransformLatinCyrillic; +CF_EXPORT const CFStringRef kCFStringTransformLatinGreek; +CF_EXPORT const CFStringRef kCFStringTransformToXMLHex; +CF_EXPORT const CFStringRef kCFStringTransformToUnicodeName; +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +CF_EXPORT const CFStringRef kCFStringTransformStripDiacritics; +#endif + +CF_EXPORT void +CFStringAppend (CFMutableStringRef theString, CFStringRef appendedString); + +CF_EXPORT void +CFStringAppendCharacters (CFMutableStringRef theString, + const UniChar *chars, CFIndex numChars); + +CF_EXPORT void +CFStringAppendCString (CFMutableStringRef theString, const char *cStr, + CFStringEncoding encoding); + +CF_EXPORT void +CFStringAppendFormat (CFMutableStringRef theString, + CFDictionaryRef formatOptions, CFStringRef format, ...); + +CF_EXPORT void +CFStringAppendFormatAndArguments (CFMutableStringRef theString, + CFDictionaryRef formatOptions, CFStringRef format, va_list arguments); + +CF_EXPORT void +CFStringAppendPascalString (CFMutableStringRef theString, + ConstStr255Param pStr, CFStringEncoding encoding); + +CF_EXPORT void +CFStringCapitalize (CFMutableStringRef theString, CFLocaleRef locale); + +CF_EXPORT CFMutableStringRef +CFStringCreateMutable (CFAllocatorRef alloc, CFIndex maxLength); + +CF_EXPORT CFMutableStringRef +CFStringCreateMutableCopy (CFAllocatorRef alloc, CFIndex maxLength, + CFStringRef theString); + +CF_EXPORT CFMutableStringRef +CFStringCreateMutableWithExternalCharactersNoCopy (CFAllocatorRef alloc, + UniChar *chars, CFIndex numChars, CFIndex capacity, + CFAllocatorRef externalCharactersAllocator); + +CF_EXPORT void +CFStringDelete (CFMutableStringRef theString, CFRange range); + +CF_EXPORT void +CFStringInsert (CFMutableStringRef str, CFIndex idx, CFStringRef insertedStr); + +CF_EXPORT void +CFStringLowercase (CFMutableStringRef theString, CFLocaleRef locale); + +CF_EXPORT void +CFStringPad (CFMutableStringRef theString, CFStringRef padString, + CFIndex length, CFIndex indexIntoPad); + +CF_EXPORT void +CFStringReplace (CFMutableStringRef theString, CFRange range, + CFStringRef replacement); + +CF_EXPORT void +CFStringReplaceAll (CFMutableStringRef theString, CFStringRef replacement); + +CF_EXPORT void +CFStringSetExternalCharactersNoCopy (CFMutableStringRef theString, + UniChar *chars, CFIndex length, CFIndex capacity); + +CF_EXPORT void +CFStringTrim (CFMutableStringRef theString, CFStringRef trimString); + +CF_EXPORT void +CFStringTrimWhitespace (CFMutableStringRef theString); + +CF_EXPORT void +CFStringUppercase (CFMutableStringRef theString, CFLocaleRef locale); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) +CF_EXPORT CFIndex +CFStringFindAndReplace (CFMutableStringRef theString, + CFStringRef stringToFind, CFStringRef replacementString, + CFRange rangeToSearch, CFOptionFlags compareOptions); + +CF_EXPORT void +CFStringNormalize (CFMutableStringRef theString, + CFStringNormalizationForm theForm); +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT Boolean +CFStringTransform (CFMutableStringRef string, CFRange *range, + CFStringRef transform, Boolean reverse); +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +CF_EXPORT void +CFStringFold (CFMutableStringRef theString, CFOptionFlags theFlags, + CFLocaleRef theLocale); +#endif +/** \} */ + + + +/** \ingroup CFStringRef + \name CFStringInlineBuffer + \{ + */ +#define __kCFStringInlineBufferLength 64 +struct CFStringInlineBuffer +{ + UniChar buffer[__kCFStringInlineBufferLength]; + CFStringRef theString; + const UniChar *directBuffer; + CFRange rangeToBuffer; + CFIndex bufferedRangeStart; + CFIndex bufferedRangeEnd; +}; +typedef struct CFStringInlineBuffer CFStringInlineBuffer; + +CF_INLINE void +CFStringInitInlineBuffer (CFStringRef str, CFStringInlineBuffer *buf, + CFRange range) +{ + buf->theString = str; + buf->rangeToBuffer = range; + buf->directBuffer = CFStringGetCharactersPtr (str); + buf->bufferedRangeStart = 0; + buf->bufferedRangeEnd = 0; +} + +CF_INLINE UniChar +CFStringGetCharacterFromInlineBuffer (CFStringInlineBuffer *buf, CFIndex idx) +{ + if (buf->directBuffer) + { + if (idx < 0 || idx >= buf->rangeToBuffer.length) + return 0; + return buf->directBuffer[idx + buf->rangeToBuffer.location]; + } + else if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) + { + CFRange range; + + if (idx < 0 || idx >= buf->rangeToBuffer.length) + return 0; + + /* Use 16 here so it's efficient to go backwards, too */ + buf->bufferedRangeStart = idx - 16; + if (buf->bufferedRangeStart < 0) + buf->bufferedRangeStart = 0; + buf->bufferedRangeEnd = + buf->bufferedRangeStart + __kCFStringInlineBufferLength; + if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) + buf->bufferedRangeEnd = buf->rangeToBuffer.length; + + range = CFRangeMake (buf->rangeToBuffer.location + buf->bufferedRangeStart, + buf->bufferedRangeEnd - buf->bufferedRangeStart); + + CFStringGetCharacters (buf->theString, range, buf->buffer); + } + + return buf->buffer[(idx - buf->bufferedRangeStart)]; +} +/** \} */ + +CF_EXTERN_C_END + +#endif /* __COREFOUNDATION_CFSTRING_H__ */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSArray.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSArray.h new file mode 100644 index 00000000000..661e90faf89 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSArray.h @@ -0,0 +1,430 @@ +/* Interface for NSArray for GNUStep + Copyright (C) 1995-2015 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum + Created: 1995 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + */ + +#ifndef __NSArray_h_GNUSTEP_BASE_INCLUDE +#define __NSArray_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +#import "NSObject.h" +#import "NSRange.h" +#import "NSEnumerator.h" +#if __BLOCKS__ +#import "../GNUstepBase/GSBlocks.h" +#endif + +#if defined(__cplusplus) +extern "C" { +#endif + +@class NSString; +@class NSURL; +@class NSIndexSet; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +enum +{ + NSBinarySearchingFirstEqual = (1UL << 8), /** Specifies that the binary + * search should find the first object equal in the array. + */ + NSBinarySearchingLastEqual = (1UL << 9), /** Specifies that the binary + * search should find the last object equal in the array. + */ + NSBinarySearchingInsertionIndex = (1UL << 10), /** Specifies that the binary + * search should find the index at which an equal object should be inserted + * in order to keep the array sorted + */ +}; + +typedef NSUInteger NSBinarySearchingOptions; +#endif + +@interface GS_GENERIC_CLASS(NSArray, __covariant ElementT) : NSObject + + ++ (instancetype) array; ++ (instancetype) arrayWithArray: (GS_GENERIC_CLASS(NSArray, ElementT) *)array; ++ (instancetype) arrayWithContentsOfFile: (NSString*)file; +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) ++ (instancetype) arrayWithContentsOfURL: (NSURL*)aURL; +#endif ++ (instancetype) arrayWithObject: (id)anObject; ++ (instancetype) arrayWithObjects: (id)firstObject, ...; ++ (instancetype) arrayWithObjects: (const id[])objects count: (NSUInteger)count; + +- (GS_GENERIC_CLASS(NSArray, ElementT) *) arrayByAddingObject: + (GS_GENERIC_TYPE(ElementT))anObject; +- (GS_GENERIC_CLASS(NSArray, ElementT) *) arrayByAddingObjectsFromArray: + (GS_GENERIC_CLASS(NSArray, ElementT)*)anotherArray; +- (BOOL) containsObject: (GS_GENERIC_TYPE(ElementT))anObject; + +/** + * Returns the number of elements contained in the receiver. + */ +- (NSUInteger) count; +- (void) getObjects: (__unsafe_unretained GS_GENERIC_TYPE(ElementT)[])aBuffer; +- (void) getObjects: (__unsafe_unretained GS_GENERIC_TYPE(ElementT)[])aBuffer + range: (NSRange)aRange; +- (NSUInteger) indexOfObject: (GS_GENERIC_TYPE(ElementT))anObject; +- (NSUInteger) indexOfObject: (GS_GENERIC_TYPE(ElementT))anObject + inRange: (NSRange)aRange; +- (NSUInteger) indexOfObjectIdenticalTo: (GS_GENERIC_TYPE(ElementT))anObject; +- (NSUInteger) indexOfObjectIdenticalTo: (GS_GENERIC_TYPE(ElementT))anObject + inRange: (NSRange)aRange; +- (instancetype) init; +- (instancetype) initWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)array; +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +- (instancetype) initWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)array + copyItems: (BOOL)shouldCopy; +#endif +- (instancetype) initWithContentsOfFile: (NSString*)file; +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +- (instancetype) initWithContentsOfURL: (NSURL*)aURL; +#endif +- (instancetype) initWithObjects: (GS_GENERIC_TYPE(ElementT)) firstObject, ...; + +/** + * This should initialize the array with count (may be zero) objects.
+ * Retains each object placed in the array.
+ * Calls -init (which does nothing but maintain MacOS-X compatibility), + * and needs to be re-implemented in subclasses in order to have all + * other initialisers work. + */ +- (instancetype) initWithObjects: (const GS_GENERIC_TYPE(ElementT)[])objects + count: (NSUInteger)count; +- (GS_GENERIC_TYPE(ElementT)) lastObject; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +- (GS_GENERIC_TYPE(ElementT)) firstObject; +#endif + +/** + * Returns the object at the specified index. + * Raises an exception of the index is beyond the array. + */ +- (GS_GENERIC_TYPE(ElementT)) objectAtIndex: (NSUInteger)index; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +- (GS_GENERIC_CLASS(NSArray, ElementT) *) objectsAtIndexes: + (NSIndexSet *)indexes; +#endif + +- (GS_GENERIC_TYPE(ElementT)) firstObjectCommonWithArray: + (GS_GENERIC_CLASS(NSArray, ElementT) *)otherArray; +- (BOOL) isEqualToArray: (NSArray*)otherArray; + +#if OS_API_VERSION(GS_API_OPENSTEP, GS_API_MACOSX) +- (void) makeObjectsPerform: (SEL)aSelector; +- (void) makeObjectsPerform: (SEL)aSelector withObject: (id)argument; +#endif +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +- (void) makeObjectsPerformSelector: (SEL)aSelector; +- (void) makeObjectsPerformSelector: (SEL)aSelector withObject: (id)arg; +#endif + +- (NSData*) sortedArrayHint; +- (GS_GENERIC_CLASS(NSArray, ElementT)*) sortedArrayUsingFunction: + (NSComparisonResult (*)(id, id, void*))comparator + context: (void*)context; +- (GS_GENERIC_CLASS(NSArray, ElementT)*) sortedArrayUsingFunction: + (NSComparisonResult (*)(id, id, void*))comparator + context: (void*)context + hint: (NSData*)hint; +- (GS_GENERIC_CLASS(NSArray, ElementT)*) sortedArrayUsingSelector: + (SEL)comparator; +- (GS_GENERIC_CLASS(NSArray, ElementT)*) subarrayWithRange: (NSRange)aRange; + +- (NSString*) componentsJoinedByString: (NSString*)separator; +- (GS_GENERIC_CLASS(NSArray, NSString*)*) pathsMatchingExtensions: + (GS_GENERIC_CLASS(NSArray, NSString*)*)extensions; + +- (GS_GENERIC_CLASS(NSEnumerator, ElementT)*) objectEnumerator; +- (GS_GENERIC_CLASS(NSEnumerator, ElementT)*) reverseObjectEnumerator; + +- (NSString*) description; +- (NSString*) descriptionWithLocale: (id)locale; +- (NSString*) descriptionWithLocale: (id)locale + indent: (NSUInteger)level; + +- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile; +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +- (BOOL) writeToURL: (NSURL*)url atomically: (BOOL)useAuxiliaryFile; +- (GS_GENERIC_TYPE(ElementT)) valueForKey: (NSString*)key; +- (void) setValue: (GS_GENERIC_TYPE(ElementT))value forKey: (NSString*)key; +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) + +#if __BLOCKS__ +DEFINE_BLOCK_TYPE(GSEnumeratorBlock, void, GS_GENERIC_TYPE(ElementT), + NSUInteger, BOOL*); +DEFINE_BLOCK_TYPE(GSPredicateBlock, BOOL, GS_GENERIC_TYPE(ElementT), + NSUInteger, BOOL*); +/** + * Enumerate over the collection using the given block. The first argument is + * the object and the second is the index in the array. The final argument is + * a pointer to a BOOL indicating whether the enumeration should stop. Setting + * this to YES will interrupt the enumeration. + */ +- (void) enumerateObjectsUsingBlock: (GSEnumeratorBlock)aBlock; + +/** + * Enumerate over the collection using the given block. The first argument is + * the object and the second is the index in the array. The final argument is + * a pointer to a BOOL indicating whether the enumeration should stop. Setting + * this to YES will interrupt the enumeration. + * + * The opts argument is a bitfield. Setting the NSNSEnumerationConcurrent flag + * specifies that it is thread-safe. The NSEnumerationReverse bit specifies + * that it should be enumerated in reverse order. + */ +- (void) enumerateObjectsWithOptions: (NSEnumerationOptions)opts + usingBlock: (GSEnumeratorBlock)aBlock; +/** + * Enumerate over the specified indexes in the collection using the given + * block. The first argument is the object and the second is the index in the + * array. The final argument is a pointer to a BOOL indicating whether the + * enumeration should stop. Setting this to YES will interrupt the + * enumeration. + * + * The opts argument is a bitfield. Setting the NSNSEnumerationConcurrent flag + * specifies that it is thread-safe. The NSEnumerationReverse bit specifies + * that it should be enumerated in reverse order. + */ +- (void) enumerateObjectsAtIndexes: (NSIndexSet*)indexSet + options: (NSEnumerationOptions)opts + usingBlock: (GSEnumeratorBlock)block; +/** + * Returns the indexes of the objects in a collection that match the condition + * specified by the block. + * + * The opts argument is a bitfield. Setting the NSNSEnumerationConcurrent flag + * specifies that it is thread-safe. The NSEnumerationReverse bit specifies + * that it should be enumerated in reverse order. + */ +- (NSIndexSet *) indexesOfObjectsWithOptions: (NSEnumerationOptions)opts + passingTest: (GSPredicateBlock)predicate; + +/** + * Returns the indexes of the objects in a collection that match the condition + * specified by the block. + */ +- (NSIndexSet*) indexesOfObjectsPassingTest: (GSPredicateBlock)predicate; + +/** + * Returns the indexes of the objects in a collection that match the condition + * specified by the block and are in the range specified by the index set. + * + * The opts argument is a bitfield. Setting the NSNSEnumerationConcurrent flag + * specifies that it is thread-safe. The NSEnumerationReverse bit specifies + * that it should be enumerated in reverse order. + */ +- (NSIndexSet*) indexesOfObjectsAtIndexes: (NSIndexSet*)indexSet + options: (NSEnumerationOptions)opts + passingTest: (GSPredicateBlock)predicate; + +/** + * Returns the index of the first object in the array that matches the + * condition specified by the block. + * + * The opts argument is a bitfield. Setting the NSNSEnumerationConcurrent flag + * specifies that it is thread-safe. The NSEnumerationReverse bit specifies + * that it should be enumerated in reverse order. + */ +- (NSUInteger) indexOfObjectWithOptions: (NSEnumerationOptions)opts + passingTest: (GSPredicateBlock)predicate; + +/** + * Returns the index of the first object in the array that matches the + * condition specified by the block. + */ +- (NSUInteger) indexOfObjectPassingTest: (GSPredicateBlock)predicate; + +/** + * Returns the index of the first object in the specified range in a collection + * that matches the condition specified by the block. + * + * The opts argument is a bitfield. Setting the NSNSEnumerationConcurrent flag + * specifies that it is thread-safe. The NSEnumerationReverse bit specifies + * that it should be enumerated in reverse order. + */ +- (NSUInteger) indexOfObjectAtIndexes: (NSIndexSet*)indexSet + options: (NSEnumerationOptions)opts + passingTest: (GSPredicateBlock)predicate; + +/** Returns a sorted array using the comparator to determine the + * order of objects. + */ +- (GS_GENERIC_CLASS(NSArray, ElementT) *) sortedArrayUsingComparator: + (NSComparator)comparator; + +/** Returns a sorted array using the block to determine the order of objects. + * + * The opts argument is a bitfield. Setting the NSSortConcurrent flag + * specifies that it is thread-safe. The NSSortStable bit specifies that + * it should keep equal objects in the same order. + */ +- (GS_GENERIC_CLASS(NSArray, ElementT) *) + sortedArrayWithOptions: (NSSortOptions)options + usingComparator: (NSComparator)comparator; + +/** + * Performs a binary search of the array within the specified range for the + * index of an object equal to obj according to cmp. + * If NSBinarySearchingInsertionIndex is specified, searches for the index + * at which such an object should be inserted. + */ +- (NSUInteger) indexOfObject: (id)key + inSortedRange: (NSRange)range + options: (NSBinarySearchingOptions)options + usingComparator: (NSComparator)comparator; +#endif +#endif +/** + * Accessor for subscripting. This is called by the compiler when you write + * code like anArray[12]. It should not be called directly. + */ +- (GS_GENERIC_TYPE(ElementT)) objectAtIndexedSubscript: (NSUInteger)anIndex; +@end + + +@interface GS_GENERIC_CLASS(NSMutableArray, ElementT) : NSArray + ++ (instancetype) arrayWithCapacity: (NSUInteger)numItems; + +/** + * Adds anObject at the end of the array, thus increasing the size of + * the array. The object is retained upon addition. + */ +- (void) addObject: (GS_GENERIC_TYPE(ElementT))anObject; +- (void) addObjectsFromArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)otherArray; +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +- (void) exchangeObjectAtIndex: (NSUInteger)i1 + withObjectAtIndex: (NSUInteger)i2; +#endif + +/** + * Initialise the array with the specified capacity ... this + * should ensure that the array can have numItems added efficiently.
+ * Calls -init (which does nothing but maintain MacOS-X compatibility), + * and needs to be re-implemented in subclasses in order to have all + * other initialisers work. + */ +- (instancetype) initWithCapacity: (NSUInteger)numItems; + +/** + * Inserts an object into the receiver at the specified location.
+ * Raises an exception if given an array index which is too large.
+ * The size of the array increases by one.
+ * The object is retained by the array. + */ +- (void) insertObject: (GS_GENERIC_TYPE(ElementT))anObject + atIndex: (NSUInteger)index; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +- (void) insertObjects: (GS_GENERIC_CLASS(NSArray, ElementT) *)objects + atIndexes: (NSIndexSet *)indexes; +#endif + +/** + * Removes an object from the receiver at the specified location.
+ * The size of the array decreases by one.
+ * Raises an exception if given an array index which is too large.
+ */ +- (void) removeObjectAtIndex: (NSUInteger)index; + +- (void) removeObjectsAtIndexes: (NSIndexSet *)indexes; + +/** + * Places an object into the receiver at the specified location.
+ * Raises an exception if given an array index which is too large.
+ * The object is retained by the array. + */ +- (void) replaceObjectAtIndex: (NSUInteger)index + withObject: (GS_GENERIC_TYPE(ElementT))anObject; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +- (void) replaceObjectsAtIndexes: (NSIndexSet *)indexes + withObjects: (GS_GENERIC_CLASS(NSArray, ElementT)*)objects; +#endif + +- (void) replaceObjectsInRange: (NSRange)aRange + withObjectsFromArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)anArray; + +- (void) replaceObjectsInRange: (NSRange)aRange + withObjectsFromArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)anArray + range: (NSRange)anotherRange; + +- (void) setArray: (GS_GENERIC_CLASS(NSArray, ElementT) *)otherArray; + +- (void) removeAllObjects; +- (void) removeLastObject; +- (void) removeObject: (GS_GENERIC_TYPE(ElementT))anObject; +- (void) removeObject: (GS_GENERIC_TYPE(ElementT))anObject + inRange: (NSRange)aRange; +- (void) removeObjectIdenticalTo: (GS_GENERIC_TYPE(ElementT))anObject; +- (void) removeObjectIdenticalTo: (GS_GENERIC_TYPE(ElementT))anObject + inRange: (NSRange)aRange; +- (void) removeObjectsInArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)otherArray; +- (void) removeObjectsInRange: (NSRange)aRange; +- (void) removeObjectsFromIndices: (NSUInteger*)indices + numIndices: (NSUInteger)count; + +- (void) sortUsingFunction: + (NSComparisonResult (*)(GS_GENERIC_TYPE(ElementT), + GS_GENERIC_TYPE(ElementT),void*))compare + context: (void*)context; +- (void) sortUsingSelector: (SEL)comparator; + + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +#if __BLOCKS__ +/** + * Sorts the array using the specified comparator block. + */ +- (void) sortUsingComparator: (NSComparator)comparator; + +/** + * Sorts the array using the specified comparator block and options. + */ +- (void) sortWithOptions: (NSSortOptions)options + usingComparator: (NSComparator)comparator; +#endif +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_8, GS_API_LATEST) +/** Set method called by the compiler with array subscripting.
+ * Replaces the object at anIndex or, if anIndex is the length of the array, + * this method appends abObject to the array. + */ +- (void) setObject: (GS_GENERIC_TYPE(ElementT))anObject +atIndexedSubscript: (NSUInteger)anIndex; +#endif +@end + +#if defined(__cplusplus) +} +#endif + +#if !NO_GNUSTEP && !defined(GNUSTEP_BASE_INTERNAL) +#import "../GNUstepBase/NSArray+GNUstepBase.h" +#endif + +#endif /* __NSArray_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSAutoreleasePool.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSAutoreleasePool.h new file mode 100644 index 00000000000..c7ec486ddde --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSAutoreleasePool.h @@ -0,0 +1,333 @@ +/* Interface for NSAutoreleasePool for GNUStep + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum + Date: 1995 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + */ + +#ifndef __NSAutoreleasePool_h_GNUSTEP_BASE_INCLUDE +#define __NSAutoreleasePool_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +#import "NSObject.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +@class NSAutoreleasePool; +@class NSThread; + + +/** + * Each thread has its own copy of these variables. + +{ + NSAutoreleasePool *current_pool; // current pool for thread + unsigned total_objects_count; // total #/autoreleased objects over thread's lifetime + id *pool_cache; // cache of previously-allocated pools, + int pool_cache_size; // used internally for recycling + int pool_cache_count; +} + +*/ +typedef struct autorelease_thread_vars +{ + /* The current, default NSAutoreleasePool for the calling thread; + the one that will hold objects that are arguments to + [NSAutoreleasePool +addObject:]. */ + __unsafe_unretained NSAutoreleasePool *current_pool; + + /* The total number of objects autoreleased since the thread was + started, or since -resetTotalAutoreleasedObjects was called + in this thread. (if compiled in) */ + unsigned total_objects_count; + + /* A cache of NSAutoreleasePool's already alloc'ed. Caching old pools + instead of deallocating and re-allocating them will save time. */ + __unsafe_unretained id *pool_cache; + int pool_cache_size; + int pool_cache_count; +} thread_vars_struct; + +/* Initialize an autorelease_thread_vars structure for a new thread. + This function is called in NSThread each time an NSThread is created. + TV should be of type `struct autorelease_thread_vars *' */ +#define init_autorelease_thread_vars(TV) \ +memset (TV, 0, sizeof (__typeof__ (*TV))) + + + +/** + * Each pool holds its objects-to-be-released in a linked-list of + these structures. + +{ + struct autorelease_array_list *next; + unsigned size; + unsigned count; + id objects[0]; +} + + */ +typedef struct autorelease_array_list +{ + struct autorelease_array_list *next; + unsigned size; + unsigned count; + __unsafe_unretained id objects[0]; +} array_list_struct; + + + +/** + *

+ * The standard OpenStep system of memory management employs retain counts. + * When an object is created, it has a retain count of 1. When an object + * is retained, the retain count is incremented. When it is released the + * retain count is decremented, and when the retain count goes to zero the + * object gets deallocated. + *

+ *

+ * A simple retain/release mechanism has problems with passing objects + * from one scope to another, + * so it's augmented with autorelease pools. You can use the + * AUTORELEASE() macro to call the [NSObject-autorelease] + * method, which adds an object to the current autorelease pool by + * calling [NSAutoreleasePool+addObject:].
+ * An autorelease pool simply maintains a reference to each object + * added to it, and for each addition, the autorelease pool will + * call the [NSObject-release] method of the object when the pool + * is released. So doing an AUTORELEASE() is just the same as + * doing a RELEASE(), but deferred until the current autorelease + * pool is deallocated. + *

+ *

+ * The NSAutoreleasePool class maintains a separate stack of + * autorelease pools objects in each thread. + *

+ *

+ * When an autorelease pool is created, it is automatically + * added to the stack of pools in the thread. + *

+ *

+ * When a pool is destroyed, it (and any pool later in + * the stack) is removed from the stack. + *

+ *

+ * This mechanism provides a simple but controllable and reasonably + * efficient way of managing temporary objects. An object can be + * autoreleased and then passed around and used until the topmost + * pool in the stack is destroyed. + *

+ *

+ * Most methods return objects which are either owned by autorelease + * pools or by the receiver of the method, so the lifetime of the + * returned object can be assumed to be the shorter of the lifetime + * of the current autorelease pool, or that of the receiver on which + * the method was called.
+ * The exceptions to this are those object returned by - + *

+ * + * [NSObject+alloc], [NSObject+allocWithZone:] + * + * Methods whose names begin with alloc return an uninitialised + * object, owned by the caller. + * + * [NSObject-init] + * + * Methods whose names begin with init return an initialised + * version of the receiving object, owned by the caller.
+ * NB. The returned object may not actually be the same as the + * receiver ... sometimes an init method releases the original + * receiver and returns an alternative. + *
+ * [NSObject+new] + * + * Methods whose names begin with new combine the effects of + * allocation and initialisation. + * + * [NSObject-copy], [(NSCopying)-copyWithZone:] + * + * Methods whose names begin with copy create a copy of the receiver + * which is owned by the caller. + * + * + * [NSObject-mutableCopy], [(NSMutableCopying)-mutableCopyWithZone:] + * + * + * Methods whose names begin with mutableCopy create a copy of the receiver + * which is owned by the caller. + * + *
+ */ +NS_AUTOMATED_REFCOUNT_UNAVAILABLE +@interface NSAutoreleasePool : NSObject +{ +#if GS_EXPOSE(NSAutoreleasePool) && !__has_feature(objc_arc) + /* For re-setting the current pool when we are dealloc'ed. */ + NSAutoreleasePool *_parent; + /* This pointer to our child pool is necessary for co-existing + with exceptions. */ + NSAutoreleasePool *_child; + /* A collection of the objects to be released. */ + struct autorelease_array_list *_released; + struct autorelease_array_list *_released_head; + /* The total number of objects autoreleased in this pool. */ + unsigned _released_count; + /* The method to add an object to this pool */ + void (*_addImp)(id, SEL, id); +#endif +#if GS_NONFRAGILE +#else + /* Pointer to private additional data used to avoid breaking ABI + * when we don't have the non-fragile ABI available. + * Use this mechanism rather than changing the instance variable + * layout (see Source/GSInternal.h for details). + */ + @private id _internal GS_UNUSED_IVAR; +#endif +} + +/** + * Adds anObj to the current autorelease pool.
+ * If there is no autorelease pool in the thread, + * a warning is logged and the object is leaked (ie it will not be released). + */ ++ (void) addObject: (id)anObj; + +/** + * Allocate and return an autorelease pool instance.
+ * If there is an already-allocated NSAutoreleasePool available, + * save time by just returning that, rather than allocating a new one.
+ * The pool instance becomes the current autorelease pool for this thread. + */ ++ (id) allocWithZone: (NSZone*)zone; + +/** + * Adds anObj to this autorelease pool. + */ +- (void) addObject: (id)anObj; + +/** + * Raises an exception - pools should not be autoreleased. + */ +- (id) autorelease; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +/** + * Intended to trigger a garbage collection run (if needed) when called in + * a garbage collected environment.
+ * In a non-garbage collected environment, this method implements the + * undocumented MacOS-X behavior, and releases the receiver. + */ +- (void) drain; +#endif + +/** + * Destroys the receiver (calls -dealloc). + */ +- (oneway void) release; + +/** + * Raises an exception ... pools should not be retained. + */ +- (id) retain; + +#if OS_API_VERSION(GS_API_NONE, GS_API_NONE) +/** + *

+ * Counts the number of times that the specified object occurs + * in autorelease pools in the current thread. + *

+ *

+ * This method is slow and should probably only be + * used for debugging purposes. + *

+ */ ++ (unsigned) autoreleaseCountForObject: (id)anObject; + +/** + * Return the currently active autorelease pool. + */ ++ (id) currentPool; + +/** + *

+ * Specifies whether objects contained in autorelease pools are to + * be released when the pools are deallocated (by default YES). + *

+ *

+ * You can set this to NO for debugging purposes. + *

+ */ ++ (void) enableRelease: (BOOL)enable; + +/** + *

+ * When autorelease pools are deallocated, the memory they used + * is retained in a cache for re-use so that new polls can be + * created very quickly. + *

+ *

+ * This method may be used to empty that cache, ensuring that + * the minimum memory is used by the application. + *

+ */ ++ (void) freeCache; + +/** + *

+ * Specifies a limit to the number of objects that may be added to + * an autorelease pool. When this limit is reached an exception is + * raised. + *

+ *

+ * You can set this to a smallish value to catch problems with code + * that autoreleases too many objects to operate efficiently. + *

+ *

+ * Default value is maxint. + *

+ */ ++ (void) setPoolCountThreshold: (unsigned)c; + +/** + * Return the number of objects in this pool. + */ +- (unsigned) autoreleaseCount; + +/** + * Empties the current pool by releasing all the autoreleased objects + * in it. Also destroys any child pools (ones created after + * the receiver in the same thread) causing any objects in those pools + * to be released.
+ * This is a low cost (efficient) method which may be used to get rid of + * autoreleased objects in the pool, but carry on using the pool. + */ +- (void) emptyPool; +#endif +@end + +#if defined(__cplusplus) +} +#endif + +#endif /* __NSAutoreleasePool_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSDate.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSDate.h new file mode 100644 index 00000000000..dbec39e46e9 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSDate.h @@ -0,0 +1,300 @@ +/* Interface for NSDate for GNUStep + Copyright (C) 1994, 1996, 1999 Free Software Foundation, Inc. + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + */ + +#ifndef __NSDate_h_GNUSTEP_BASE_INCLUDE +#define __NSDate_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +#import "NSObjCRuntime.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +GS_EXPORT NSString * const NSSystemClockDidChangeNotification; + +/** + * Time interval difference between two dates, in seconds. + */ +typedef double NSTimeInterval; + +/** + * Time interval between the unix standard reference date of 1 January 1970 + * and the OpenStep reference date of 1 January 2001
+ * This number comes from:
+ * (((31 years * 365 days) + 8 days for leap years) = total number of days
+ * 24 hours * 60 minutes * 60 seconds)
+ * This ignores leap-seconds. + */ +GS_EXPORT const NSTimeInterval NSTimeIntervalSince1970; + +#import "NSObject.h" + +@class NSArray; +@class NSCalendarDate; +@class NSData; +@class NSDictionary; +@class NSString; +@class NSTimeZone; +@class NSTimeZoneDetail; + +@interface NSDate : NSObject +{ +} + +/** Returns an autoreleased instance with the current date/time. + */ ++ (id) date; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** Returns an autoreleased instance representing the date and time given + * by string. The value of string may be a 'natural' specification as + * specified by the preferences in the user defaults database, allowing + * phrases like 'last tuesday' + */ ++ (id) dateWithNaturalLanguageString: (NSString*)string; + +/** + *

Returns an autoreleased instance representing the date and time given + * by string. The value of string may be a 'natural' specification as + * specified by the preferences in the user defaults database, allowing + * phrases like 'last tuesday' + *

+ * The locale contains keys such as - + * + * NSDateTimeOrdering + * Controls the use of ambiguous numbers. This is done as a + * sequence of the letters D(ay), M(onth), Y(ear), and H(our). + * YMDH means that the first number encountered is assumed to be a + * year, the second a month, the third a day, and the last an hour. + * + * NSEarlierTimeDesignations + * An array of strings for times in the past.
+ * Defaults are ago, last, past, prior + *
+ * NSHourNameDesignations + * An array of arrays of strings identifying the time of day. + * Each array has an hour as its first value, and one or more words + * as subsequent values.
+ * Defaults are: (0, midnight), (10, morning), (12, noon, lunch), + * (14, afternoon), (19, dinner). + *
+ * NSLaterTimeDesignations + * An array of strings for times in the future.
+ * Default is next + *
+ * NSNextDayDesignations + * The day after today. Default is tomorrow. + * + * NSNextNextDayDesignations + * The day after tomorrow. Default is nextday. + * + * NSPriorDayDesignations + * The day before today. Default is yesterday. + * + * NSThisDayDesignations + * Identifies the current day. Default is today. + * + * NSYearMonthWeekDesignations + * An array giving the word for year, month, and week.
+ * Defaults are year, month and week. + *
+ *
+ */ ++ (id) dateWithNaturalLanguageString: (NSString*)string + locale: (NSDictionary*)locale; +#endif + +/** Returns an autoreleased instance with the date and time value given + * by the string using the ISO standard format YYYY-MM-DD HH:MM:SS +/-HHHMM + * (all the fields of which must be present). + */ ++ (id) dateWithString: (NSString*)description; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST) +/** Returns an autoreleased NSDate instance whose value is offset from + * that of the given date by the specified interval in seconds. + */ ++ (id) dateWithTimeInterval: (NSTimeInterval)seconds sinceDate: (NSDate*)date; +#endif + +/** Returns an autoreleased instance with the offset from the unix system + * reference date of 1 January 1970, GMT. + */ ++ (id) dateWithTimeIntervalSince1970: (NSTimeInterval)seconds; + +/** Returns an autoreleased instance with the offset from the current + * date/time given by seconds (which may be fractional). + */ ++ (id) dateWithTimeIntervalSinceNow: (NSTimeInterval)seconds; + +/** Returns an autoreleased instance with the offset from the OpenStep + * reference date of 1 January 2001, GMT. + */ ++ (id) dateWithTimeIntervalSinceReferenceDate: (NSTimeInterval)seconds; + +/** Returns an autoreleased instance with the date/time set in the far + * past. + */ ++ (id) distantPast; + +/** Returns an autoreleased instance with the date/time set in the far + * future. + */ ++ (id) distantFuture; + +/** Returns the time interval between the reference date and the current + * time. + */ ++ (NSTimeInterval) timeIntervalSinceReferenceDate; + +/** Returns an autorelease date instance formed by adding the specified + * time interval in seconds to the receiver's time interval. + */ +- (id) addTimeInterval: (NSTimeInterval)seconds; + +/** Returns the time interval between the receivers value and the + * OpenStep reference date of 1 Jan 2001 GMT. + */ +- (NSComparisonResult) compare: (NSDate*)otherDate; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST) +/** Returns an autoreleased NSDate instance whose value is offset from + * that of the receiver by the specified interval. + */ +- (id) dateByAddingTimeInterval: (NSTimeInterval)ti; +#endif + +/** Returns an autoreleased instance of the [NSCalendarDate] class whose + * date/time value is the same as that of the receiver, and which uses + * the formatString and timeZone specified. + */ +- (NSCalendarDate*) dateWithCalendarFormat: (NSString*)formatString + timeZone: (NSTimeZone*)timeZone; + +/** Returns a string representation of the receiver formatted according + * to the default format string, time zone, and locale. + */ +- (NSString*) description; + +/** Returns a string representation of the receiver formatted according + * to the specified format string, time zone, and locale. + */ +- (NSString*) descriptionWithCalendarFormat: (NSString*)format + timeZone: (NSTimeZone*)aTimeZone + locale: (NSDictionary*)l; + +/** Returns a string representation of the receiver formatted according + * to the default format string and time zone, but using the given locale. + */ +- (NSString*) descriptionWithLocale: (id)locale; + +/** Returns the earlier of the receiver and otherDate.
+ * If the two represent identical date/time values, returns the receiver. + */ +- (NSDate*) earlierDate: (NSDate*)otherDate; + +/** Returns an instance initialised with the current date/time. + */ +- (id) init; + +/** Returns an instance with the date and time value given + * by the string using the ISO standard format YYYY-MM-DD HH:MM:SS +/-HHHMM + * (all the fields of which must be present). + */ +- (id) initWithString: (NSString*)description; + +/** Returns an instance with the given offset from anotherDate. + */ +- (id) initWithTimeInterval: (NSTimeInterval)secsToBeAdded + sinceDate: (NSDate*)anotherDate; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** Returns an instance with the offset from the unix system + * reference date of 1 January 1970, GMT. + */ +- (id) initWithTimeIntervalSince1970: (NSTimeInterval)seconds; +#endif + +/** Returns an instance with the offset from the current date/time. + */ +- (id) initWithTimeIntervalSinceNow: (NSTimeInterval)secsToBeAdded; + +/** + * Returns an instance with the given offset from the OpenStep + * reference date of 1 January 2001, GMT. + */ +- (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)secs; + +/** Returns NO if other is not a date, otherwise returns the result of + * calling the -isEqualtoDate: method. + */ +- (BOOL) isEqual: (id)other; + +/** Returns whether the receiver is exactly equal to other, to the limit + * of the NSTimeInterval precision.
+ * This is the behavior of the current MacOS-X system, not that of the + * OpenStep specification (which counted two dates within a second of + * each other as being equal).
+ * The old behavior meant that two dates equal to a third date were not + * necessarily equal to each other (confusing), and meant that there was + * no reasonable way to use a date as a dictionary key or store dates + * in a set. + */ +- (BOOL) isEqualToDate: (NSDate*)other; + +/** Returns the earlier of the receiver and otherDate.
+ * If the two represent identical date/time values, returns the receiver. + */ +- (NSDate*) laterDate: (NSDate*)otherDate; + +/** Returns the time interval between the receivers value and the + * unix system reference date of 1 January 1970, GMT. + */ +- (NSTimeInterval) timeIntervalSince1970; + +/** Returns the time interval between the receivers value and that of the + * otherDate argument. If otherDate is earlier than the receiver, the + * returned value will be positive, if it is later it will be negative.
+ * For current (2011) OSX compatibility, this method returns NaN if otherDate + * is nil ... do not write code depending on that behavior. + */ +- (NSTimeInterval) timeIntervalSinceDate: (NSDate*)otherDate; + +/** Returns the time interval between the receivers value and the + * current date/time. If the receiver represents a date/time in + * the past this will be negative, if it is in the future the + * returned value will be positive. + */ +- (NSTimeInterval) timeIntervalSinceNow; + +/** Returns the time interval between the receivers value and the + * OpenStep reference date of 1 Jan 2001 GMT. + */ +- (NSTimeInterval) timeIntervalSinceReferenceDate; + +@end + +#if defined(__cplusplus) +} +#endif + +#endif /* __NSDate_h_GNUSTEP_BASE_INCLUDE*/ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSEnumerator.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSEnumerator.h new file mode 100644 index 00000000000..5f31abdf13d --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSEnumerator.h @@ -0,0 +1,63 @@ +/* + NSEnumerator.h + + Copyright (C) 1998 Free Software Foundation, Inc. + + Author: Scott Christley + Date: January 1998 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. +*/ + +#ifndef __NSEnumerator_h_GNUSTEP_BASE_INCLUDE +#define __NSEnumerator_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +#import "NSObject.h" + + +#if defined(__cplusplus) +extern "C" { +#endif + +@class GS_GENERIC_CLASS(NSArray, ElementT); + +typedef struct +{ + unsigned long state; + __unsafe_unretained id *itemsPtr; + unsigned long *mutationsPtr; + unsigned long extra[5]; +} NSFastEnumerationState; + +@protocol NSFastEnumeration +- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState *)state + objects: (__unsafe_unretained id[])stackbuf + count: (NSUInteger)len; +@end + +@interface GS_GENERIC_CLASS(NSEnumerator, IterT) : NSObject +- (GS_GENERIC_CLASS(NSArray, IterT) *) allObjects; +- (GS_GENERIC_TYPE(IterT)) nextObject; +@end + +#if defined(__cplusplus) +} +#endif + +#endif /* __NSEnumerator_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSGeometry.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSGeometry.h new file mode 100644 index 00000000000..05888b7d206 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSGeometry.h @@ -0,0 +1,609 @@ +/* Interface for NSGeometry routines for GNUStep + * Copyright (C) 1995 Free Software Foundation, Inc. + * + * Written by: Adam Fedor + * Date: 1995,199 + * + * This file is part of the GNUstep Base Library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02111 USA. + */ + +#ifndef __NSGeometry_h_GNUSTEP_BASE_INCLUDE +#define __NSGeometry_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +#import + +#import "NSString.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +/**** Type, Constant, and Macro Definitions **********************************/ + +#ifndef MAX +#define MAX(a,b) \ + ({__typeof__(a) _MAX_a = (a); __typeof__(b) _MAX_b = (b); \ + _MAX_a > _MAX_b ? _MAX_a : _MAX_b; }) +#define GS_DEFINED_MAX +#endif + +#ifndef MIN +#define MIN(a,b) \ + ({__typeof__(a) _MIN_a = (a); __typeof__(b) _MIN_b = (b); \ + _MIN_a < _MIN_b ? _MIN_a : _MIN_b; }) +#define GS_DEFINED_MIN +#endif + +/** +{ + CGFloat x; + CGFloat y; +} +

Represents a 2-d cartesian position.

*/ +typedef struct _NSPoint NSPoint; +struct _NSPoint +{ + CGFloat x; + CGFloat y; +}; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** Array of NSPoint structs. */ +typedef NSPoint *NSPointArray; +/** Pointer to NSPoint struct. */ +typedef NSPoint *NSPointPointer; +#endif + +/** +{ + CGFloat width; + CGFloat height; +} +

Floating point rectangle size.

*/ +typedef struct _NSSize NSSize; +struct _NSSize +{ + CGFloat width; + CGFloat height; +}; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** Array of NSSize structs. */ +typedef NSSize *NSSizeArray; +/** Pointer to NSSize struct. */ +typedef NSSize *NSSizePointer; +#endif + +/** +{ + NSPoint origin; + NSSize size; +} + +

Rectangle.

*/ +typedef struct _NSRect NSRect; +struct _NSRect +{ + NSPoint origin; + NSSize size; +}; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** Array of NSRect structs. */ +typedef NSRect *NSRectArray; +/** Pointer to NSRect struct. */ +typedef NSRect *NSRectPointer; +#endif + +enum +{ + NSMinXEdge = 0, + NSMinYEdge = 1, + NSMaxXEdge = 2, + NSMaxYEdge = 3 +}; +/** Sides of a rectangle. + +{ + NSMinXEdge, + NSMinYEdge, + NSMaxXEdge, + NSMaxYEdge +} + + */ +typedef NSUInteger NSRectEdge; + +/** +{ + CGFloat top; + CGFloat left; + CGFloat bottom; + CGFloat right; +} + +

A description of the distance between the edges of two rectangles.

*/ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST) +typedef struct NSEdgeInsets { + CGFloat top; + CGFloat left; + CGFloat bottom; + CGFloat right; +} NSEdgeInsets; +#endif + +/** Point at 0,0 */ +static const NSPoint NSZeroPoint __attribute__((unused)) = {0.0,0.0}; +/** Zero-size rectangle at 0,0 */ +static const NSRect NSZeroRect __attribute__((unused)) = {{0.0,0.0},{0.0,0.0}}; +/** Zero size */ +static const NSSize NSZeroSize __attribute__((unused)) = {0.0,0.0}; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST) +/** Zero edge insets **/ +static const NSEdgeInsets NSEdgeInsetsZero __attribute__((unused)) = {0.0,0.0,0.0,0.0}; +#endif + +/**** Function Prototypes ****************************************************/ + +/* + * All but the most complex functions are declared static inline in this + * header file so that they are maximally efficient. In order to provide + * true functions (for code modules that don't have this header) this + * header is included in NSGeometry.m where the functions are no longer + * declared inline. + */ +#ifdef IN_NSGEOMETRY_M +#define GS_GEOM_SCOPE extern +#define GS_GEOM_ATTR +#else +#define GS_GEOM_SCOPE static inline +#define GS_GEOM_ATTR __attribute__((unused)) +#endif + +/** Create Basic Structures... **/ + +GS_GEOM_SCOPE NSPoint +NSMakePoint(CGFloat x, CGFloat y) GS_GEOM_ATTR; + +/** Returns an NSPoint having x-coordinate X and y-coordinate Y. */ +GS_GEOM_SCOPE NSPoint +NSMakePoint(CGFloat x, CGFloat y) +{ + NSPoint point; + + point.x = x; + point.y = y; + return point; +} + +GS_GEOM_SCOPE NSSize +NSMakeSize(CGFloat w, CGFloat h) GS_GEOM_ATTR; + +/** Returns an NSSize having width w and height h. */ +GS_GEOM_SCOPE NSSize +NSMakeSize(CGFloat w, CGFloat h) +{ + NSSize size; + + size.width = w; + size.height = h; + return size; +} + +GS_GEOM_SCOPE NSRect +NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h) GS_GEOM_ATTR; + +/** Returns an NSRect having point of origin (x, y) and size {w, h}. */ +GS_GEOM_SCOPE NSRect +NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h) +{ + NSRect rect; + + rect.origin.x = x; + rect.origin.y = y; + rect.size.width = w; + rect.size.height = h; + return rect; +} + +/** Constructs NSEdgeInsets. **/ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST) +GS_GEOM_SCOPE NSEdgeInsets +NSEdgeInsetsMake(CGFloat top, CGFloat left, + CGFloat bottom, CGFloat right) GS_GEOM_ATTR; + +GS_GEOM_SCOPE NSEdgeInsets +NSEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) +{ + NSEdgeInsets edgeInsets; + + edgeInsets.top = top; + edgeInsets.left = left; + edgeInsets.bottom = bottom; + edgeInsets.right = right; + + return edgeInsets; +} + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST) +/** Compares two edge insets for equality. **/ +GS_EXPORT BOOL +NSEdgeInsetsEqual(NSEdgeInsets e1, NSEdgeInsets e2); +#endif + +#endif + +/** Get a Rectangle's Coordinates... **/ + +GS_GEOM_SCOPE CGFloat +NSMaxX(NSRect aRect) GS_GEOM_ATTR; + +/** Returns the greatest x-coordinate value still inside aRect. */ +GS_GEOM_SCOPE CGFloat +NSMaxX(NSRect aRect) +{ + return aRect.origin.x + aRect.size.width; +} + +GS_GEOM_SCOPE CGFloat +NSMaxY(NSRect aRect) GS_GEOM_ATTR; + +/** Returns the greatest y-coordinate value still inside aRect. */ +GS_GEOM_SCOPE CGFloat +NSMaxY(NSRect aRect) +{ + return aRect.origin.y + aRect.size.height; +} + +GS_GEOM_SCOPE CGFloat +NSMidX(NSRect aRect) GS_GEOM_ATTR; + +/** Returns the x-coordinate of aRect's middle point. */ +GS_GEOM_SCOPE CGFloat +NSMidX(NSRect aRect) +{ + return aRect.origin.x + (aRect.size.width / 2.0); +} + +GS_GEOM_SCOPE CGFloat +NSMidY(NSRect aRect) GS_GEOM_ATTR; + +/** Returns the y-coordinate of aRect's middle point. */ +GS_GEOM_SCOPE CGFloat +NSMidY(NSRect aRect) +{ + return aRect.origin.y + (aRect.size.height / 2.0); +} + +GS_GEOM_SCOPE CGFloat +NSMinX(NSRect aRect) GS_GEOM_ATTR; + +/** Returns the least x-coordinate value still inside aRect. */ +GS_GEOM_SCOPE CGFloat +NSMinX(NSRect aRect) +{ + return aRect.origin.x; +} + +GS_GEOM_SCOPE CGFloat +NSMinY(NSRect aRect) GS_GEOM_ATTR; + +/** Returns the least y-coordinate value still inside aRect. */ +GS_GEOM_SCOPE CGFloat +NSMinY(NSRect aRect) +{ + return aRect.origin.y; +} + +GS_GEOM_SCOPE CGFloat +NSWidth(NSRect aRect) GS_GEOM_ATTR; + +/** Returns aRect's width. */ +GS_GEOM_SCOPE CGFloat +NSWidth(NSRect aRect) +{ + return aRect.size.width; +} + +GS_GEOM_SCOPE CGFloat +NSHeight(NSRect aRect) GS_GEOM_ATTR; + +/** Returns aRect's height. */ +GS_GEOM_SCOPE CGFloat +NSHeight(NSRect aRect) +{ + return aRect.size.height; +} + +GS_GEOM_SCOPE BOOL +NSIsEmptyRect(NSRect aRect) GS_GEOM_ATTR; + +/** Returns 'YES' iff the area of aRect is zero (i.e., iff either + * of aRect's width or height is negative or zero). */ +GS_GEOM_SCOPE BOOL +NSIsEmptyRect(NSRect aRect) +{ + return ((NSWidth(aRect) > 0) && (NSHeight(aRect) > 0)) ? NO : YES; +} + +/** Modify a Copy of a Rectangle... **/ + +GS_GEOM_SCOPE NSRect +NSOffsetRect(NSRect aRect, CGFloat dx, CGFloat dy) GS_GEOM_ATTR; + +/** Returns the rectangle obtained by translating aRect + * horizontally by dx and vertically by dy. */ +GS_GEOM_SCOPE NSRect +NSOffsetRect(NSRect aRect, CGFloat dx, CGFloat dy) +{ + NSRect rect = aRect; + + rect.origin.x += dx; + rect.origin.y += dy; + return rect; +} + +GS_GEOM_SCOPE NSRect +NSInsetRect(NSRect aRect, CGFloat dX, CGFloat dY) GS_GEOM_ATTR; + +/** Returns the rectangle obtained by moving each of aRect's + * horizontal sides inward by dy and each of aRect's vertical + * sides inward by dx.
+ * NB. For MacOS-X compatability, this is permitted to return + * a rectanglew with nagative width or height, strange as that seems. + */ +GS_GEOM_SCOPE NSRect +NSInsetRect(NSRect aRect, CGFloat dX, CGFloat dY) +{ + NSRect rect; + + rect = NSOffsetRect(aRect, dX, dY); + rect.size.width -= (2 * dX); + rect.size.height -= (2 * dY); + return rect; +} + +/** Divides aRect into two rectangles (namely slice and remainder) by + * "cutting" aRect---parallel to, and a distance amount from the given edge + * of aRect. You may pass 0 in as either of slice or + * remainder to avoid obtaining either of the created rectangles. */ +GS_EXPORT void +NSDivideRect(NSRect aRect, + NSRect *slice, + NSRect *remainder, + CGFloat amount, + NSRectEdge edge); + +/** Returns a rectangle obtained by expanding aRect minimally + * so that all four of its defining components are integers. */ +GS_EXPORT NSRect +NSIntegralRect(NSRect aRect); + +/** Compute a Third Rectangle from Two Rectangles... **/ + +GS_GEOM_SCOPE NSRect +NSUnionRect(NSRect aRect, NSRect bRect) GS_GEOM_ATTR; + +/** Returns the smallest rectangle which contains both aRect + * and bRect (modulo a set of measure zero). If either of aRect + * or bRect is an empty rectangle, then the other rectangle is + * returned. If both are empty, then the empty rectangle is returned. */ +GS_GEOM_SCOPE NSRect +NSUnionRect(NSRect aRect, NSRect bRect) +{ + NSRect rect; + + if (NSIsEmptyRect(aRect) && NSIsEmptyRect(bRect)) + return NSMakeRect(0.0,0.0,0.0,0.0); + else if (NSIsEmptyRect(aRect)) + return bRect; + else if (NSIsEmptyRect(bRect)) + return aRect; + + rect = NSMakeRect(MIN(NSMinX(aRect), NSMinX(bRect)), + MIN(NSMinY(aRect), NSMinY(bRect)), 0.0, 0.0); + + rect = NSMakeRect(NSMinX(rect), + NSMinY(rect), + MAX(NSMaxX(aRect), NSMaxX(bRect)) - NSMinX(rect), + MAX(NSMaxY(aRect), NSMaxY(bRect)) - NSMinY(rect)); + + return rect; +} + +GS_GEOM_SCOPE NSRect +NSIntersectionRect(NSRect aRect, NSRect bRect) GS_GEOM_ATTR; + +/** Returns the largest rectangle which lies in both aRect and + * bRect. If aRect and bRect have empty intersection (or, rather, + * intersection of measure zero, since this includes having their + * intersection be only a point or a line), then the empty + * rectangle is returned. */ +GS_GEOM_SCOPE NSRect +NSIntersectionRect (NSRect aRect, NSRect bRect) +{ + if (NSMaxX(aRect) <= NSMinX(bRect) || NSMaxX(bRect) <= NSMinX(aRect) + || NSMaxY(aRect) <= NSMinY(bRect) || NSMaxY(bRect) <= NSMinY(aRect)) + { + return NSMakeRect(0.0, 0.0, 0.0, 0.0); + } + else + { + NSRect rect; + + if (NSMinX(aRect) <= NSMinX(bRect)) + rect.origin.x = bRect.origin.x; + else + rect.origin.x = aRect.origin.x; + + if (NSMinY(aRect) <= NSMinY(bRect)) + rect.origin.y = bRect.origin.y; + else + rect.origin.y = aRect.origin.y; + + if (NSMaxX(aRect) >= NSMaxX(bRect)) + rect.size.width = NSMaxX(bRect) - rect.origin.x; + else + rect.size.width = NSMaxX(aRect) - rect.origin.x; + + if (NSMaxY(aRect) >= NSMaxY(bRect)) + rect.size.height = NSMaxY(bRect) - rect.origin.y; + else + rect.size.height = NSMaxY(aRect) - rect.origin.y; + + return rect; + } +} + +/** Test geometric relationships... **/ + +/** Returns 'YES' iff aRect's and bRect's origin and size are the same. */ +GS_EXPORT BOOL +NSEqualRects(NSRect aRect, NSRect bRect) GS_GEOM_ATTR; + +/** Returns 'YES' iff aSize's and bSize's width and height are the same. */ +GS_EXPORT BOOL +NSEqualSizes(NSSize aSize, NSSize bSize) GS_GEOM_ATTR; + +/** Returns 'YES' iff aPoint's and bPoint's x- and y-coordinates + * are the same. */ +GS_EXPORT BOOL +NSEqualPoints(NSPoint aPoint, NSPoint bPoint) GS_GEOM_ATTR; + +GS_GEOM_SCOPE BOOL +NSMouseInRect(NSPoint aPoint, NSRect aRect, BOOL flipped) GS_GEOM_ATTR; + +/** Returns 'YES' iff aPoint is inside aRect. */ +GS_GEOM_SCOPE BOOL +NSMouseInRect(NSPoint aPoint, NSRect aRect, BOOL flipped) +{ + if (flipped) + { + return ((aPoint.x >= NSMinX(aRect)) + && (aPoint.y >= NSMinY(aRect)) + && (aPoint.x < NSMaxX(aRect)) + && (aPoint.y < NSMaxY(aRect))) ? YES : NO; + } + else + { + return ((aPoint.x >= NSMinX(aRect)) + && (aPoint.y > NSMinY(aRect)) + && (aPoint.x < NSMaxX(aRect)) + && (aPoint.y <= NSMaxY(aRect))) ? YES : NO; + } +} + +GS_GEOM_SCOPE BOOL +NSPointInRect(NSPoint aPoint, NSRect aRect) GS_GEOM_ATTR; + +/** Just like 'NSMouseInRect(aPoint, aRect, YES)'. */ +GS_GEOM_SCOPE BOOL +NSPointInRect(NSPoint aPoint, NSRect aRect) +{ + return NSMouseInRect(aPoint, aRect, YES); +} + +GS_GEOM_SCOPE BOOL +NSContainsRect(NSRect aRect, NSRect bRect) GS_GEOM_ATTR; + +/** Returns 'YES' iff aRect totally encloses bRect. NOTE: For + * this to be the case, aRect cannot be empty, nor can any side + * of bRect go beyond any side of aRect. Note that this behavior + * is different than the original OpenStep behavior, where the sides + * of bRect could not touch aRect. */ +GS_GEOM_SCOPE BOOL +NSContainsRect(NSRect aRect, NSRect bRect) +{ + return (!NSIsEmptyRect(bRect) + && (NSMinX(aRect) <= NSMinX(bRect)) + && (NSMinY(aRect) <= NSMinY(bRect)) + && (NSMaxX(aRect) >= NSMaxX(bRect)) + && (NSMaxY(aRect) >= NSMaxY(bRect))) ? YES : NO; +} + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +GS_GEOM_SCOPE BOOL +NSIntersectsRect(NSRect aRect, NSRect bRect) GS_GEOM_ATTR; + +/** Returns YES if aRect and bRect have non-zero intersection area + (intersecting at a line or a point doesn't count). */ +GS_GEOM_SCOPE BOOL +NSIntersectsRect(NSRect aRect, NSRect bRect) +{ + /* Note that intersecting at a line or a point doesn't count */ + return (NSMaxX(aRect) <= NSMinX(bRect) + || NSMaxX(bRect) <= NSMinX(aRect) + || NSMaxY(aRect) <= NSMinY(bRect) + || NSMaxY(bRect) <= NSMinY(aRect) + || NSIsEmptyRect(aRect) + || NSIsEmptyRect(bRect)) ? NO : YES; +} +#endif + +/** Get a String Representation... **/ + +#ifdef __OBJC__ +/** Returns an NSString of the form "{x=X; y=Y}", where + * X and Y are the x- and y-coordinates of aPoint, respectively. */ +GS_EXPORT NSString * +NSStringFromPoint(NSPoint aPoint); + +/** Returns an NSString of the form "{x=X; y=Y; width=W; height=H}", + * where X, Y, W, and H are the x-coordinate, y-coordinate, + * width, and height of aRect, respectively. */ +GS_EXPORT NSString * +NSStringFromRect(NSRect aRect); + +/** Returns an NSString of the form "{width=W; height=H}", where + * W and H are the width and height of aSize, respectively. */ +GS_EXPORT NSString * +NSStringFromSize(NSSize aSize); + +/** Parses point from string of form "{x=a; y=b}". (0,0) returned + if parsing fails. */ +GS_EXPORT NSPoint NSPointFromString(NSString* string); + +/** Parses size from string of form "{width=a; height=b}". Size of + 0,0 returned if parsing fails. */ +GS_EXPORT NSSize NSSizeFromString(NSString* string); + +/** Parses point from string of form "{x=a; y=b; width=c; + height=d}". Rectangle of 0 size at origin returned if parsing + fails. +*/ +GS_EXPORT NSRect NSRectFromString(NSString* string); + +#endif /* __OBJC__ */ + +#ifdef GS_DEFINED_MAX +#undef GS_DEFINED_MAX +#undef MAX +#endif + +#ifdef GS_DEFINED_MIN +#undef GS_DEFINED_MIN +#undef MIN +#endif + +#if defined(__cplusplus) +} +#endif + +#endif /* __NSGeometry_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h new file mode 100644 index 00000000000..189af80436a --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h @@ -0,0 +1,317 @@ +/** Interface to ObjC runtime for GNUStep + Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum + Date: 1995 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + + AutogsdocSource: NSObjCRuntime.m + AutogsdocSource: NSLog.m + + */ + +#ifndef __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE +#define __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE + +#ifdef __cplusplus +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif +#endif + +#import "../GNUstepBase/GSVersionMacros.h" +#import "../GNUstepBase/GSConfig.h" +#import "../GNUstepBase/GNUstep.h" +#if __BLOCKS__ +#import "../GNUstepBase/GSBlocks.h" +#endif + +#include +#include +#include + +/* PA HP-UX kludge. */ +#if defined(__hppa__) && defined(__hpux__) && !defined(PRIuPTR) +#define PRIuPTR "lu" +#endif + +/* IRIX kludge. */ +#if defined(__sgi) +/* IRIX 6.5 provides all definitions, but only for C99 + compilations. */ +#define PRId8 "hhd" +#define PRIu8 "hhu" +#if (_MIPS_SZLONG == 32) +#define PRId64 "lld" +#define PRIu64 "llu" +#endif +/* This doesn't match , which always has "lld" here, but the + arguments are uint64_t, int64_t, which are unsigned long, long for + 64-bit in . */ +#if (_MIPS_SZLONG == 64) +#define PRId64 "ld" +#define PRIu64 "lu" +#endif +/* This doesn't match , which has "u" here, but the arguments + are uintptr_t, which is always unsigned long. */ +#define PRIuPTR "lu" +#endif + +/* Solaris < 10 kludge. */ +#if defined(__sun__) && defined(__svr4__) && !defined(PRIuPTR) +#if defined(__arch64__) || defined (__x86_64__) +#define PRIuPTR "lu" +#define PRIdPTR "ld" +#define PRIxPTR "lx" +#else +#define PRIuPTR "u" +#define PRIdPTR "d" +#define PRIxPTR "x" +#endif +#endif + + +/* These typedefs must be in place before GSObjCRuntime.h is imported. + */ + +#if !defined(NSINTEGER_DEFINED) +typedef intptr_t NSInteger; +typedef uintptr_t NSUInteger; +# define NSIntegerMax INTPTR_MAX +# define NSIntegerMin INTPTR_MIN +# define NSUIntegerMax UINTPTR_MAX +#endif /* !defined(NSINTEGER_DEFINED) */ + +#if !defined(CGFLOAT_DEFINED) +#if GS_SIZEOF_VOIDP == 8 +#define CGFLOAT_IS_DBL 1 +typedef double CGFloat; +#define CGFLOAT_MIN DBL_MIN +#define CGFLOAT_MAX DBL_MAX +#else +typedef float CGFloat; +#define CGFLOAT_MIN FLT_MIN +#define CGFLOAT_MAX FLT_MAX +#endif +#endif /* !defined(CGFLOAT_DEFINED) */ + +#define NSINTEGER_DEFINED 1 +#define CGFLOAT_DEFINED 1 +#ifndef NS_AUTOMATED_REFCOUNT_UNAVAILABLE +# if __has_feature(objc_arc) +# define NS_AUTOMATED_REFCOUNT_UNAVAILABLE \ + __attribute__((unavailable("Not available with automatic reference counting"))) +# else +# define NS_AUTOMATED_REFCOUNT_UNAVAILABLE +# endif +#endif + + +#if defined(__cplusplus) +extern "C" { +#endif + + +/* + * We can have strongly typed enums in C++11 mode or when the objc_fixed_enum + * feature is availble. + */ +#if (__has_feature(objc_fixed_enum) || (__cplusplus && (__cplusplus > 199711L) && __has_extension(cxx_strong_enums))) +# define _GS_NAMED_ENUM(ty, name) enum name : ty name; enum name : ty +# define _GS_ANON_ENUM(ty) enum : ty +# if __cplusplus +# define NS_OPTIONS(ty,name) ty name; enum : ty +# else +# define NS_OPTIONS(ty,name) NS_ENUM(ty,name) +# endif +#else // this provides less information, but works with older compilers +# define _GS_NAMED_ENUM(ty, name) ty name; enum +# define _GS_ANON_ENUM(ty) enum +# define NS_OPTIONS(ty, name) NS_ENUM(ty, name) +#endif +// A bit of fairy dust to expand NS_ENUM to the correct variant +#define _GS_GET_ENUM_MACRO(_first,_second,NAME,...) NAME +/* The trick here is that placing the variadic args first will push the name + * that the _GS_GET_ENUM_MACRO expands to into the correct position. + */ +#define NS_ENUM(...) _GS_GET_ENUM_MACRO(__VA_ARGS__,_GS_NAMED_ENUM,_GS_ANON_ENUM)(__VA_ARGS__) + +/* + * If the compiler supports nullability qualifiers, we define the macros for + * non-null sections. + */ +#if __has_feature(nullability) +# define NS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin") +# define NS_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end") +#else +# define NS_ASSUME_NONNULL_BEGIN +# define NS_ASSUME_NONNULL_END +#endif + +/* + * Backwards compatibility macro for instance type. + */ +#if !__has_feature(objc_instancetype) +# define instancetype id +#endif + +/* + * Backwards compatibility macros for Objective-C lightweight generics. + */ +#if __has_feature(objc_generics) +# define GS_GENERIC_CLASS(clz, ...) clz<__VA_ARGS__> +# define GS_GENERIC_TYPE_F(typeRef, fallback) typeRef +#else +# define GS_GENERIC_CLASS(clz, ...) clz +# define GS_GENERIC_TYPE_F(typeRef, fallback) fallback +#endif +#define GS_GENERIC_TYPE(typeRef) GS_GENERIC_TYPE_F(typeRef, id) + +/** + * Backwards compatibility macro for the objc_designated_initializer attribute + */ +#if __has_attribute(objc_designated_initializer) +# define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +# define NS_DESIGNATED_INITIALIZER +#endif + +/** Bitfield used to specify options to control enumeration over collections. + */ +typedef NS_OPTIONS(NSUInteger, NSEnumerationOptions) +{ + NSEnumerationConcurrent = (1UL << 0), /** Specifies that the enumeration + * is concurrency-safe. Note that this does not mean that it will be + * carried out in a concurrent manner, only that it can be. + */ + + NSEnumerationReverse = (1UL << 1) /** Specifies that the enumeration should + * happen in the opposite of the natural order of the collection. + */ +}; + + +/** Bitfield used to specify options to control the sorting of collections. + */ +typedef NS_OPTIONS(NSUInteger, NSSortOptions) +{ + NSSortConcurrent = (1UL << 0), /** Specifies that the sort + * is concurrency-safe. Note that this does not mean that it will be + * carried out in a concurrent manner, only that it can be. + */ + NSSortStable = (1UL << 4) /** Specifies that the sort should keep + * equal objects in the same order in the collection. + */ +}; + + +#import "../GNUstepBase/GSObjCRuntime.h" + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST) +GS_EXPORT NSString *NSStringFromProtocol(Protocol *aProtocol); +GS_EXPORT Protocol *NSProtocolFromString(NSString *aProtocolName); +#endif +GS_EXPORT SEL NSSelectorFromString(NSString *aSelectorName); +GS_EXPORT NSString *NSStringFromSelector(SEL aSelector); +GS_EXPORT SEL NSSelectorFromString(NSString *aSelectorName); +GS_EXPORT Class NSClassFromString(NSString *aClassName); +GS_EXPORT NSString *NSStringFromClass(Class aClass); +GS_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr, + NSUInteger *sizep, NSUInteger *alignp); + +#if OS_API_VERSION(GS_API_NONE, GS_API_NONE) +/* Logging */ +/** + * OpenStep spec states that log messages go to stderr, but just in case + * someone wants them to go somewhere else, they can implement a function + * like this and assign a pointer to it to _NSLog_printf_handler. + */ +typedef void NSLog_printf_handler (NSString* message); +GS_EXPORT NSLog_printf_handler *_NSLog_printf_handler; +GS_EXPORT int _NSLogDescriptor; +@class NSRecursiveLock; +GS_EXPORT NSRecursiveLock *GSLogLock(void); +#endif + +GS_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2); +GS_EXPORT void NSLogv(NSString *format, va_list args) NS_FORMAT_FUNCTION(1,0); + +#ifndef YES +#define YES 1 +#endif +#ifndef NO +#define NO 0 +#endif +#ifndef nil +#define nil 0 +#endif + +/** + * Contains values NSOrderedSame, NSOrderedAscending + * NSOrderedDescending, for left hand side equals, less than, or + * greater than right hand side. + */ +typedef NS_ENUM(NSInteger, NSComparisonResult) +{ + NSOrderedAscending = (NSInteger)-1, NSOrderedSame, NSOrderedDescending +}; + +enum {NSNotFound = NSIntegerMax}; + +#if __BLOCKS__ +DEFINE_BLOCK_TYPE(NSComparator, NSComparisonResult, id, id); +#endif + +/** + * Declare the foundation export macro as an alias to GS_EXPORT + */ +#define FOUNDATION_EXPORT GS_EXPORT + +#if defined(__cplusplus) +} +#endif + +/** + * Declare Apple availability macros for compatibility purposes as no-ops. + */ +#define NS_CLASS_AVAILABLE(...) +#define NS_AVAILABLE(...) +#define NS_AVAILABLE_MAC(...) +#define NS_DEPRECATED(...) +#define NS_DEPRECATED_MAC(...) +#define NS_ENUM_AVAILABLE(...) +#define NS_ENUM_AVAILABLE_MAC(...) +#define NS_ENUM_DEPRECATED(...) +#define NS_ENUM_DEPRECATED_MAC(...) +#define NS_CLASS_AVAILABLE(...) +#define NS_CLASS_DEPRECATED(...) +#define NS_CLASS_AVAILABLE_MAC(...) +#define NS_CLASS_DEPRECATED_MAC(...) +#define NS_UNAVAILABLE + +/* Define root class NS macro */ +#ifndef NS_ROOT_CLASS +#if __has_attribute(objc_root_class) +#define NS_ROOT_CLASS __attribute__((objc_root_class)) +#else +#define NS_ROOT_CLASS +#endif +#endif + +#endif /* __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObject.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObject.h new file mode 100644 index 00000000000..35647eadab6 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObject.h @@ -0,0 +1,594 @@ +/**Interface for NSObject for GNUStep + Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum + Date: 1995 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + + AutogsdocSource: NSObject.m + */ + +#ifndef __NSObject_h_GNUSTEP_BASE_INCLUDE +#define __NSObject_h_GNUSTEP_BASE_INCLUDE + +#import "NSObjCRuntime.h" +#import +#import "NSZone.h" + +#ifdef GS_WITH_GC +#undef GS_WITH_GC +#endif +#define GS_WITH_GC 0 + +#import "../GNUstepBase/GNUstep.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +@class NSArchiver; +@class NSArray; +@class NSCoder; +@class NSDictionary; +@class NSPortCoder; +@class NSMethodSignature; +@class NSMutableString; +@class NSRecursiveLock; +@class NSString; +@class NSInvocation; +@class Protocol; + +/** + * The NSObject protocol describes a minimal set of methods that all + * objects are expected to support. You should be able to send any + * of the messages listed in this protocol to an object, and be safe + * in assuming that the receiver can handle it. + */ +@protocol NSObject +/** + * Returns the class of the receiver. If the receiver is a proxy, then this + * may return the class of the proxy target. Use -isProxy to determine whether + * the receiver is a proxy. If you wish to find the real class of the + * receiver, ignoring proxies, then use object_getClass(). + */ +- (Class) class; +/** + * Returns the superclass of receiver's class. If the receiver is a proxy, + * then this may return the class of the proxy target. Use -isProxy to + * determine whether the receiver is a proxy. If you wish to find the real + * superclass of the receiver's class, ignoring proxies, then use + * class_getSuperclass(object_getClass()). + */ +- (Class) superclass; +/** + * Returns whether the receiver is equal to the argument. Defining equality is + * complex, so be careful when implementing this method. Collections such as + * NSSet depend on the behaviour of this method. In particular, this method + * must be commutative, so for any objects a and b: + * + * [a isEqual: b] == [b isEqual: a] + * + * This means that you must be very careful when returning YES if the argument + * is of another class. For example, if you define a number class that returns + * YES if the argument is a string representation of the number, then this will + * break because the string will not recognise your object as being equal to + * itself. + * + * If two objects are equal, then they must have the same hash value, however + * equal hash values do not imply equality. + */ +- (BOOL) isEqual: (id)anObject; +/** + * Returns YES if the receiver is an instance of the class, an instance of the + * subclass, or (in the case of proxies), an instance of something that can be + * treated as an instance of the class. + */ +- (BOOL) isKindOfClass: (Class)aClass; +/** + * Returns YES if the receiver is an instance of the class or (in the case of + * proxies), an instance of something that can be treated as an instance of the + * class. + * + * Calling this method is rarely the correct thing to do. In most cases, a + * subclass can be substituted for a superclass, so you should never need to + * check that an object is really an instance of a specific class and not a + * subclass. + */ +- (BOOL) isMemberOfClass: (Class)aClass; +/** + * Returns YES if the receiver is a proxy, NO otherwise. The default + * implementation of this method in NSObject returns NO, while the + * implementation in NSProxy returns YES. + */ +- (BOOL) isProxy; +/** + * Returns a hash value for the object. All objects that are equal *MUST* + * return the same hash value. For efficient storage in sets, or as keys in + * dictionaries, different objects should return hashes spread evenly over the + * range of an integer. + * + * An object may not return different values from this method after being + * stored in a collection. This typically means that ether the hash value must + * be constant after the object's creation, or that the object may not be + * modified while stored in an unordered collection. + */ +- (NSUInteger) hash; +/** + * Returns the receiver. In a proxy, this may (but is not required to) return + * the proxied object. + */ +- (id) self; +/** + * Performs the specified selector. The selector must correspond to a method + * that takes no arguments. + */ +- (id) performSelector: (SEL)aSelector; +/** + * Performs the specified selector, with the object as the argument. This + * method does not perform any automatic unboxing, so the selector must + * correspond to a method that takes one object argument. + */ +- (id) performSelector: (SEL)aSelector + withObject: (id)anObject; +/** + * Performs the specified selector, with the objects as the arguments. This + * method does not perform any automatic unboxing, so the selector must + * correspond to a method that takes two object arguments. + */ +- (id) performSelector: (SEL)aSelector + withObject: (id)object1 + withObject: (id)object2; +/** + * Returns YES if the object can respond to messages with the specified + * selector. The default implementation in NSObject returns YES if the + * receiver has a method corresponding to the method, but other classes may + * return YES if they can respond to a selector using one of the various + * forwarding mechanisms. + */ +- (BOOL) respondsToSelector: (SEL)aSelector; +/** + * Returns YES if the receiver conforms to the specified protocol. + */ +- (BOOL) conformsToProtocol: (Protocol*)aProtocol; +/** + * Increments the reference count of the object and returns the receiver. In + * garbage collected mode, this method does nothing. In automated reference + * counting mode, you may neither implement this method nor call it directly. + */ +- (id) retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +/** + * Decrements the reference count of the object and destroys if it there are no + * remaining references. In garbage collected mode, this method does nothing. + * In automated reference counting mode, you may neither implement this method + * nor call it directly. + */ +- (oneway void) release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +/** + * Performs a deferred -release operation. The object's reference count is + * decremented at the end of the scope of the current autorelease pool, + * identified either by a -drain message sent to the current NSAutoreleasePool + * instance, or in more recent versions of Objective-C by the end of an + * @autorelease_pool scope. + * + * In garbage collected mode, this method does nothing. In automated reference + * counting mode, you may neither implement this method nor call it directly. + */ +- (id) autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +/** + * Returns the current retain count of an object. This does not include the + * result of any pending autorelease operations. + * + * Code that relies on this method returning a sane value is broken. For + * singletons, it may return NSUIntegerMax. Even when it is tracking a retain + * count, it will not include on-stack pointers in manual retain/release mode, + * pointers marked as __unsafe_unretain or __weak in ARC mode, or pending + * autorelease operations. Its value is therefore largely meaningless. It can + * occasionally be useful for debugging. + */ +- (NSUInteger) retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +/** + * Returns the description of the object. This is used by the %@ format + * specifier in strings. + */ +- (NSString*) description; +/** + * Returns the zone of the object. + */ +- (NSZone*) zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +@end + +/** + * This protocol must be adopted by any class wishing to support copying - + * ie where instances of the class should be able to create new instances + * which are copies of the original and, where a class has mutable and + * immutable versions, where the copies are immutable. + */ +@protocol NSCopying +/** + * Called by [NSObject-copy] passing NSDefaultMallocZone() as zone.
+ * This method returns a copy of the receiver and, where the receiver is a + * mutable variant of a class which has an immutable partner class, the + * object returned is an instance of that immutable class.
+ * The new object is not autoreleased, and is considered to be + * 'owned' by the calling code ... which is therefore responsible for + * releasing it.
+ * In the case where the receiver is an instance of a container class, + * it is undefined whether contained objects are merely retained in the + * new copy, or are themselves copied, or whether some other mechanism + * entirely is used. + */ +- (id) copyWithZone: (NSZone*)zone; +@end + +/** + * This protocol must be adopted by any class wishing to support + * mutable copying - ie where instances of the class should be able + * to create mutable copies of themselves. + */ +@protocol NSMutableCopying +/** + * Called by [NSObject-mutableCopy] passing NSDefaultMallocZone() as zone.
+ * This method returns a copy of the receiver and, where the receiver is an + * immutable variant of a class which has a mutable partner class, the + * object returned is an instance of that mutable class. + * The new object is not autoreleased, and is considered to be + * 'owned' by the calling code ... which is therefore responsible for + * releasing it.
+ * In the case where the receiver is an instance of a container class, + * it is undefined whether contained objects are merely retained in the + * new copy, or are themselves copied, or whether some other mechanism + * entirely is used. + */ +- (id) mutableCopyWithZone: (NSZone*)zone; +@end + +/** + * This protocol must be adopted by any class wishing to support + * saving and restoring instances to an archive, or copying them + * to remote processes via the Distributed Objects mechanism. + */ +@protocol NSCoding + +/** + * Called when it is time for receiver to be serialized for writing to an + * archive or network connection. Receiver should record all of its instance + * variables using methods on aCoder. See documentation for [NSCoder], + * [NSArchiver], [NSKeyedArchiver], and/or [NSPortCoder] for more information. + */ +- (void) encodeWithCoder: (NSCoder*)aCoder; + +/** + * Called on a freshly allocated receiver when it is time to reconstitute from + * serialized bytes in an archive or from a network connection. Receiver + * should load all of its instance variables using methods on aCoder. See + * documentation for [NSCoder], [NSUnarchiver], [NSKeyedUnarchiver], and/or + * [NSPortCoder] for more information. + */ +- (id) initWithCoder: (NSCoder*)aDecoder; +@end + +@protocol NSSecureCoding ++ (BOOL)supportsSecureCoding; +@end + + +GS_ROOT_CLASS @interface NSObject +{ + /** + * Points to instance's class. Used by runtime to access method + * implementations, etc.. Set in +alloc, Unlike other instance variables, + * which are cleared there. + */ + Class isa; +} + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +/** On a system which performs garbage collection, you should implement + * this method to execute code when the receiver is collected.
+ * You must not call this method yourself (except when a subclass + * calls the superclass method within its own implementation). + */ +- (void) finalize; +#endif + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +- (NSString*) className; +#endif + ++ (id) allocWithZone: (NSZone*)z; ++ (id) alloc; ++ (Class) class; + +/** + * This method is automatically invoked on any class which implements it + * when the class is loaded into the runtime.
+ * It is also invoked on any category where the method is implemented + * when that category is loaded into the runtime.
+ * The +load method is called directly by the runtime and you should never + * send a +load message to a class yourself.
+ * This method is called before the +initialize message is sent + * to the class, so you cannot depend on class initialisation having been + * performed, or upon other classes existing (apart from superclasses of + * the receiver, since +load is called on superclasses before it is called + * on their subclasses).
+ * As a gross generalisation, it is safe to use C code, including + * most ObjectiveC runtime functions within +load, but attempting to send + * messages to ObjectiveC objects is likely to fail.
+ * In GNUstep, this method is implemented for NSObject to perform some + * initialisation for the base library.
+ * If you implement +load for a class, don't call [super load] in your + * implementation. + */ ++ (void) load; + +/** + * This message is automatically sent to a class by the runtime. It is + * sent once for each class, just before the class is used for the first + * time (excluding any automatic call to +load by the runtime).
+ * The message is sent in a thread-safe manner ... other threads may not + * call methods of the class until +initialize has finished executing.
+ * If the class has a superclass, its implementation of +initialize is + * called first.
+ * If the class does not implement +initialize then the implementation + * in the closest superclass may be called. This means that +initialize may + * be called more than once, and the recommended way to handle this by + * using the + * + * if (self == [classname class]) + * + * conditional to check whether the method is being called for a subclass.
+ * You should never call +initialize yourself ... let the runtime do it.
+ * You can implement +initialize in your own class if you need to. + * NSObject's implementation handles essential root object and base + * library initialization.
+ * It should be safe to call [super initialize] in your implementation + * of +initialize. + */ ++ (void) initialize; ++ (IMP) instanceMethodForSelector: (SEL)aSelector; ++ (NSMethodSignature*) instanceMethodSignatureForSelector: (SEL)aSelector; ++ (BOOL) instancesRespondToSelector: (SEL)aSelector; ++ (BOOL) isSubclassOfClass: (Class)aClass; ++ (id) new; ++ (void) poseAsClass: (Class)aClassObject; ++ (id) setVersion: (NSInteger)aVersion; ++ (NSInteger) version; + +- (id) awakeAfterUsingCoder: (NSCoder*)aDecoder; +- (Class) classForArchiver; +- (Class) classForCoder; +- (id) copy; +- (void) dealloc; +- (void) doesNotRecognizeSelector: (SEL)aSelector; +- (void) forwardInvocation: (NSInvocation*)anInvocation; +- (id) init; +- (IMP) methodForSelector: (SEL)aSelector; +- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector; +- (id) mutableCopy; +- (id) replacementObjectForArchiver: (NSArchiver*)anArchiver; +- (id) replacementObjectForCoder: (NSCoder*)anEncoder; +- (Class) superclass; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +/** + * This method will be called when attempting to send a message a class that + * does not understand it. The class may install a new method for the given + * selector and return YES, otherwise it should return NO. + * + * Note: This method is only reliable when using the GNUstep runtime. If you + * require compatibility with the GCC runtime, you must also implement + * -forwardInvocation: with equivalent semantics. This will be considerably + * slower, but more portable. + */ ++ (BOOL) resolveClassMethod: (SEL)name; + +/** + * This method will be called when attempting to send a message an instance + * that does not understand it. The class may install a new method for the + * given selector and return YES, otherwise it should return NO. + * + * Note: This method is only reliable when using the GNUstep runtime. If you + * require compatibility with the GCC runtime, you must also implement + * -forwardInvocation: with equivalent semantics. This will be considerably + * slower, but more portable. + */ ++ (BOOL) resolveInstanceMethod: (SEL)name; +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +/** + * Returns an auto-accessing proxy for the given object. This proxy sends a + * -beginContentAccess message to the receiver when it is created and an + * -endContentAccess message when it is destroyed. This prevents an object + * that implements the NSDiscardableContent protocol from having its contents + * discarded for as long as the proxy exists. + * + * On systems using the GNUstep runtime, messages send to the proxy will be + * slightly slower than direct messages. With the GCC runtime, they will be + * approximately two orders of magnitude slower. The GNUstep runtime, + * therefore, is strongly recommended for code calling this method. + */ +- (id) autoContentAccessingProxy; + +/** + * If an object does not understand a message, it may delegate it to another + * object. Returning nil indicates that forwarding should not take place. The + * default implementation of this returns nil, but care should be taken when + * subclassing NSObject subclasses and overriding this method that + * the superclass implementation is called if returning nil. + * + * Note: This method is only reliable when using the GNUstep runtime and code + * compiled with clang. If you require compatibility with GCC and the GCC + * runtime, you must also implement -forwardInvocation: with equivalent + * semantics. This will be considerably slower, but more portable. + */ +- (id) forwardingTargetForSelector: (SEL)aSelector; + +#endif +@end + +/** + * Used to allocate memory to hold an object, and initialise the + * class of the object to be aClass etc. The allocated memory will + * be extraBytes larger than the space actually needed to hold the + * instance variables of the object.
+ * This function is used by the [NSObject+allocWithZone:] method. + */ +GS_EXPORT id +NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); + +/** + * Used to release the memory used by an object.
+ * This function is used by the [NSObject-dealloc] method. + */ +GS_EXPORT void +NSDeallocateObject(id anObject); + +/** + * Used to copy anObject. This makes a bitwise copy of anObject to + * memory allocated from zone. The allocated memory will be extraBytes + * longer than that necessary to actually store the instance variables + * of the copied object.
+ */ +GS_EXPORT NSObject * +NSCopyObject(NSObject *anObject, NSUInteger extraBytes, NSZone *zone); + +/** + * Returns a flag to indicate whether anObject should be retained or + * copied in order to make a copy in the specified zone.
+ * Basically, this tests to see if anObject was allocated from + * requestedZone and returns YES if it was. + */ +GS_EXPORT BOOL +NSShouldRetainWithZone(NSObject *anObject, NSZone *requestedZone); + +GS_EXPORT BOOL +NSDecrementExtraRefCountWasZero(id anObject); + +GS_EXPORT NSUInteger +NSExtraRefCount(id anObject); + +GS_EXPORT void +NSIncrementExtraRefCount(id anObject); + +#if OS_API_VERSION(GS_API_NONE, GS_API_NONE) + +/** Global lock to be used by classes when operating on any global + data that invoke other methods which also access global; thus, + creating the potential for deadlock. */ +GS_EXPORT NSRecursiveLock *gnustep_global_lock; + +@interface NSObject (NEXTSTEP) +- (id) error:(const char *)aString, ...; +/* - (const char *) name; + Removed because OpenStep has -(NSString*)name; */ +@end + +#if GS_API_VERSION(GS_API_NONE, 011700) +@interface NSObject (GNUstep) ++ (void) enableDoubleReleaseCheck: (BOOL)enable; +@end +#endif + +#endif + +#import "NSDate.h" +/** + * Declares some methods for sending messages to self after a fixed delay. + * (These methods are in OpenStep and OS X.) + */ +@interface NSObject (TimedPerformers) + +/** + * Cancels any perform operations set up for the specified target + * in the current run loop. + */ ++ (void) cancelPreviousPerformRequestsWithTarget: (id)obj; + +/** + * Cancels any perform operations set up for the specified target + * in the current loop, but only if the value of aSelector and argument + * with which the performs were set up match those supplied.
+ * Matching of the argument may be either by pointer equality or by + * use of the [NSObject-isEqual:] method. + */ ++ (void) cancelPreviousPerformRequestsWithTarget: (id)obj + selector: (SEL)s + object: (id)arg; +/** + * Sets given message to be sent to this instance after given delay, + * in any run loop mode. See [NSRunLoop]. + */ +- (void) performSelector: (SEL)s + withObject: (id)arg + afterDelay: (NSTimeInterval)seconds; + +/** + * Sets given message to be sent to this instance after given delay, + * in given run loop modes. See [NSRunLoop]. + */ +- (void) performSelector: (SEL)s + withObject: (id)arg + afterDelay: (NSTimeInterval)seconds + inModes: (NSArray*)modes; +@end + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +/** + * The NSDiscardableContent protocol is used by objects which encapsulate data + * which may be discarded if resource constraints are exceeded. These + * constraints are typically, but not always, related memory. + */ +@protocol NSDiscardableContent + +/** + * This method is called before any access to the object. It returns YES if + * the object's content is still valid. The caller must call -endContentAccess + * once for every call to -beginContentAccess; + */ +- (BOOL) beginContentAccess; + +/** + * Discards the contents of the object if it is not currently being edited. + */ +- (void) discardContentIfPossible; + +/** + * This method indicates that the caller has finished accessing the contents of + * the object adopting this protocol. Every call to -beginContentAccess must + * be be paired with a call to this method after the caller has finished + * accessing the contents. + */ +- (void) endContentAccess; + +/** + * Returns YES if the contents of the object have been discarded, either via a + * call to -discardContentIfPossible while the object is not in use, or by some + * implementation dependent mechanism. + */ +- (BOOL) isContentDiscarded; +@end +#endif +#if defined(__cplusplus) +} +#endif + +#if !NO_GNUSTEP && !defined(GNUSTEP_BASE_INTERNAL) +#import "../GNUstepBase/NSObject+GNUstepBase.h" +#endif + +#endif /* __NSObject_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSRange.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSRange.h new file mode 100644 index 00000000000..845d44ac2d5 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSRange.h @@ -0,0 +1,235 @@ +/* + * Copyright (C) 1995,1999 Free Software Foundation, Inc. + * + * Written by: Adam Fedor + * Date: 1995 + * + * This file is part of the GNUstep Base Library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02111 USA. + */ + +#ifndef __NSRange_h_GNUSTEP_BASE_INCLUDE +#define __NSRange_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +/**** Included Headers *******************************************************/ + +#import "NSObject.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +@class NSException; +@class NXConstantString; + +/**** Type, Constant, and Macro Definitions **********************************/ + +#ifndef MAX +#define MAX(a,b) \ + ({__typeof__(a) _MAX_a = (a); __typeof__(b) _MAX_b = (b); \ + _MAX_a > _MAX_b ? _MAX_a : _MAX_b; }) +#define GS_DEFINED_MAX +#endif + +#ifndef MIN +#define MIN(a,b) \ + ({__typeof__(a) _MIN_a = (a); __typeof__(b) _MIN_b = (b); \ + _MIN_a < _MIN_b ? _MIN_a : _MIN_b; }) +#define GS_DEFINED_MIN +#endif + +/** + * +{ + NSUInteger location; + NSUInteger length; +} + *

+ * The NSRange type is used to specify ranges of locations, + * typically items in an array, characters in a string, and bytes + * in a data object. + *

+ *

+ * As 'boundary' or 'fencepost' errors are a particularly common + * problem in programming, it is important that you understand + * how an NSRange works. + *

+ *

+ * An NSRange consists of a location and a length. The + * points that are considered to lie in a range are the integers from + * the location to the location plus the length, so the number + * of points in a range is the length of the range plus one.
+ * However, if you consider these points like the marks on a + * ruler, you can only store information between + * points. So the number of items that can be stored in a range + * is the length of the range. + *

+ */ +typedef struct _NSRange NSRange; +struct _NSRange +{ + NSUInteger location; + NSUInteger length; +}; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** Pointer to an NSRange structure. */ +typedef NSRange *NSRangePointer; +#endif + +/**** Function Prototypes ****************************************************/ + +/* + * All but the most complex functions are declared static inline in this + * header file so that they are maximally efficient. In order to provide + * true functions (for code modules that don't have this header) this + * header is included in NSRange.m where the functions are no longer + * declared inline. + */ +#ifdef IN_NSRANGE_M +#define GS_RANGE_SCOPE extern +#define GS_RANGE_ATTR +#else +#define GS_RANGE_SCOPE static inline +#define GS_RANGE_ATTR __attribute__((unused)) +#endif + +GS_RANGE_SCOPE NSUInteger +NSMaxRange(NSRange range) GS_RANGE_ATTR; + +/** Returns top end of range (location + length). */ +GS_RANGE_SCOPE NSUInteger +NSMaxRange(NSRange range) +{ + return range.location + range.length; +} + +GS_RANGE_SCOPE BOOL +NSLocationInRange(NSUInteger location, NSRange range) GS_RANGE_ATTR; + +/** Returns whether location is greater than or equal to range's location + * and less than its max. + */ +GS_RANGE_SCOPE BOOL +NSLocationInRange(NSUInteger location, NSRange range) +{ + return (location >= range.location) && (location < NSMaxRange(range)); +} + +/** Convenience method for raising an NSRangeException. */ +GS_EXPORT void _NSRangeExceptionRaise (void); +/* NB: The implementation of _NSRangeExceptionRaise is: + [NSException raise: NSRangeException + format: @"Range location + length too great"]; + + _NSRangeExceptionRaise is defined in NSRange.m so that this + file (NSRange.h) can be included without problems in the + implementation of the base classes themselves. */ + +GS_RANGE_SCOPE NSRange +NSMakeRange(NSUInteger location, NSUInteger length) GS_RANGE_ATTR; + +/** Creates new range starting at location and of given length. */ +GS_RANGE_SCOPE NSRange +NSMakeRange(NSUInteger location, NSUInteger length) +{ + NSRange range; + NSUInteger end = location + length; + + if (end < location || end < length) + { + _NSRangeExceptionRaise (); + } + range.location = location; + range.length = length; + return range; +} + +GS_RANGE_SCOPE BOOL +NSEqualRanges(NSRange range1, NSRange range2) GS_RANGE_ATTR; + +/** Returns whether range1 and range2 have same location and length. */ +GS_RANGE_SCOPE BOOL +NSEqualRanges(NSRange range1, NSRange range2) +{ + return ((range1.location == range2.location) + && (range1.length == range2.length)); +} + +GS_RANGE_SCOPE NSRange +NSUnionRange(NSRange range1, NSRange range2) GS_RANGE_ATTR; + +/** Returns range going from minimum of aRange's and bRange's locations to + maximum of their two max's. */ +GS_RANGE_SCOPE NSRange +NSUnionRange(NSRange aRange, NSRange bRange) +{ + NSRange range; + + range.location = MIN(aRange.location, bRange.location); + range.length = MAX(NSMaxRange(aRange), NSMaxRange(bRange)) + - range.location; + return range; +} + +GS_RANGE_SCOPE NSRange +NSIntersectionRange(NSRange range1, NSRange range2) GS_RANGE_ATTR; + +/** Returns range containing indices existing in both aRange and bRange. If + * the returned length is 0, the location is undefined and should be ignored. + */ +GS_RANGE_SCOPE NSRange +NSIntersectionRange (NSRange aRange, NSRange bRange) +{ + NSRange range; + + if (NSMaxRange(aRange) < bRange.location + || NSMaxRange(bRange) < aRange.location) + return NSMakeRange(0, 0); + + range.location = MAX(aRange.location, bRange.location); + range.length = MIN(NSMaxRange(aRange), NSMaxRange(bRange)) + - range.location; + return range; +} + + +@class NSString; + +/** Returns string of form {location=a, length=b}. */ +GS_EXPORT NSString *NSStringFromRange(NSRange range); + +/** Parses range from string of form {location=a, length=b}; returns range + with 0 location and length if this fails. */ +GS_EXPORT NSRange NSRangeFromString(NSString *aString); + +#ifdef GS_DEFINED_MAX +#undef GS_DEFINED_MAX +#undef MAX +#endif + +#ifdef GS_DEFINED_MIN +#undef GS_DEFINED_MIN +#undef MIN +#endif + +#if defined(__cplusplus) +} +#endif + +#endif /* __NSRange_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSString.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSString.h new file mode 100644 index 00000000000..7863d9404f9 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSString.h @@ -0,0 +1,977 @@ +/* Interface for NSString for GNUstep + Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum + Date: 1995 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + */ + +/** + + Portable path handling +

Portable path handling (across both unix-like and mswindows operating + systems) requires some care. A modern operating system uses the concept + of a single root to the filesystem, but mswindows has multiple filesystems + with no common root, so code must be aware of this. There is also the + more minor issue that windows often uses a backslash as a separator between + the components of a path and unix-like systems always use forward slash.
+ On windows there is also the issue that two styles of path are used, + most commonly with a drive letter and a path on that drive + (eg. 'C:\directory\file') but also UNC paths + (eg. '//host/share/directory/file') so path handling functions must deal + with both formats. +

+

GNUstep has three path handling modes, 'gnustep', 'unix', and 'windows'. + The mode defaults to 'gnustep' but may be set using the GSPathHandling() + function.
+ You should probably stick to using the default 'gnustep' mode in which the + path handling methods cope with both 'unix' and 'windows' style paths in + portable and tolerant manner:
+ Paths are read in literally so they can be in the native format provided + by the operating system or in a non-native format. See + [NSFileManager-stringWithFileSystemRepresentation:length:].
+ Paths are written out using the native format of the system the application + is running on (eg on windows slashes are converted to backslashes). + See [NSFileManager-fileSystemRepresentationWithPath:].
+ The path handling methods accept either a forward or backward slash as a + path separator when parsing any path.
+ Unless operating in 'unix' mode, a leading letter followed by a colon is + considered the start of a windows style path (the drive specifier), and a + path beginning with something of the form '//host/share/' is considered + the start of a UNC style path.
+ The path handling methods add forward slashes when building new paths + internally or when standardising paths, so those path strings provide + a portable representation (as long as they are relative paths, not including + system specific roots).
+ An important case to note is that on windows a path which looks at first + glance like an absolute path may actually be a relative one.
+ 'C:file' is a relative path because it specifies a file on the C drive + but does not say what directory it is in.
+Similarly, '/dir/file' is a relative path because it specifies the full +location fo a file on a drive, but does not specify which drive it is on. +

+

As a consequence of this path handling, you are able to work completely +portably using relative paths (adding components, extensions and +relative paths to a pth, or removing components, extensions and relative +paths from a path etc), and when you save paths as strings in files +which may be transferred to another platform, you should save a relative +path.
+When you need to know absolute paths of various points in the filesystem, +you can use various path utility functions to obtain those absolute paths. +For instance, instead of saving an absolute path to a file, you might want +to save a path relative to a user's home directory. You could do that by +calling NSHomeDirectory() to get the home directory, and only saving the +part of the full path after that prefix. +

+
+ */ + +#ifndef __NSString_h_GNUSTEP_BASE_INCLUDE +#define __NSString_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +#import "NSObject.h" +#import "NSRange.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +/** + * Type for representing unicode characters. (16-bit) + */ +typedef uint16_t unichar; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST) +#define NSMaximumStringLength (INT_MAX-1) +#endif + +@class NSArray; +@class NSCharacterSet; +@class NSData; +@class NSDictionary; +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +@class NSError; +@class NSLocale; +@class NSURL; +#endif + +#define NSMaximumStringLength (INT_MAX-1) + +enum +{ + NSCaseInsensitiveSearch = 1, + NSLiteralSearch = 2, + NSBackwardsSearch = 4, + NSAnchoredSearch = 8, + NSNumericSearch = 64 /* MacOS-X 10.2 */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST) + , + NSDiacriticInsensitiveSearch = 128, + NSWidthInsensitiveSearch = 256, + NSForcedOrderingSearch = 512 +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_7,GS_API_LATEST) + , + /** + * Treats the search string as a regular expression. This option may be + * combined with NSCaseInsensitiveSearch and NSAnchoredSearch, but no other + * search options. + * + * This option may only be used with the -rangeOfString: family of methods. + */ + NSRegularExpressionSearch = 1024 +#endif +}; +typedef NSUInteger NSStringCompareOptions; + +/** + *

Enumeration of available encodings for converting between bytes and + * characters (in [NSString]s). The ones that are shared with OpenStep and + * Cocoa are: NSASCIIStringEncoding, NSNEXTSTEPStringEncoding, + * NSJapaneseEUCStringEncoding, NSUTF8StringEncoding, + * NSISOLatin1StringEncoding, NSSymbolStringEncoding, + * NSNonLossyASCIIStringEncoding, NSShiftJISStringEncoding, + * NSISOLatin2StringEncoding, NSUnicodeStringEncoding, + * NSWindowsCP1251StringEncoding, NSWindowsCP1252StringEncoding, + * NSWindowsCP1253StringEncoding, NSWindowsCP1254StringEncoding, + * NSWindowsCP1250StringEncoding, NSISO2022JPStringEncoding, + * NSMacOSRomanStringEncoding, NSProprietaryStringEncoding.

+ * + *

Additional encodings available under GNUstep are: + * NSKOI8RStringEncoding, NSISOLatin3StringEncoding, + * NSISOLatin4StringEncoding, NSISOCyrillicStringEncoding, + * NSISOArabicStringEncoding, NSISOGreekStringEncoding, + * NSISOHebrewStringEncoding, NSISOLatin5StringEncoding, + * NSISOLatin6StringEncoding, NSISOThaiStringEncoding, + * NSISOLatin7StringEncoding, NSISOLatin8StringEncoding, + * NSISOLatin9StringEncoding, NSGB2312StringEncoding, NSUTF7StringEncoding, + * NSGSM0338StringEncoding, NSBIG5StringEncoding, + * NSKoreanEUCStringEncoding.

+ */ +typedef enum _NSStringEncoding +{ +/* NB. Must not have an encoding with value zero - so we can use zero to + tell that a variable that should contain an encoding has not yet been + initialised */ + GSUndefinedEncoding = 0, + NSASCIIStringEncoding = 1, + NSNEXTSTEPStringEncoding = 2, + NSJapaneseEUCStringEncoding = 3, + NSUTF8StringEncoding = 4, + NSISOLatin1StringEncoding = 5, // ISO-8859-1; West European + NSSymbolStringEncoding = 6, + NSNonLossyASCIIStringEncoding = 7, + NSShiftJISStringEncoding = 8, + NSISOLatin2StringEncoding = 9, // ISO-8859-2; East European + NSUnicodeStringEncoding = 10, + NSUTF16StringEncoding = NSUnicodeStringEncoding, // An alias + NSWindowsCP1251StringEncoding = 11, + NSWindowsCP1252StringEncoding = 12, // WinLatin1 + NSWindowsCP1253StringEncoding = 13, // Greek + NSWindowsCP1254StringEncoding = 14, // Turkish + NSWindowsCP1250StringEncoding = 15, // WinLatin2 + NSISO2022JPStringEncoding = 21, + NSMacOSRomanStringEncoding = 30, + NSProprietaryStringEncoding = 31, + + NSKOI8RStringEncoding = 50, // Russian/Cyrillic + NSISOLatin3StringEncoding = 51, // ISO-8859-3; South European + NSISOLatin4StringEncoding = 52, // ISO-8859-4; North European + NSISOCyrillicStringEncoding = 22, // ISO-8859-5 + NSISOArabicStringEncoding = 53, // ISO-8859-6 + NSISOGreekStringEncoding = 54, // ISO-8859-7 + NSISOHebrewStringEncoding = 55, // ISO-8859-8 + NSISOLatin5StringEncoding = 57, // ISO-8859-9; Turkish + NSISOLatin6StringEncoding = 58, // ISO-8859-10; Nordic + NSISOThaiStringEncoding = 59, // ISO-8859-11 +/* Possible future ISO-8859 additions + // ISO-8859-12 +*/ + NSISOLatin7StringEncoding = 61, // ISO-8859-13 + NSISOLatin8StringEncoding = 62, // ISO-8859-14 + NSISOLatin9StringEncoding = 63, // ISO-8859-15; Replaces ISOLatin1 + NSGB2312StringEncoding = 56, + NSUTF7StringEncoding = 64, // RFC 2152 + NSGSM0338StringEncoding, // GSM (mobile phone) default alphabet + NSBIG5StringEncoding, // Traditional chinese + NSKoreanEUCStringEncoding // Korean + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4,GS_API_LATEST) + , + NSUTF16BigEndianStringEncoding = 0x90000100, + NSUTF16LittleEndianStringEncoding = 0x94000100, + NSUTF32StringEncoding = 0x8c000100, + NSUTF32BigEndianStringEncoding = 0x98000100, + NSUTF32LittleEndianStringEncoding = 0x9c000100 +#endif +} NSStringEncoding; + +enum { + NSOpenStepUnicodeReservedBase = 0xF400 +}; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4,GS_API_LATEST) +enum { + NSStringEncodingConversionAllowLossy = 1, + NSStringEncodingConversionExternalRepresentation = 2 +}; +typedef NSUInteger NSStringEncodingConversionOptions; +#endif + +/** + *

+ * NSString objects represent an immutable string of Unicode 3.0 + * characters. These may be accessed individually as type + * unichar, an unsigned short.
+ * The [NSMutableString] subclass represents a modifiable string. Both are + * implemented as part of a class cluster and the instances you receive may + * actually be of unspecified concrete subclasses. + *

+ *

+ * A constant NSString can be created using the following syntax: + * @"...", where the contents of the quotes are the + * string, using only ASCII characters. + *

+ *

+ * A variable string can be created using a C printf-like format, + * as in [NSString stringWithFormat: @"Total is %f", t]. + *

+ *

+ * To create a concrete subclass of NSString, you must have your + * class inherit from NSString and override at least the two + * primitive methods - -length and -characterAtIndex: + *

+ *

+ * In general the rule is that your subclass must override any + * initialiser that you want to use with it. The GNUstep + * implementation relaxes that to say that, you may override + * only the designated initialiser and the other + * initialisation methods should work. + *

+ *

+ * Where an NSString instance method returns an NSString object, + * the class of the actual object returned may be any subclass + * of NSString. The actual value returned may be a new + * autoreleased object, an autoreleased copy of the receiver, + * or the receiver itsself. While the abstract base class + * implementations of methods (other than initialisers) will + * avoid returning mutable strings by returning an autoreleased + * copy of a mutable receiver, concrete subclasses may behave + * differently, so code should not rely upon the mutability of + * returned strings nor upon their lifetime being greater than + * that of the receiver which returned them. + *

+ */ +@interface NSString :NSObject + ++ (id) string; ++ (id) stringWithCharacters: (const unichar*)chars + length: (NSUInteger)length; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4,GS_API_LATEST) && GS_API_VERSION( 10200,GS_API_LATEST) ++ (id) stringWithCString: (const char*)byteString + encoding: (NSStringEncoding)encoding; +#endif ++ (id) stringWithCString: (const char*)byteString + length: (NSUInteger)length; ++ (id) stringWithCString: (const char*)byteString; ++ (id) stringWithFormat: (NSString*)format, ... NS_FORMAT_FUNCTION(1,2); ++ (id) stringWithContentsOfFile:(NSString *)path; + +// Initializing Newly Allocated Strings +- (id) init; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4,GS_API_LATEST) && GS_API_VERSION( 10200,GS_API_LATEST) +- (id) initWithBytes: (const void*)bytes + length: (NSUInteger)length + encoding: (NSStringEncoding)encoding; +- (id) initWithBytesNoCopy: (void*)bytes + length: (NSUInteger)length + encoding: (NSStringEncoding)encoding + freeWhenDone: (BOOL)flag; +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4,GS_API_LATEST) ++ (id) stringWithContentsOfFile: (NSString*)path + usedEncoding: (NSStringEncoding*)enc + error: (NSError**)error; +- (id) initWithContentsOfFile: (NSString*)path + usedEncoding: (NSStringEncoding*)enc + error: (NSError**)error; ++ (id) stringWithContentsOfFile: (NSString*)path + encoding: (NSStringEncoding)enc + error: (NSError**)error; +- (id) initWithContentsOfFile: (NSString*)path + encoding: (NSStringEncoding)enc + error: (NSError**)error; ++ (id) stringWithContentsOfURL: (NSURL*)url + usedEncoding: (NSStringEncoding*)enc + error: (NSError**)error; +- (id) initWithContentsOfURL: (NSURL*)url + usedEncoding: (NSStringEncoding*)enc + error: (NSError**)error; ++ (id) stringWithContentsOfURL: (NSURL*)url + encoding: (NSStringEncoding)enc + error: (NSError**)error; +- (id) initWithContentsOfURL: (NSURL*)url + encoding: (NSStringEncoding)enc + error: (NSError**)error; +- (BOOL) writeToFile: (NSString*)path + atomically: (BOOL)atomically + encoding: (NSStringEncoding)enc + error: (NSError**)error; +- (BOOL) writeToURL: (NSURL*)url + atomically: (BOOL)atomically + encoding: (NSStringEncoding)enc + error: (NSError**)error; +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST) +- (NSString*)stringByReplacingOccurrencesOfString: (NSString*)replace + withString: (NSString*)by + options: (NSStringCompareOptions)opts + range: (NSRange)searchRange; +- (NSString*)stringByReplacingOccurrencesOfString: (NSString*)replace + withString: (NSString*)by; +- (NSString*) stringByReplacingCharactersInRange: (NSRange)aRange + withString: (NSString*)by; +#endif +- (id) initWithCharactersNoCopy: (unichar*)chars + length: (NSUInteger)length + freeWhenDone: (BOOL)flag; +- (id) initWithCharacters: (const unichar*)chars + length: (NSUInteger)length; +- (id) initWithCStringNoCopy: (char*)byteString + length: (NSUInteger)length + freeWhenDone: (BOOL)flag; +- (id) initWithCString: (const char*)byteString + length: (NSUInteger)length; +- (id) initWithCString: (const char*)byteString; +- (id) initWithString: (NSString*)string; +- (id) initWithFormat: (NSString*)format, ... NS_FORMAT_FUNCTION(1,2); +- (id) initWithFormat: (NSString*)format + arguments: (va_list)argList NS_FORMAT_FUNCTION(1,0); +- (id) initWithData: (NSData*)data + encoding: (NSStringEncoding)encoding; +- (id) initWithContentsOfFile: (NSString*)path; + +// Getting a String's Length +- (NSUInteger) length; + +// Accessing Characters +- (unichar) characterAtIndex: (NSUInteger)index; +- (void) getCharacters: (unichar*)buffer; +- (void) getCharacters: (unichar*)buffer + range: (NSRange)aRange; + +// Combining Strings +- (NSString*) stringByAppendingFormat: (NSString*)format, ... + NS_FORMAT_FUNCTION(1,2); +- (NSString*) stringByAppendingString: (NSString*)aString; + +// Dividing Strings into Substrings +- (NSArray*) componentsSeparatedByString: (NSString*)separator; +- (NSString*) substringFromIndex: (NSUInteger)index; +- (NSString*) substringToIndex: (NSUInteger)index; + +// Finding Ranges of Characters and Substrings +- (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet; +- (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet + options: (NSUInteger)mask; +- (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet + options: (NSUInteger)mask + range: (NSRange)aRange; +- (NSRange) rangeOfString: (NSString*)string; +- (NSRange) rangeOfString: (NSString*)string + options: (NSUInteger)mask; +- (NSRange) rangeOfString: (NSString*)aString + options: (NSUInteger)mask + range: (NSRange)aRange; + +// Determining Composed Character Sequences +- (NSRange) rangeOfComposedCharacterSequenceAtIndex: (NSUInteger)anIndex; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2,GS_API_LATEST) +/** Returns a copy of the receiver normalised using the KD form. + */ +- (NSString *) decomposedStringWithCompatibilityMapping; + +/** Returns a copy of the receiver normalised using the D form. + */ +- (NSString *) decomposedStringWithCanonicalMapping; + +/** Returns a copy of the receiver normalised using the KC form. + */ +- (NSString *) precomposedStringWithCompatibilityMapping; + +/** Returns a copy of the receiver normalised using the C form. + */ +- (NSString *) precomposedStringWithCanonicalMapping; +#endif + +// Converting String Contents into a Property List +- (id) propertyList; +- (NSDictionary*) propertyListFromStringsFileFormat; + +// Identifying and Comparing Strings +- (NSComparisonResult) compare: (NSString*)aString; +- (NSComparisonResult) compare: (NSString*)aString + options: (NSUInteger)mask; +- (NSComparisonResult) compare: (NSString*)aString + options: (NSUInteger)mask + range: (NSRange)aRange; +- (BOOL) hasPrefix: (NSString*)aString; +- (BOOL) hasSuffix: (NSString*)aString; +- (BOOL) isEqual: (id)anObject; +- (BOOL) isEqualToString: (NSString*)aString; +- (NSUInteger) hash; + +// Getting a Shared Prefix +- (NSString*) commonPrefixWithString: (NSString*)aString + options: (NSUInteger)mask; + +// Changing Case +- (NSString*) capitalizedString; +- (NSString*) lowercaseString; +- (NSString*) uppercaseString; + +// Getting C Strings +- (const char*) cString; +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4,GS_API_LATEST) && GS_API_VERSION( 10200,GS_API_LATEST) +- (const char*) cStringUsingEncoding: (NSStringEncoding)encoding; +- (BOOL) getCString: (char*)buffer + maxLength: (NSUInteger)maxLength + encoding: (NSStringEncoding)encoding; +- (id) initWithCString: (const char*)byteString + encoding: (NSStringEncoding)encoding; +- (NSUInteger) lengthOfBytesUsingEncoding: (NSStringEncoding)encoding; +- (NSUInteger) maximumLengthOfBytesUsingEncoding: (NSStringEncoding)encoding; +#endif + +#endif +- (NSUInteger) cStringLength; +- (void) getCString: (char*)buffer; +- (void) getCString: (char*)buffer + maxLength: (NSUInteger)maxLength; +- (void) getCString: (char*)buffer + maxLength: (NSUInteger)maxLength + range: (NSRange)aRange + remainingRange: (NSRange*)leftoverRange; + +// Getting Numeric Values +- (float) floatValue; +- (int) intValue; + +// Working With Encodings +- (BOOL) canBeConvertedToEncoding: (NSStringEncoding)encoding; +- (NSData*) dataUsingEncoding: (NSStringEncoding)encoding; +- (NSData*) dataUsingEncoding: (NSStringEncoding)encoding + allowLossyConversion: (BOOL)flag; ++ (NSStringEncoding) defaultCStringEncoding; +- (NSString*) description; +- (NSStringEncoding) fastestEncoding; +- (NSStringEncoding) smallestEncoding; + +/** + * Attempts to complete this string as a path in the filesystem by finding + * a unique completion if one exists and returning it by reference in + * outputName (which must be a non-nil pointer), or if it finds a set of + * completions they are returned by reference in outputArray, if it is non-nil. + * filterTypes can be an array of strings specifying extensions to consider; + * files without these extensions will be ignored and will not constitute + * completions. Returns 0 if no match found, else a positive number that is + * only accurate if outputArray was non-nil. + */ +- (NSUInteger) completePathIntoString: (NSString**)outputName + caseSensitive: (BOOL)flag + matchesIntoArray: (NSArray**)outputArray + filterTypes: (NSArray*)filterTypes; + +/** + * Converts the receiver to a C string path expressed in the character + * encoding appropriate for the local host file system. This string will be + * automatically freed soon after it is returned, so copy it if you need it + * for long.
+ * NB. On mingw32 systems the filesystem representation of a path is a 16-bit + * unicode character string, so you should only pass the value returned by + * this method to functions expecting wide characters.
+ * This method uses [NSFileManager-fileSystemRepresentationWithPath:] to + * perform the conversion. + */ +- (const GSNativeChar*) fileSystemRepresentation; + +/** + * Converts the receiver to a C string path using the character encoding + * appropriate to the local file system. This string will be stored + * into buffer if it is shorter (number of characters) than size, + * otherwise NO is returned.
+ * NB. On mingw32 systems the filesystem representation of a path is a 16-bit + * unicode character string, so the buffer you pass to this method must be + * twice as many bytes as the size (number of characters) you expect to + * receive.
+ * This method uses [NSFileManager-fileSystemRepresentationWithPath:] to + * perform the conversion. + */ +- (BOOL) getFileSystemRepresentation: (GSNativeChar*)buffer + maxLength: (NSUInteger)size; + +/** + * Returns a string containing the last path component of the receiver.
+ * The path component is the last non-empty substring delimited by the ends + * of the string, or by path separator characters.
+ * If the receiver only contains a root part, this method returns it.
+ * If there are no non-empty substrings, this returns an empty string.
+ * NB. In a windows UNC path, the host and share specification is treated as + * a single path component, even though it contains separators. + * So a string of the form '//host/share' may be returned.
+ * Other special cases are apply when the string is the root. + * + * @"foo/bar" produces @"bar" + * @"foo/bar/" produces @"bar" + * @"/foo/bar" produces @"bar" + * @"/foo" produces @"foo" + * @"/" produces @"/" (root is a special case) + * @"" produces @"" + * @"C:/" produces @"C:/" (root is a special case) + * @"C:" produces @"C:" + * @"//host/share/" produces @"//host/share/" (root is a special case) + * @"//host/share" produces @"//host/share" + * + */ +- (NSString*) lastPathComponent; + +/** + * Returns a new string containing the path extension of the receiver.
+ * The path extension is a suffix on the last path component which starts + * with the extension separator (a '.') (for example .tiff is the + * pathExtension for /foo/bar.tiff).
+ * Returns an empty string if no such extension exists. + * + * @"a.b" produces @"b" + * @"a.b/" produces @"b" + * @"/path/a.ext" produces @"ext" + * @"/path/a." produces @"" + * @"/path/.a" produces @"" (.a is not an extension to a file) + * @".a" produces @"" (.a is not an extension to a file) + * + */ +- (NSString*) pathExtension; + +/** + * Returns a string where a prefix of the current user's home directory is + * abbreviated by '~', or returns the receiver (or an immutable copy) if + * it was not found to have the home directory as a prefix. + */ +- (NSString*) stringByAbbreviatingWithTildeInPath; + +/** + * Returns a new string with the path component given in aString + * appended to the receiver.
+ * This removes trailing path separators from the receiver and the root + * part from aString and replaces them with a single slash as a path + * separator.
+ * Also condenses any multiple separator sequences in the result into + * single path separators. + * + * @"" with @"file" produces @"file" + * @"path" with @"file" produces @"path/file" + * @"/" with @"file" produces @"/file" + * @"/" with @"file" produces @"/file" + * @"/" with @"/file" produces @"/file" + * @"path with @"C:/file" produces @"path/file" + * + * NB. Do not use this method to modify strings other than filesystem + * paths as the behavior in such cases is undefined ... for instance + * the string may have repeated slashes or slash-dot-slash sequences + * removed. + */ +- (NSString*) stringByAppendingPathComponent: (NSString*)aString; + +/** + * Returns a new string with the path extension given in aString + * appended to the receiver after an extensionSeparator ('.').
+ * If the receiver has trailing path separator characters, they are + * stripped before the extension separator is added.
+ * If the receiver contains no components after the root, the extension + * cannot be appended (an extension can only be appended to a file name), + * so a copy of the unmodified receiver is returned.
+ * An empty string may be used as an extension ... in which case the extension + * separator is appended.
+ * This behavior mirrors that of the -stringByDeletingPathExtension method. + * + * @"Mail" with @"app" produces @"Mail.app" + * @"Mail.app" with @"old" produces @"Mail.app.old" + * @"file" with @"" produces @"file." + * @"/" with @"app" produces @"/" (no file name to append to) + * @"" with @"app" produces @"" (no file name to append to) + * + * NB. Do not use this method to modify strings other than filesystem + * paths as the behavior in such cases is undefined ... for instance + * the string may have repeated slashes or slash-dot-slash sequences + * removed. + */ +- (NSString*) stringByAppendingPathExtension: (NSString*)aString; + +/** + * Returns a new string with the last path component (including any final + * path separators) removed from the receiver.
+ * A string without a path component other than the root is returned + * without alteration.
+ * See -lastPathComponent for a definition of a path component. + * + * @"hello/there" produces @"hello" (a relative path) + * @"hello" produces @"" (a relative path) + * @"/hello" produces @"/" (an absolute unix path) + * @"/" produces @"/" (an absolute unix path) + * @"C:file" produces @"C:" (a relative windows path) + * @"C:" produces @"C:" (a relative windows path) + * @"C:/file" produces @"C:/" (an absolute windows path) + * @"C:/" produces @"C:/" (an absolute windows path) + * @"//host/share/file" produces @"//host/share/" (a UNC path) + * @"//host/share/" produces @"//host/share/" (a UNC path) + * @"//path/file" produces @"//path" (an absolute Unix path) + * + * NB. Do not use this method to modify strings other than filesystem + * paths as the behavior in such cases is undefined ... for instance + * the string may have repeated slashes or slash-dot-slash sequences + * removed. + */ +- (NSString*) stringByDeletingLastPathComponent; + +/** + * Returns a new string with the path extension removed from the receiver.
+ * Strips any trailing path separators before checking for the extension + * separator.
+ * NB. This method does not consider a string which contains nothing + * between the root part and the extension separator ('.') to be a path + * extension. This mirrors the behavior of the -stringByAppendingPathExtension: + * method. + * + * @"file.ext" produces @"file" + * @"/file.ext" produces @"/file" + * @"/file.ext/" produces @"/file" (trailing path separators are ignored) + * @"/file..ext" produces @"/file." + * @"/file." produces @"/file" + * @"/.ext" produces @"/.ext" (there is no file to strip from) + * @".ext" produces @".ext" (there is no file to strip from) + * + * NB. Do not use this method to modify strings other than filesystem + * paths as the behavior in such cases is undefined ... for instance + * the string may have repeated slashes or slash-dot-slash sequences + * removed. + */ +- (NSString*) stringByDeletingPathExtension; + +/** + * Returns a string created by expanding the initial tilde ('~') and any + * following username to be the home directory of the current user or the + * named user.
+ * Returns the receiver or an immutable copy if it was not possible to + * expand it. + */ +- (NSString*) stringByExpandingTildeInPath; + +/** + * First calls -stringByExpandingTildeInPath if necessary.
+ * Replaces path string by one in which path components representing symbolic + * links have been replaced by their referents.
+ * Removes a leading '/private' if the result is valid.
+ * If links cannot be resolved, returns an unmodified copy of the receiver. + */ +- (NSString*) stringByResolvingSymlinksInPath; + +/** + * Returns a standardised form of the receiver, with unnecessary parts + * removed, tilde characters expanded, and symbolic links resolved + * where possible.
+ * NB. Refers to the local filesystem to resolve symbolic links in + * absolute paths, and to expand tildes ... so this can't be used for + * general path manipulation.
+ * If the string is an invalid path, the unmodified receiver is returned.
+ *

+ * Uses -stringByExpandingTildeInPath to expand tilde expressions.
+ * Simplifies '//' and '/./' sequences and removes trailing '/' or '.'.
+ *

+ *

+ * For absolute paths, uses -stringByResolvingSymlinksInPath to resolve + * any links, then gets rid of '/../' sequences and removes any '/private' + * prefix. + *

+ */ +- (NSString*) stringByStandardizingPath; + + +// for methods working with decomposed strings +- (int) _baseLength; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** + * Concatenates the path components in the array and returns the result.
+ * This method does not remove empty path components, but does recognize an + * empty initial component as a special case meaning that the string + * returned will begin with a slash. + */ ++ (NSString*) pathWithComponents: (NSArray*)components; + +/** + * Returns YES if the receiver represents an absolute path ...
+ * Returns NO otherwise.
+ * An absolute path in unix mode is one which begins + * with a slash or tilde.
+ * In windows mode a drive specification (eg C:) followed by a slash or + * backslash, is an absolute path, as is any path beginning with a tilde.
+ * In any mode a UNC path (//host/share...) is always absolute.
+ * In the default gnustep path handling mode, + * the rules are the same as for windows, + * except that a path whose root is a slash denotes an absolute path + * when running on unix and a relative path when running under windows. + */ +- (BOOL) isAbsolutePath; + +/** + * Returns the path components of the receiver separated into an array.
+ * If the receiver begins with a root sequence such as the path separator + * character (or a drive specification in windows) then that is used as the + * first element in the array.
+ * Empty components are removed.
+ * If a trailing path separator (which was not part of the root) was present, + * it is added as the last element in the array. + */ +- (NSArray*) pathComponents; + +/** + * Returns an array of strings made by appending the values in paths + * to the receiver. + */ +- (NSArray*) stringsByAppendingPaths: (NSArray*)paths; + ++ (NSString*) localizedStringWithFormat: (NSString*)format, ... + NS_FORMAT_FUNCTION(1,2); + ++ (id) stringWithString: (NSString*)aString; ++ (id) stringWithContentsOfURL: (NSURL*)url; ++ (id) stringWithUTF8String: (const char*)bytes; +- (id) initWithFormat: (NSString*)format + locale: (NSDictionary*)locale, ... NS_FORMAT_FUNCTION(1,3); +- (id) initWithFormat: (NSString*)format + locale: (NSDictionary*)locale + arguments: (va_list)argList NS_FORMAT_FUNCTION(1,0); +- (id) initWithUTF8String: (const char *)bytes; +- (id) initWithContentsOfURL: (NSURL*)url; +- (NSString*) substringWithRange: (NSRange)aRange; +- (NSComparisonResult) caseInsensitiveCompare: (NSString*)aString; +- (NSComparisonResult) compare: (NSString*)string + options: (NSUInteger)mask + range: (NSRange)compareRange + locale: (id)locale; +- (NSComparisonResult) localizedCompare: (NSString *)string; +- (NSComparisonResult) localizedCaseInsensitiveCompare: (NSString *)string; +- (BOOL) writeToFile: (NSString*)filename + atomically: (BOOL)useAuxiliaryFile; +- (BOOL) writeToURL: (NSURL*)url atomically: (BOOL)atomically; +- (double) doubleValue; ++ (NSStringEncoding*) availableStringEncodings; ++ (NSString*) localizedNameOfStringEncoding: (NSStringEncoding)encoding; +- (void) getLineStart: (NSUInteger *)startIndex + end: (NSUInteger *)lineEndIndex + contentsEnd: (NSUInteger *)contentsEndIndex + forRange: (NSRange)aRange; +- (NSRange) lineRangeForRange: (NSRange)aRange; +- (const char*) lossyCString; +- (NSString*) stringByAddingPercentEscapesUsingEncoding: (NSStringEncoding)e; +- (NSString*) stringByPaddingToLength: (NSUInteger)newLength + withString: (NSString*)padString + startingAtIndex: (NSUInteger)padIndex; +- (NSString*) stringByReplacingPercentEscapesUsingEncoding: (NSStringEncoding)e; +- (NSString*) stringByTrimmingCharactersInSet: (NSCharacterSet*)aSet; +- (const char *)UTF8String; +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_9,GS_API_LATEST) +- (NSString *) stringByAddingPercentEncodingWithAllowedCharacters: (NSCharacterSet *)aSet; +- (NSString *) stringByRemovingPercentEncoding; +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3,GS_API_LATEST) +/** Not implemented */ +- (void) getParagraphStart: (NSUInteger *)startIndex + end: (NSUInteger *)parEndIndex + contentsEnd: (NSUInteger *)contentsEndIndex + forRange: (NSRange)range; +/** Not implemented */ + - (NSRange) paragraphRangeForRange: (NSRange)range; +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST) +/** + * Returns YES when scanning the receiver's text from left to right + * finds an initial digit in the range 1-9 or a letter in the set + * ('Y', 'y', 'T', 't').
+ * Any trailing characters are ignored.
+ * Any leading whitespace or zeros or signs are also ignored.
+ * Returns NO if the above conditions are not met. + */ +- (BOOL) boolValue; +- (NSArray *) componentsSeparatedByCharactersInSet: (NSCharacterSet *)separator; +- (NSInteger) integerValue; +- (long long) longLongValue; +/** Not implemented */ +- (NSRange) rangeOfComposedCharacterSequencesForRange: (NSRange)range; +/** Not implemented */ +- (NSRange) rangeOfString: (NSString *)aString + options: (NSStringCompareOptions)mask + range: (NSRange)searchRange + locale: (NSLocale *)locale; + +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_10,GS_API_LATEST) + +/** + * Returns YES if the receiver contains string, otherwise, NO. + */ +- (BOOL) containsString: (NSString *)string; + +#endif + +#if OS_API_VERSION(GS_API_NONE, GS_API_NONE) ++ (Class) constantStringClass; +#endif /* GS_API_NONE */ + +@end + +@interface NSMutableString : NSString + +// Creating Temporary Strings ++ (id) string; ++ (id) stringWithCharacters: (const unichar*)characters + length: (NSUInteger)length; ++ (id) stringWithCString: (const char*)byteString + length: (NSUInteger)length; ++ (id) stringWithCString: (const char*)byteString; ++ (id) stringWithFormat: (NSString*)format, ... NS_FORMAT_FUNCTION(1,2); ++ (id) stringWithContentsOfFile: (NSString*)path; ++ (NSMutableString*) stringWithCapacity: (NSUInteger)capacity; + +// Initializing Newly Allocated Strings +- (id) initWithCapacity: (NSUInteger)capacity; + +// Modify A String +- (void) appendFormat: (NSString*)format, ... NS_FORMAT_FUNCTION(1,2); +- (void) appendString: (NSString*)aString; +- (void) deleteCharactersInRange: (NSRange)range; +- (void) insertString: (NSString*)aString atIndex: (NSUInteger)loc; +- (void) replaceCharactersInRange: (NSRange)range + withString: (NSString*)aString; +- (NSUInteger) replaceOccurrencesOfString: (NSString*)replace + withString: (NSString*)by + options: (NSUInteger)opts + range: (NSRange)searchRange; +- (void) setString: (NSString*)aString; + +@end + +#ifdef __OBJC_GNUSTEP_RUNTIME_ABI__ +# if __OBJC_GNUSTEP_RUNTIME_ABI__ >= 20 +# define GNUSTEP_NEW_STRING_ABI +# endif +#endif + +/** + *

The NXConstantString class is used to hold constant 8-bit character + * string objects produced by the compiler where it sees @"..." in the + * source. The compiler generates the instances of this class - which + * has three instance variables -

+ * + * a pointer to the class (this is the sole ivar of NSObject) + * a pointer to the 8-bit data + * the length of the string + * + *

In older versions of the compiler, the isa variable is always set to + * the NXConstantString class. In newer versions a compiler option was + * added for GNUstep, to permit the isa variable to be set to another + * class, and GNUstep uses this to avoid conflicts with the default + * implementation of NXConstantString in the ObjC runtime library (the + * preprocessor is used to change all occurrences of NXConstantString + * in the source code to NSConstantString).

+ *

Since GNUstep will generally use the GNUstep extension to the + * compiler, you should never refer to the constant string class by + * name, but should use the [NSString+constantStringClass] method to + * get the actual class being used for constant strings.

+ * What follows is a dummy declaration of the class to keep the compiler + * happy. + */ +@interface NXConstantString : NSString +{ +@public +#ifdef GNUSTEP_NEW_STRING_ABI + /** + * Flags. The low 16 bits are reserved for the compiler, the top 16 for use + * by the Foundation Framework. Currently only the low 2 bits are used, to + * indicate the encoding of the string, with the following values: + * + * 0. ASCII (UTF-8 using only 7-bit characters) + * 1. UTF-8 + * 2. UTF-16 + * 3. UTF-32 + * + */ + uint32_t flags; + /** + * The number of characters (UTF-16 code units) in the string. + */ + uint32_t nxcslen; + /** + * The number of bytes in the string. For fixed-length encodings, this is a + * fixed multiple of nxcslen, but for UTF-8 it can be different. + */ + uint32_t size; + /** + * Hash value. + */ + uint32_t hash; + /** + * Pointer to the byte data of the string. Note that `char*` is the correct + * type only if the low two bits of the flags indicate that this is an ASCII + * or UTF-8 string, otherwise it is a pointer to 16- or 32-bit characters in + * native byte order. + */ + const char * const nxcsptr; +#else + const char * const nxcsptr; + const unsigned int nxcslen; +#endif +} +@end + +#ifdef NeXT_RUNTIME +/** For internal use with NeXT runtime; + needed, until Apple Radar 2870817 is fixed. */ +extern struct objc_class _NSConstantStringClassReference; +#endif + +#if defined(__cplusplus) +} +#endif + +#if !NO_GNUSTEP && !defined(GNUSTEP_BASE_INTERNAL) +#import "../GNUstepBase/NSString+GNUstepBase.h" +#import "../GNUstepBase/NSMutableString+GNUstepBase.h" +#endif + +#endif /* __NSString_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSValue.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSValue.h new file mode 100644 index 00000000000..f194f01a228 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSValue.h @@ -0,0 +1,370 @@ +/* Interface for NSValue for GNUStep + Copyright (C) 1995, 1996 Free Software Foundation, Inc. + + Written by: Adam Fedor + Created: 1995 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + */ + +#ifndef __NSValue_h_GNUSTEP_BASE_INCLUDE +#define __NSValue_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +#import "NSObject.h" +#import "NSGeometry.h" +#import "NSRange.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +@class NSString; + +/** + * The NSValue class can wrap a single primitive value as an + * object so it can be used in the containers and other places where an object + * reference is needed. Once initialized, an NSValue is + * immutable, and there is no NSMutableValue class. You + * initialize it by giving it a pointer to the primitive value, and you should + * be careful this does not get freed until after the NSValue is + * no longer used. + */ +@interface NSValue : NSObject + +// Allocating and Initializing + +/** + * Create new instance with specified value (a pointer) of given type, which + * is a string code obtainable through the compile-time operator + * @encode(...). For example: + + NSValue *theValue = [NSValue value: &n withObjCType: @encode(int)]; + + */ ++ (NSValue*) value: (const void*)value withObjCType: (const char*)type; + +/** + * Create new instance holding anObject. This is useful if you want to add + * anObject to a collection such as [NSArray] but don't want it to be retained + * (a weak reference). + */ ++ (NSValue*) valueWithNonretainedObject: (id)anObject; + +/** + * Convenience method to create instance holding an NSPoint + * structure. + */ ++ (NSValue*) valueWithPoint: (NSPoint)point; + +/** + * Convenience method to create instance holding a pointer. Same as + * using @encode(void *) in +value:withObjCType: . + */ ++ (NSValue*) valueWithPointer: (const void*)pointer; + +/** + * Convenience method to create instance holding an NSRange + * structure. + */ ++ (NSValue*) valueWithRange: (NSRange)range; + +/** + * Convenience method to create instance holding an NSRect + * structure. + */ ++ (NSValue*) valueWithRect: (NSRect)rect; + +/** + * Convenience method to create instance holding an NSSize + * structure. + */ ++ (NSValue*) valueWithSize: (NSSize)size; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** + * Synonym for value:withObjCType: . + */ ++ (NSValue*) valueWithBytes: (const void*)value objCType: (const char*)type; + +/** + * Initialize with value of type, parallel to value:withObjCType: . + */ +- (id) initWithBytes: (const void*)data objCType: (const char*)type; + +/** + * Compares this instance to another NSValue. For equality, + * both contents and declared type of the two values must match. + */ +- (BOOL) isEqualToValue: (NSValue*)other; +#endif /* GS_API_MACOSX */ + +// Accessing Data + +/** + * Copies bytes from the pointer receiver was initialized with into buffer + * pointed to by value. Number of bytes copied is determined by the type. If + * type was a void * pointer or object id, the memory address itself is + * copied. + */ +- (void) getValue: (void*)value; + +/** + * Returns the string @encode(...) compatible type the receiver + * was initialized with. + */ +- (const char*) objCType; + +/** + * If receiver was initialized with an object ID, return it, else raises + * NSInternalInconsistencyException. + */ +- (id) nonretainedObjectValue; + +/** + * If receiver was initialized with a void * pointer, return it, else raises + * NSInternalInconsistencyException. + */ +- (void*) pointerValue; + +/** + * If receiver was initialized with an NSRange value, return it, + * else raises NSInternalInconsistencyException. + */ +- (NSRange) rangeValue; + +/** + * If receiver was initialized with an NSRect value, return it, + * else raises NSInternalInconsistencyException. + */ +- (NSRect) rectValue; + +/** + * If receiver was initialized with an NSSize value, return it, + * else raises NSInternalInconsistencyException. + */ +- (NSSize) sizeValue; + +/** + * If receiver was initialized with an NSPoint value, return it, + * else raises NSInternalInconsistencyException. + */ +- (NSPoint) pointValue; + +@end + +/** + * Subclass of [NSValue] offering convenience methods for initializing from + * and accessing as any C primitive numeric type. On access, the value will + * be type-converted if necessary, using standard C conversion rules. + */ +@interface NSNumber : NSValue + +// Allocating and Initializing + +/** New instance from boolean value. */ ++ (NSNumber*) numberWithBool: (BOOL)value; +/** New instance from signed char value. */ ++ (NSNumber*) numberWithChar: (signed char)value; +/** New instance from double value. */ ++ (NSNumber*) numberWithDouble: (double)value; +/** New instance from float value. */ ++ (NSNumber*) numberWithFloat: (float)value; +/** New instance from (signed) int value. */ ++ (NSNumber*) numberWithInt: (signed int)value; +/** New instance from (signed) long value. */ ++ (NSNumber*) numberWithLong: (signed long)value; +/** New instance from (signed) long long value. */ ++ (NSNumber*) numberWithLongLong: (signed long long)value; +/** New instance from (signed) short value. */ ++ (NSNumber*) numberWithShort: (signed short)value; +/** New instance from unsigned char value. */ ++ (NSNumber*) numberWithUnsignedChar: (unsigned char)value; +/** New instance from unsigned int value. */ ++ (NSNumber*) numberWithUnsignedInt: (unsigned int)value; +/** New instance from unsigned long value. */ ++ (NSNumber*) numberWithUnsignedLong: (unsigned long)value; +/** New instance from unsigned long long value. */ ++ (NSNumber*) numberWithUnsignedLongLong: (unsigned long long)value; +/** New instance from unsigned short value. */ ++ (NSNumber*) numberWithUnsignedShort: (unsigned short)value; + +/** Initialize from boolean value. */ +- (id) initWithBool: (BOOL)value; +/** Initialize from signed char value. */ +- (id) initWithChar: (signed char)value; +/** Initialize from double value. */ +- (id) initWithDouble: (double)value; +/** Initialize from float value. */ +- (id) initWithFloat: (float)value; +/** Initialize from (signed) int value. */ +- (id) initWithInt: (signed int)value; +/** Initialize from (signed) long value. */ +- (id) initWithLong: (signed long)value; +/** Initialize from (signed) long long value. */ +- (id) initWithLongLong: (signed long long)value; +/** Initialize from (signed) short value. */ +- (id) initWithShort: (signed short)value; +/** Initialize from unsigned char value. */ +- (id) initWithUnsignedChar: (unsigned char)value; +/** Initialize from unsigned int value. */ +- (id) initWithUnsignedInt: (unsigned int)value; +/** Initialize from unsigned long value. */ +- (id) initWithUnsignedLong: (unsigned long)value; +/** Initialize from unsigned long long value. */ +- (id) initWithUnsignedLongLong: (unsigned long long)value; +/** Initialize from unsigned short value. */ +- (id) initWithUnsignedShort: (unsigned short)value; + +// Accessing Data + +/** + * Return value as a BOOL; this will in fact be a char value converted + * if necessary from type initialized with; if you wish to consider anything + * nonzero TRUE do not compare directly to YES, but use '!= NO'. + */ +- (BOOL) boolValue; +/** Returns value as a signed char, converting if necessary. */ +- (signed char) charValue; +/** Returns value as a double, converting if necessary. */ +- (double) doubleValue; +/** Returns value as a float, converting if necessary. */ +- (float) floatValue; +/** Returns value as a (signed) int, converting if necessary. */ +- (signed int) intValue; +/** Returns value as a (signed) long, converting if necessary. */ +- (signed long) longValue; +/** Returns value as a (signed) long long, converting if necessary. */ +- (signed long long) longLongValue; +/** Returns value as a (signed) short, converting if necessary. */ +- (signed short) shortValue; +/** Returns value as an unsigned char, converting if necessary. */ +- (unsigned char) unsignedCharValue; +/** Returns value as an unsigned int, converting if necessary. */ +- (unsigned int) unsignedIntValue; +/** Returns value as an unsigned long, converting if necessary. */ +- (unsigned long) unsignedLongValue; +/** Returns value as an unsigned long long, converting if necessary. */ +- (unsigned long long) unsignedLongLongValue; +/** Returns value as an unsigned short, converting if necessary. */ +- (unsigned short) unsignedShortValue; + +/** Returns -description . */ +- (NSString*) stringValue; + +/** + * Returns the string representation of this number using a non-localised + * conversion (decimal point is '.' irrespective of the locale). + */ +- (NSString*) description; + +/** + *

+ * Produces a string representation of the number. For a boolean + * this will be either 'true' or 'false'. For other numbers the + * format is produced using the initWithFormat:locale:... method + * of NSString, and the format depends on the type of number as + * follows - + *

+ * + * char + * %i + * short + * %hi + * int + * %i + * long + * %li + * long long + * %lli + * unsigned char + * %u + * unsigned short + * %hu + * unsigned int + * %u + * unsigned long + * %lu + * unsigned long long + * %llu + * float + * %0.7g + * double + * %0.16g + * + */ +- (NSString*) descriptionWithLocale: (id)locale; + +/** + * Compares receiver with otherNumber, using C type conversion if necessary, + * and returns NSOrderedAscending, + * NSOrderedDescending, or NSOrderedSame depending + * on whether it is less than, greater than, or equal to otherNumber. + */ +- (NSComparisonResult) compare: (NSNumber*)otherNumber; + +/** + * Returns whether receiver and otherNumber represent the same numerical value. + */ +- (BOOL) isEqualToNumber: (NSNumber*)otherNumber; + + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +/** Return a number intialised with NSInteger. + */ ++ (NSNumber*) numberWithInteger: (NSInteger)value; +/** Return a number intialised with NSUInteger. + */ ++ (NSNumber*) numberWithUnsignedInteger: (NSUInteger)value; +/** Initialise the receiver with NSInteger content. + */ +- (id) initWithInteger: (NSInteger)value; +/** Initialise the receiver with NSUInteger content. + */ +- (id) initWithUnsignedInteger: (NSUInteger)value; +/** Return the contents of the receiver as NSInteger. + */ +- (NSInteger) integerValue; +/** Return the contents of the receiver as NSUInteger. + */ +- (NSUInteger) unsignedIntegerValue; +#endif + +@end + +#if OS_API_VERSION(GS_API_NONE, GS_API_NONE) + +/** Note: Defines a method that is not in the OpenStep spec, but makes + subclassing easier. */ +@interface NSValue (Subclassing) + +/** Used by value: withObjCType: to determine the concrete subclass to alloc. */ ++ (Class) valueClassWithObjCType: (const char*)type; + +@end +#endif + +#if defined(__cplusplus) +} +#endif + +#if !NO_GNUSTEP && !defined(GNUSTEP_BASE_INTERNAL) +#import "../GNUstepBase/NSNumber+GNUstepBase.h" +#endif + +#endif /* __NSValue_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSZone.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSZone.h new file mode 100644 index 00000000000..21776f65c3b --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSZone.h @@ -0,0 +1,335 @@ +/** Zone memory management. -*- Mode: ObjC -*- + Copyright (C) 1997,1998,1999 Free Software Foundation, Inc. + + Written by: Yoo C. Chung + Date: January 1997 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + + AutogsdocSource: NSZone.m + AutogsdocSource: NSPage.m + + */ + +#ifndef __NSZone_h_GNUSTEP_BASE_INCLUDE +#define __NSZone_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +/** + * Primary structure representing an NSZone. Technically it + * consists of a set of function pointers for zone upkeep functions plus some + * other things- + +{ + // Functions for zone. + void *(*malloc)(struct _NSZone *zone, size_t size); + void *(*realloc)(struct _NSZone *zone, void *ptr, size_t size); + void (*free)(struct _NSZone *zone, void *ptr); + void (*recycle)(struct _NSZone *zone); + BOOL (*check)(struct _NSZone *zone); + BOOL (*lookup)(struct _NSZone *zone, void *ptr); + + // Zone statistics (not always maintained). + struct NSZoneStats (*stats)(struct _NSZone *zone); + + size_t gran; // Zone granularity (passed in on initialization) + NSString *name; // Name of zone (default is 'nil') + NSZone *next; // Pointer used for internal management of multiple zones. +} + */ +typedef struct _NSZone NSZone; + +#import "NSObjCRuntime.h" + +@class NSString; + +#if defined(__cplusplus) +extern "C" { +#endif + +struct _NSZone +{ + /* Functions for zone. */ + void *(*malloc)(struct _NSZone *zone, size_t size); + void *(*realloc)(struct _NSZone *zone, void *ptr, size_t size); + void (*free)(struct _NSZone *zone, void *ptr); + void (*recycle)(struct _NSZone *zone); + BOOL (*check)(struct _NSZone *zone); + BOOL (*lookup)(struct _NSZone *zone, void *ptr); + struct NSZoneStats (*stats)(struct _NSZone *zone); + + size_t gran; // Zone granularity + __unsafe_unretained NSString *name; // Name of zone (default is 'nil') + NSZone *next; +}; + +/** + * Creates a new zone of start bytes, which will grow and shrink by + * granularity bytes. If canFree is 0, memory in zone is allocated but + * never freed, meaning allocation will be very fast. The whole zone can + * still be freed with NSRecycleZone(), and you should still call NSZoneFree + * on memory in the zone that is no longer needed, since a count of allocated + * pointers is kept and must reach zero before freeing the zone.
+ * If Garbage Collection is enabled, this function does nothing other than + * log a warning and return the same value as the NSDefaultMallocZone() + * function. + */ +GS_EXPORT NSZone* +NSCreateZone (NSUInteger start, NSUInteger gran, BOOL canFree); + +/** Returns the default zone for memory allocation. Memory created in this + * zone is the same as memory allocates using the system malloc() function. + */ +GS_EXPORT NSZone* +NSDefaultMallocZone (void); + +/** + * Searches and finds the zone ptr was allocated from. The speed depends + * upon the number of zones and their size.
+ * If Garbage Collection is enabled, this function always returns the + * same as the NSDefaultMallocZone() function. + */ +GS_EXPORT NSZone* +NSZoneFromPointer (void *ptr); + +/** + * Allocates and returns memory for elems items of size bytes, in the + * given zone. Returns NULL if allocation of size 0 requested. Raises + * NSMallocException if not enough free memory in zone to + * allocate and no more can be obtained from system, unless using the + * default zone, in which case NULL is returned.
+ * If Garbage Collection is enabled, this function always allocates + * non-scanned, non-collectable memory in the NSDefaultMallocZone() and + * the zone argument is ignored. + */ +GS_EXPORT void* +NSZoneMalloc (NSZone *zone, NSUInteger size); + +/** + * Allocates and returns cleared memory for elems items of size bytes, in the + * given zone. Returns NULL if allocation of size 0 requested. Raises + * NSMallocException if not enough free memory in zone to + * allocate and no more can be obtained from system, unless using the + * default zone, in which case NULL is returned.
+ * If Garbage Collection is enabled, this function always allocates + * non-scanned, non-collectable memory in the NSDefaultMallocZone() and + * the zone argument is ignored. + */ +GS_EXPORT void* +NSZoneCalloc (NSZone *zone, NSUInteger elems, NSUInteger bytes); + +/** + * Reallocates the chunk of memory in zone pointed to by ptr to a new one of + * size bytes. Existing contents in ptr are copied over. Raises an + * NSMallocException if insufficient memory is available in the + * zone and no more memory can be obtained from the system, unless using the + * default zone, in which case NULL is returned.
+ * If Garbage Collection is enabled, the zone argument is ignored. + */ +GS_EXPORT void* +NSZoneRealloc (NSZone *zone, void *ptr, NSUInteger size); + +/** + * Return memory for an entire zone to system. In fact, this will not be done + * unless all memory in the zone has been explicitly freed (by calls to + * NSZoneFree()). For "non-freeable" zones, the number of NSZoneFree() calls + * must simply equal the number of allocation calls. The default zone, on the + * other hand, cannot be recycled.
+ * If Garbage Collection is enabled, this function has not effect. + */ +GS_EXPORT void +NSRecycleZone (NSZone *zone); + +/** + * Frees memory pointed to by ptr (which should have been allocated by a + * previous call to NSZoneMalloc(), NSZoneCalloc(), or NSZoneRealloc()) and + * returns it to zone. Note, if this is a nonfreeable zone, the memory is + * not actually freed, but the count of number of free()s is updated.
+ * If Garbage Collection is enabled, the zone argument is ignored and this + * function causes ptr to be deallocated immediately. + */ +GS_EXPORT void +NSZoneFree (NSZone *zone, void *ptr); + +/** + * Sets name of the given zone (useful for debugging and logging). + */ +GS_EXPORT void +NSSetZoneName (NSZone *zone, NSString *name); + +/** + * Returns the name of the given zone (useful for debugging and logging). + */ +GS_EXPORT NSString* +NSZoneName (NSZone *zone); + +#if OS_API_VERSION(GS_API_NONE, GS_API_NONE) + +/** Deprecated ...
+ * Checks integrity of a zone. Not defined by OpenStep or OS X. + */ +BOOL +NSZoneCheck (NSZone *zone); + +/** + * NSZoneStats is the structure returned by the NSZoneStats() + * function that summarizes the current usage of a zone. It is similar to + * the structure mstats in the GNU C library. It has 5 fields of + * type size_t- + * + * bytes_total + * + * This is the total size of memory managed by the zone, in bytes. + * chunks_used + * This is the number of memory chunks in use in the zone. + * bytes_used + * This is the number of bytes in use. + * chunks_free + * This is the number of memory chunks that are not in use. + * bytes_free + * + * This is the number of bytes managed by the zone that are not in use. + * + * + */ +struct NSZoneStats +{ + size_t bytes_total; + size_t chunks_used; + size_t bytes_used; + size_t chunks_free; + size_t bytes_free; +}; + +/** Deprecated ...
+ * Obtain statistics about the zone. Implementation emphasis is on + * correctness, not speed. Not defined by OpenStep or OS X. + */ +struct NSZoneStats +NSZoneStats (NSZone *zone); + +/** + * Try to get more memory - the normal process has failed. + * If we can't do anything, just return a null pointer. + * Try to do some logging if possible. + */ +void* +GSOutOfMemory(NSUInteger size, BOOL retry); + +/** + * Called during +initialize to tell the class that instances created + * in future should have the specified instance variable as a weak + * pointer for garbage collection.
+ * NB. making a pointer weak does not mean that it is automatically + * zeroed when the object it points to is garbage collected. To get that + * behavior you must asign values to the pointer using the + * GSAssignZeroingWeakPointer() function.
+ * This function has no effect if the system is + * not built for garbage collection. + */ +GS_EXPORT void +GSMakeWeakPointer(Class theClass, const char *iVarName); + +/** + * This function must be used to assign a value to a zeroing weak pointer.
+ * A zeroing weak pointer is one where, when the garbage collector collects + * the object pointed to, it also clears the weak pointer.
+ * Assigning zero (nil) will always succeed and has the effect of telling the + * garbage collector that it no longer needs to track the previously assigned + * object. Apart from that case, a source needs to be garbage collectable for + * this function to work, and using a non-garbage collectable value will + * cause the function to return NO.
+ * If the destination object (the weak pointer watching the source object) + * belongs to a chunk of memory which may be collected before the source + * object is collected, it is important that it is finalised and the + * finalisation code assigns zero to the pointer.
+ * If garbage collection is not in use, this function performs a simple + * assignment returning YES, unless destination is null in which case it + * returns NO. + */ +GS_EXPORT BOOL +GSAssignZeroingWeakPointer(void **destination, void *source); + +#endif + +GS_EXPORT NSUInteger +NSPageSize (void) __attribute__ ((const)); + +GS_EXPORT NSUInteger +NSLogPageSize (void) __attribute__ ((const)); + +GS_EXPORT NSUInteger +NSRoundDownToMultipleOfPageSize (NSUInteger bytes) __attribute__ ((const)); + +GS_EXPORT NSUInteger +NSRoundUpToMultipleOfPageSize (NSUInteger bytes) __attribute__ ((const)); + +GS_EXPORT NSUInteger +NSRealMemoryAvailable (void); + +GS_EXPORT void* +NSAllocateMemoryPages (NSUInteger bytes); + +GS_EXPORT void +NSDeallocateMemoryPages (void *ptr, NSUInteger bytes); + +GS_EXPORT void +NSCopyMemoryPages (const void *src, void *dest, NSUInteger bytes); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, OS_API_LATEST) + +enum { + NSScannedOption = (1<<0), + NSCollectorDisabledOption = (1<<1) +}; + +/** Allocate memory. If garbage collection is not enabled this uses the + * default malloc zone and the options are ignored.
+ * If garbage collection is enabled, the allocate memory is normally not + * scanned for pointers but is itsself garbage collectable. The options + * argument is a bitmask in which NSScannedOption sets the memory to be + * scanned for pointers by the garbage collector, and + * NSCollectorDisabledOption causes the memory to be excempt from being + * garbage collected itsself.
+ * In any case the memory returned is zero'ed. + */ +GS_EXPORT void * +NSAllocateCollectable(NSUInteger size, NSUInteger options); + +/** Reallocate memory to be of a different size and/or to have different + * options settings. The behavior of options is as for + * the NSAllocateCollectable() function. + */ +GS_EXPORT void * +NSReallocateCollectable(void *ptr, NSUInteger size, NSUInteger options); + +#endif + +static inline id NSMakeCollectable(const void *cf) { +#if __has_feature(objc_arc) + return nil; +#else + return (id)cf; // Unimplemented; garbage collection is deprecated. +#endif +} + +#if defined(__cplusplus) +} +#endif + +#endif /* not __NSZone_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GNUstep.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GNUstep.h new file mode 100644 index 00000000000..c3b7f2bd55e --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GNUstep.h @@ -0,0 +1,418 @@ +/* GNUstep.h - macros to make easier to port gnustep apps to macos-x + Copyright (C) 2001 Free Software Foundation, Inc. + + Written by: Nicola Pero + Date: March, October 2001 + + This file is part of GNUstep. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __GNUSTEP_GNUSTEP_H_INCLUDED_ +#define __GNUSTEP_GNUSTEP_H_INCLUDED_ + +/* The contents of this file are designed to be usable with either + * GNUstep-base or MacOS-X Foundation. + */ + +#ifndef __has_feature +# define __has_feature(x) 0 +#endif + +/* + * __has_extension has slightly different semantics from __has_feature. + * It evaluates to true if the feature is supported by by clang for the + * current compilation unit (language and -f switches), regardless of + * whether it is part of the language standard or just a (non-standard) + * extension. + */ +#ifndef __has_extension +# define __has_extension(x) __has_feature(x) +#endif + +/* + * __has_attribute is the equivalent to __has_feature and __has_extension + * for GNU-style attributes. + */ +#ifndef __has_attribute +# define __has_attribute(x) 0 +#endif + +#if __has_feature(objc_arc) + +#ifndef RETAIN +#define RETAIN(object) (object) +#endif +#ifndef RELEASE +#define RELEASE(object) +#endif +#ifndef AUTORELEASE +#define AUTORELEASE(object) (object) +#endif + +#ifndef TEST_RETAIN +#define TEST_RETAIN(object) (object) +#endif +#ifndef TEST_RELEASE +#define TEST_RELEASE(object) +#endif +#ifndef TEST_AUTORELEASE +#define TEST_AUTORELEASE(object) (object) +#endif + +#ifndef ASSIGN +#define ASSIGN(object,value) object = (value) +#endif +#ifndef ASSIGNCOPY +#define ASSIGNCOPY(object,value) object = [(value) copy] +#endif +#ifndef DESTROY +#define DESTROY(object) object = nil +#endif + +#define IF_NO_GC(X) + +#ifndef ENTER_POOL +#define ENTER_POOL @autoreleasepool{do{ +#endif + +#ifndef LEAVE_POOL +#define LEAVE_POOL }while(0);} +#endif + +#ifndef DEALLOC +#define DEALLOC +#endif + +#else + +#ifndef RETAIN +/** + * Basic retain operation ... calls [NSObject-retain]
+ * Deprecated ... pointless on modern processors. + * Simply call the -retain method. + */ +#define RETAIN(object) [(object) retain] +#endif + +#ifndef RELEASE +/** + * Basic release operation ... calls [NSObject-release]
+ * Deprecated ... pointless on modern processors. + * Simply call the -release method. + */ +#define RELEASE(object) [(object) release] +#endif + +#ifndef AUTORELEASE +/** + * Basic autorelease operation ... calls [NSObject-autorelease]
+ * Deprecated ... pointless on modern processors. + * Simply call the -autorelease method. + */ +#define AUTORELEASE(object) [(object) autorelease] +#endif + +#ifndef TEST_RETAIN +/** + * Tested retain - only invoke the + * objective-c method if the receiver is not nil.
+ * Deprecated ... pointless on modern processors. + * Simply call the -retain method. + */ +#define TEST_RETAIN(object) ({\ +id __object = (object); (__object != nil) ? [__object retain] : nil; }) +#endif + +#ifndef TEST_RELEASE +/** + * Tested release - only invoke the + * objective-c method if the receiver is not nil.
+ * Deprecated ... pointless on modern processors. + * Simply call the -release method. + */ +#define TEST_RELEASE(object) ({\ +id __object = (object); if (__object != nil) [__object release]; }) +#endif + +#ifndef TEST_AUTORELEASE +/** + * Tested autorelease - only invoke the + * objective-c method if the receiver is not nil.
+ * Deprecated ... pointless on modern processors. + * Simply call the -autorelease method. + */ +#define TEST_AUTORELEASE(object) ({\ +id __object = (object); (__object != nil) ? [__object autorelease] : nil; }) +#endif + +#ifndef ASSIGN +/** + * ASSIGN(object,value) assigns the value to the object with + * appropriate retain and release operations.
+ * Use this to avoid retain/release errors. + */ +#define ASSIGN(object,value) ({\ + id __object = object; \ + object = [(value) retain]; \ + [__object release]; \ +}) +#endif + +#ifndef ASSIGNCOPY +/** + * ASSIGNCOPY(object,value) assigns a copy of the value to the object + * with release of the original.
+ * Use this to avoid retain/release errors. + */ +#define ASSIGNCOPY(object,value) ({\ + id __object = object; \ + object = [(value) copy];\ + [__object release]; \ +}) +#endif + +#ifndef DESTROY +/** + * DESTROY() is a release operation which also sets the variable to be + * a nil pointer for tidiness - we can't accidentally use a DESTROYED + * object later. It also makes sure to set the variable to nil before + * releasing the object - to avoid side-effects of the release trying + * to reference the object being released through the variable. + */ +#define DESTROY(object) ({ \ + id __o = object; \ + object = nil; \ + [__o release]; \ +}) +#endif + +#define IF_NO_GC(X) X + +#ifndef ENTER_POOL +/** + * ENTER_POOL creates an autorelease pool and places subsequent code + * in a do/while loop (executed only once) which can be broken out of + * to reach the point when the pool is drained.
+ * The block must be terminated with a corresponding LEAVE_POOL.
+ * You should not return from such a block of code (to do so could + * leak an autorelease pool and give objects a longer lifetime than + * they ought to have. If you wish to leave the block of code early, + * you may do so using a 'break' statement. + */ +#define ENTER_POOL {NSAutoreleasePool *_lARP=[NSAutoreleasePool new];do{ +#endif + +#ifndef LEAVE_POOL +/** + * LEAVE_POOL terminates a block of code started with ENTER_POOL. + */ +#define LEAVE_POOL }while(0);[_lARP drain];} +#endif + +#ifndef DEALLOC +/** + * DEALLOC calls the superclass implementation of dealloc, unless + * ARC is in use (in which case it does nothing). + */ +#define DEALLOC [super dealloc]; +#endif +#endif + +#ifndef CREATE_AUTORELEASE_POOL +/** DEPRECATED ... use ENTER_POOL and LEAVE_POOL + */ +#define CREATE_AUTORELEASE_POOL(X) \ + NSAutoreleasePool *X = [NSAutoreleasePool new] +#endif + +#ifndef RECREATE_AUTORELEASE_POOL +/** DEPRECATED ... use ENTER_POOL and LEAVE_POOL + */ +#define RECREATE_AUTORELEASE_POOL(X) \ + DESTROY(X);\ + X = [NSAutoreleasePool new] +#endif + + +/** + *

+ * This function (macro) is a GNUstep extension. + *

+ *

+ * _(@"My string to translate") + *

+ *

+ * is basically equivalent to + *

+ *

+ * NSLocalizedString(@"My string to translate", @"") + *

+ *

+ * It is useful when you need to translate an application + * very quickly, as you just need to enclose all strings + * inside _(). But please note that when you + * use this macro, you are not taking advantage of comments + * for the translator, so consider using + * NSLocalizedString instead when you need a + * comment. + *

+ *

You may define GS_LOCALISATION_BUNDLE_ID to the bundle identifier + * of the bundle which is to provide the localisation information.
+ * This can be used when compiling a single file by specifying something like + * '-D GS_LOCALISATION_BUNDLE_ID=$(FRAMEWORK_NAME)' in your make file.
+ * If this is not defined, the localisation is provided by your application's + * main bundle exactly like the NSLocalizedString function. + *

+ *

Alternatively you may define GS_LOCALISATION_BUNDLE to be the bundle + * to be used to prvide the localisation information. + *

+ */ +# define _(X) \ + [GS_LOCALISATION_BUNDLE localizedStringForKey: (X) value: @"" table: nil] + +#if !defined(GS_LOCALISATION_BUNDLE) +# if defined(GS_LOCALISATION_BUNDLE_ID) +# define GS_LOCALISATION_BUNDLE [NSBundle bundleWithIdentifier: \ + GS_LOCALISATION_BUNDLE_ID] +# else +# define GS_LOCALISATION_BUNDLE [NSBundle mainBundle] +# endif +#endif + + + +/** + *

+ * This function (macro) is a GNUstep extension. + *

+ *

+ * __(@"My string to translate") + *

+ *

+ * is exactly the same as + *

+ *

+ * GSLocalizedStaticString(@"My string to translate", @"") + *

+ *

+ * It is useful when you need to translate an application very + * quickly. You would use it as follows for static strings: + *

+ *

+ * + * NSString *message = __(@"Hello there"); + * ... more code ... + * NSLog (_(messages)); + * + *

+ *

+ * But please note that when you use this macro, you are not + * taking advantage of comments for the translator, so + * consider using GSLocalizedStaticString + * instead when you need a comment. + *

+ */ +#define __(X) X + +/* The better way for a static string, with a comment - use as follows - + * + * static NSString *string = GSLocalizedStaticString (@"New Game", + * @"Menu Option"); + * + * NSLog (_(string)); + * + * If you need anything more complicated than this, please initialize + * the static strings manually. + */ + +/** + *

+ * This function (macro) is a GNUstep extensions, and it is used + * to localize static strings. Here is an example of a static + * string: + *

+ *

+ * + * NSString *message = @"Hi there"; + * ... some code ... + * NSLog (message); + * + *

+ *

+ * This string can not be localized using the standard + * openstep functions/macros. By using this gnustep extension, + * you can localize it as follows: + *

+ *

+ * + * NSString *message = GSLocalizedStaticString (@"Hi there", + * @"Greeting"); + * + * ... some code ... + * + * NSLog (NSLocalizedString (message, @"")); + * + *

+ *

+ * When the tools generate the + * Localizable.strings file from the source + * code, they will ignore the NSLocalizedString + * call while they will extract the string (and the comment) + * to localize from the GSLocalizedStaticString + * call. + *

+ *

+ * When the code is compiled, instead, the + * GSLocalizedStaticString call is ignored (discarded, + * it is a macro which simply expands to key), while + * the NSLocalizedString will actually look up the + * string for translation in the Localizable.strings + * file. + *

+ *

+ * Please note that there is currently no macro/function to + * localize static strings using different tables. If you + * need that functionality, you have either to prepare the + * localization tables by hand, or to rewrite your code in + * such a way as not to use static strings. + *

+ */ +#define GSLocalizedStaticString(key, comment) key + +/** + * To be used inside a method for making sure that a range does not specify + * anything outside the size of an array/string. Raises exception if range + * extends beyond [0,size]. Size must be an unsigned integer (NSUInteger). + */ +#define GS_RANGE_CHECK(RANGE, SIZE) \ + if (RANGE.location > (NSUInteger)SIZE \ + || RANGE.length > ((NSUInteger)SIZE - RANGE.location)) \ + [NSException raise: NSRangeException format: @"in %s, range { %"\ + PRIuPTR ", %" PRIuPTR " } extends beyond size (%" PRIuPTR ")", \ + GSNameFromSelector(_cmd), RANGE.location, RANGE.length, (NSUInteger)SIZE] + +/** Checks whether INDEX is strictly less than OVER (within C array space). + * INDEX and OVER must be unsigned integers (NSUInteger). + */ +#define CHECK_INDEX_RANGE_ERROR(INDEX, OVER) \ +if ((NSUInteger)INDEX >= (NSUInteger)OVER) \ + [NSException raise: NSRangeException \ + format: @"in %s, index %" PRIuPTR " is out of range", \ + GSNameFromSelector(_cmd), (NSUInteger)INDEX] + +#endif /* __GNUSTEP_GNUSTEP_H_INCLUDED_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSBlocks.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSBlocks.h new file mode 100644 index 00000000000..ac4e9c92ea6 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSBlocks.h @@ -0,0 +1,145 @@ +/** Definitions for block support for GNUStep + Copyright (C) 2011 Free Software Foundation, Inc. + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + + */ + +#ifndef __GSBlocks_h_GNUSTEP_BASE_INCLUDE +#define __GSBlocks_h_GNUSTEP_BASE_INCLUDE + +/* Define the has_feature pseudo-macro for GCC. */ +#ifndef __has_feature +#define __has_feature(x) 0 +#endif + +#ifndef GCC_VERSION +#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) +#endif + +#if __has_feature(blocks) + +#define BLOCK_SCOPE __block +/** + * Defines a block type. Will work whether or not the compiler natively + * supports blocks. + */ +#define DEFINE_BLOCK_TYPE(name, retTy, argTys, ...) \ +typedef retTy(^name)(argTys, ## __VA_ARGS__) + +#define DEFINE_BLOCK_TYPE_NO_ARGS(name, retTy) \ +typedef retTy(^name)() + +/** + * Calls a block. Works irrespective of whether the compiler supports blocks. + */ +#define CALL_BLOCK(block, args, ...) block(args, ## __VA_ARGS__) + +/** + * Calls a block without arguments. + */ +#define CALL_BLOCK_NO_ARGS(block) block() +#else + +/* Fall-back versions for when the compiler doesn't have native blocks support. + */ +#if (GCC_VERSION >= 3000) + +#define DEFINE_BLOCK_TYPE(name, retTy, argTys, ...) \ + typedef struct {\ + void *isa;\ + int flags;\ + int reserved;\ + retTy (*invoke)(void*, argTys, ## __VA_ARGS__);\ + } *name + +#define DEFINE_BLOCK_TYPE_NO_ARGS(name, retTy) \ + typedef struct {\ + void *isa;\ + int flags;\ + int reserved;\ + retTy (*invoke)(void*);\ + } *name + +#define CALL_BLOCK(block, args, ...) block->invoke(block, args, ## __VA_ARGS__) + +#define CALL_BLOCK_NO_ARGS(block) block->invoke(block) +#define BLOCK_SCOPE + +#else /* GCC_VERSION >= 3000 */ + +#define DEFINE_BLOCK_TYPE(name, retTy, argTys...) \ + typedef struct {\ + void *isa;\ + int flags;\ + int reserved;\ + retTy (*invoke)(void*, argTys);\ + } *name + +#define DEFINE_BLOCK_TYPE_NO_ARGS(name, retTy) \ + typedef struct {\ + void *isa;\ + int flags;\ + int reserved;\ + retTy (*invoke)(void*);\ + } *name + + +#define CALL_BLOCK(block, args...) block->invoke(block, args) +#define CALL_BLOCK_NO_ARGS(block) block->invoke(block) +#define BLOCK_SCOPE +#endif /* GCC_VERSION >= 3000 */ + +#endif /* __has_feature(blocks) */ + +#if __has_include() +# include +#else + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * _Block_copy and _Block_release are weakly imported, but can be assumed + * to be available whenever a feature using blocks is accessed + * by an application. + */ + +/* weak attributed supported only with ELF, MINGW is COFF */ +#ifndef __MINGW32__ + +void *_Block_copy(const void *) __attribute__((weak)); +void _Block_release(const void *) __attribute__((weak)); + +#endif /* __MINGW32__ */ + +#ifdef __cplusplus +} +#endif + +#ifndef Block_copy +# define Block_copy(x) ((__typeof(x))_Block_copy((const void *)(x))) +#endif +#ifndef Block_release +# define Block_release(x) _Block_release((const void *)(x)) +#endif + +#endif /* __has_include() */ +#endif /* __GSBlocks_h_GNUSTEP_BASE_INCLUDE */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSConfig.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSConfig.h new file mode 100644 index 00000000000..a0e7cc7a409 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSConfig.h @@ -0,0 +1,462 @@ +/* Machine/OS specific configuration information for GNUstep + + Please NOTE - GSConfig.h is generated by the configure script from the + file GSConfig.h.in - changes/fixes need to be made to the original file, + not to the GSConfig.h generated from it. + + Copyright (C) 1998-2010 Free Software Foundation, Inc. + + Written by: Richard frith-Macdonald + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + */ + +#ifndef included_GSConfig_h +#define included_GSConfig_h + +/* Check the compiler to see if we are building on/for ms-windows. + * Whatever the compiler uses, we want a standard setting of _WIN64 + * to indicate 64bit AND _WIN32 to indicate ms-windows. + * These are defined by gcc, clang, and microsoft compilers anyway. + */ +#if defined(__WIN32__) \ + || defined(__MS_WIN32__) \ + || defined(__MINGW32__) +# if !defined(_WIN32) +# define _WIN32 +# endif +#endif +#if defined(__WIN64__) \ + || defined(__MS_WIN64__) \ + || defined(__MINGW64__) +# if !defined(__WIN64__) +# define __WIN64__ +# endif +# if !defined(_WIN32) +# define _WIN32 +# endif +#endif + +/* Check to see if this is a MINGW build (all we currently support) + */ +#if defined(__MINGW32__) || defined(__MINGW64__) +# if !defined(__MINGW__) +# define __MINGW__ +# endif +#endif + +// Make sure we expose the constants that we use in ObjC++ mode +#ifndef __STDC_CONSTANT_MACROS +#define __STDC_CONSTANT_MACROS 1 +#endif +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#if !defined(NeXT_Foundation_LIBRARY) + +/* An alternate to GS_FAKE_MAIN which forces the user to call the + NSProcessInfo initialization in 'main', GS_FAKE_MAIN must also + be undefined. */ +#if 0 +#define GS_PASS_ARGUMENTS 0 +#endif + +#define GS_FAKE_MAIN 0 +#if GS_FAKE_MAIN + +/* + * NOTE - if GS_FAKE_MAIN (above) is set to 1, this hack applies - and you + * must make sure that this file is included in any file that implements + * the 'main()' function and links with the GNUstep base libarary. + * You should NOT include this file in a program that does not link with + * the base library. + * This file is included automatically in NSObject.h and Foundation.h + * + * The Foundation classe NSProcessInfo need access to the argc, argv, + * and env variables of the main() function. The purpose of this (ugly hack) + * definition is to give the gstep-base library the opportunity to implement + * its own main function with private access to the global vars. The private + * main() implementation (in NSProcessInfo.m) will then call the user defined + * gnustep_base_user_main() function. + * + * The original hack was - + ** Written by: Georg Tuparev, EMBL & Academia Naturalis, + ** Heidelberg, Germany + ** Tuparev@EMBL-Heidelberg.de + ** + ** NOTE! This is very dirty and dangerous trick. I spend several hours + ** on thinking and man pages browsing, but couldn't find better solution. + ** I know that I will spend 666 years in the Computer Hell for writing + ** this hack, and the master devil (Bully Boy) will send me to write + ** Windowz software. + ** BTW, for writing this hack I got personal congratulations from Dennis + ** Ritchie and Bjarne Stroustrup sent me a bunch of flowers and asked me + ** to participate in the standardization committee for C-- v.6.0 as + ** responsible for the new Tab-Overriding-Operator and Scope-Sensitive- + ** Comments ... but this makes my situation even worse ;-) + ** - Georg + * + * On some systems, there are other relatively clean workarounds, if this + * applies to the system you are running on, your configuration script + * should have set GS_FAKE_MAIN to zero, so that this define hack will + * not be used. + */ + +#define main gnustep_base_user_main + +#endif /* GS_FAKE_MAIN */ +#endif + +/* + * Definition to specify if your processor stores words with the most + * significant byte first (like Motorola and SPARC, unlike Intel and VAX). + */ +#define GS_WORDS_BIGENDIAN 0 + +/* + * Size definitions for standard types + */ +#define GS_SIZEOF_SHORT 2 +#define GS_SIZEOF_INT 4 +#define GS_SIZEOF_LONG 8 +#define GS_SIZEOF_LONG_LONG 8 +#define GS_SIZEOF_FLOAT 4 +#define GS_SIZEOF_DOUBLE 8 +#define GS_SIZEOF_VOIDP 8 + +/* + * Size information to be places in bits 5 and 6 of type encoding bytes + * in archives (bits 0 to 4 are used for basic type info and bit 7 is + * used to mark cross-references to previously encoded objects). + */ +#define _GSC_S_SHT _GSC_I16 +#define _GSC_S_INT _GSC_I32 +#define _GSC_S_LNG _GSC_I64 +#define _GSC_S_LNG_LNG _GSC_I64 + +/* + * Type definitions for types with known sizes. + */ +typedef signed char gss8; +typedef unsigned char gsu8; +typedef signed short gss16; +typedef unsigned short gsu16; +typedef signed int gss32; +typedef unsigned int gsu32; +typedef signed long gss64; +typedef unsigned long gsu64; +typedef struct { gsu8 a[16]; } gss128; +typedef struct { gsu8 a[16]; } gsu128; +typedef float gsf32; +typedef double gsf64; + +/* + * Integer type with same size as a pointer + */ +typedef unsigned long gsuaddr; +typedef long gssaddr; +typedef gsuaddr gsaddr; + +/* + * Do we have real 64-bit and 128-bit integers or are we just pretending. + */ +#define GS_HAVE_I64 1 +#define GS_HAVE_I128 0 + +/* + * Ensure some standard types are defined. + */ +#include + + + + + + + + + + + +/* + * PTR Limit information replacements for buggy headers + */ +#if 0 +#undef INTPTR_MAX +#define INTPTR_MAX +#undef INTPTR_MIN +#define INTPTR_MIN +#undef UINTPTR_MAX +#define UINTPTR_MAX +#endif + + +/* + * Do we have zlib for file handle compression? + */ +#define USE_ZLIB 1 + +/* + * Do we have the GNU Multiple-precision library for NSDecimal? + */ +//#define USE_GMP 1 +#define USE_GMP 0 + +#ifdef GS_WITH_GC +#undef GS_WITH_GC +#endif +#define GS_WITH_GC 0 + +/* + * Define to say if we use NXConstantString or NSConstantString + */ +#define NXConstantString NSConstantString + + +/* + * Wide unicode character type. + */ +#ifndef UTF32Char +#define UTF32Char uint32_t +#endif + +/* + * Native character type for use in systemcalls etc. + */ + +#if defined(__MINGW__) +# define GSNativeChar uint16_t +#else +# define GSNativeChar char +#endif + +/* + * Types used to avoid exposing pthread header in NSLock.h + * NB. These types should *never* be used except to provide enough space + * in a class layout for the type of data actually used by the pthread + * implementation of the current platform. + */ +typedef struct { + uint8_t dummy[48]; +} gs_cond_t __attribute__((aligned (8))); +typedef struct { + uint8_t dummy[40]; +} gs_mutex_t __attribute__((aligned (8))); + +#define OBJC2RUNTIME 1 +#define BASE_NATIVE_OBJC_EXCEPTIONS 1 +#define GS_NONFRAGILE 0 +#define GS_MIXEDABI 0 +#define GS_USE_LIBXML 0 +#define GS_USE_GNUTLS 0 +#define GS_USE_AVAHI 0 +#define GS_USE_MDNS 0 +#define GS_USE_ICU 0 +#define GS_USE_LIBDISPATCH 0 +#define GS_USE_LIBDISPATCH_RUNLOOP 0 +#define GS_HAVE_OBJC_ROOT_CLASS_ATTR 0 + +#ifndef __has_include +# define __has_include(x) 0 +#endif +#ifndef __has_feature +# define __has_feature(x) 0 +#endif +#ifndef __has_builtin +# define __has_builtin(x) 0 +#endif + +/* + * __has_extension has slightly different semantics from __has_feature. + * It evaluates to true if the feature is supported by by clang for the + * current compilation unit (language and -f switches), regardless of + * whether it is part of the language standard or just a (non-standard) + * extension. + */ +#ifndef __has_extension +# define __has_extension(x) __has_feature(x) +#endif + +#if defined(_WIN32) +#define BOOL WinBOOL +#define __OBJC_BOOL 1 +#include +#ifndef _WIN32_WINNT +#define _WIN32_WINNT Windows2000 +#endif +#if !defined(WINVER) +#define WINVER Windows2000 +#elif (WINVER < Windows2000) +#undef WINVER +#define WINVER Windows2000 +#endif + +#if defined(__WIN64__) +#include +#include +#else +#include +#include +#endif + +#undef __OBJC_BOOL +#undef BOOL +#endif + +/* Include the blocks runtime header if it's available (It shouldn't matter + * that this doesn't work on compilers that don't support __has_include(), + * because they also don't support blocks). + */ +#if __has_include() +# include +#endif + +#ifndef _WIN32 +#include /* Hack to get rid of warning in GNU libc 2.0.3. */ +#endif + +/* The following group of lines maintained by the gstep-base configure */ +#define GNUSTEP_BASE_VERSION 1.26.0 +#define GNUSTEP_BASE_MAJOR_VERSION 1 +#define GNUSTEP_BASE_MINOR_VERSION 26 +#define GNUSTEP_BASE_SUBMINOR_VERSION 0 +#define GNUSTEP_BASE_GCC_VERSION 4.0.0 + +/* Do not use the following macros! + */ +#define OBJC_DEP(M) \ + ({ static BOOL beenHere = NO; if (beenHere == NO) {\ + beenHere = YES; fprintf(stderr, "%s:%d %s", __FILE__, __LINE__, (M));}}) + +#define OBJC_MALLOC(VAR, TYPE, NUM) \ + (OBJC_DEP("OBJC_MALLOC is deprecated ... use malloc\n"),(VAR) = (TYPE *) malloc ((unsigned)(NUM)*sizeof(TYPE))) +#define OBJC_VALLOC(VAR, TYPE, NUM) \ + (OBJC_DEP("OBJC_VALLOC is deprecated\n"),(VAR) = (TYPE *) valloc ((unsigned)(NUM)*sizeof(TYPE))) +#define OBJC_ATOMIC_MALLOC(VAR, TYPE, NUM) \ + (OBJC_DEP("OBJC_ATOMIC_MALLOC is deprecated\n"),(VAR) = (TYPE *) malloc ((unsigned)(NUM)*sizeof(TYPE))) +#define OBJC_REALLOC(VAR, TYPE, NUM) \ + (OBJC_DEP("OBJC_REALLOC is deprecated ... use realloc\n"),(VAR) = (TYPE *) realloc ((VAR), (unsigned)(NUM)*sizeof(TYPE))) +#define OBJC_CALLOC(VAR, TYPE, NUM) \ + (OBJC_DEP("OBJC_CALLOC is deprecated ... use calloc\n"),(VAR) = (TYPE *) calloc ((unsigned)(NUM), sizeof(TYPE))) +#define OBJC_FREE(PTR) (OBJC_DEP("OBJC_FREE is deprecated ... use free\n"), free (PTR)) + +#ifndef MAX +#define MAX(a,b) \ + ({__typeof__(a) _MAX_a = (a); __typeof__(b) _MAX_b = (b); \ + _MAX_a > _MAX_b ? _MAX_a : _MAX_b; }) +#endif + +#ifndef MIN +#define MIN(a,b) \ + ({__typeof__(a) _MIN_a = (a); __typeof__(b) _MIN_b = (b); \ + _MIN_a < _MIN_b ? _MIN_a : _MIN_b; }) +#endif + +#ifndef ABS +#define ABS(a) \ + ({__typeof__(a) _ABS_a = (a); \ + _ABS_a < 0 ? -_ABS_a : _ABS_a; }) +#endif + +#ifndef STRINGIFY +#define STRINGIFY(s) XSTRINGIFY(s) +#define XSTRINGIFY(s) #s +#endif + +#ifndef OBJC_STRINGIFY +#define OBJC_STRINGIFY(s) OBJC_XSTRINGIFY(s) +#define OBJC_XSTRINGIFY(s) @#s +#endif + +#ifndef PTR2LONG +#define PTR2LONG(P) (((char*)(P))-(char*)0) +#endif +#ifndef LONG2PTR +#define LONG2PTR(L) (((char*)0)+(L)) +#endif + +#if VSPRINTF_RETURNS_LENGTH +#define VSPRINTF_LENGTH(VSPF_CALL) (VSPF_CALL) +#else +#define VSPRINTF_LENGTH(VSPF_CALL) strlen((VSPF_CALL)) +#endif /* VSPRINTF_RETURNS_LENGTH */ + +#if VASPRINTF_RETURNS_LENGTH +#define VASPRINTF_LENGTH(VASPF_CALL) (VASPF_CALL) +#else +#define VASPRINTF_LENGTH(VASPF_CALL) strlen((VASPF_CALL)) +#endif /* VSPRINTF_RETURNS_LENGTH */ + +/* Evil hack to stop gcc-4.1 complaining about a dealloc method which + * does not call the superclass implementation. + */ +#define GSNOSUPERDEALLOC if (0) [super dealloc] + +#ifndef CF_EXCLUDE_CSTD_HEADERS +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#if !__has_feature(objc_arc) +// NetBSD > 6 defines __weak in cdefs_elf.h +#ifdef __NetBSD__ +#undef __weak +#endif +# if !defined(__weak) +# define __weak +# endif +# if !defined(__strong) +# define __strong +# endif +#endif + +#ifndef __unsafe_unretained +# if !__has_feature(objc_arc) +# define __unsafe_unretained +# endif +#endif +#ifndef __bridge +# if !__has_feature(objc_arc) +# define __bridge +# endif +#endif + +#if __has_builtin(__builtin_unreachable) +# define GS_UNREACHABLE() __builtin_unreachable() +#else +# define GS_UNREACHABLE() abort() +#endif + +#endif /* included_GSConfig_h */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSObjCRuntime.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSObjCRuntime.h new file mode 100644 index 00000000000..2088ee2e886 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSObjCRuntime.h @@ -0,0 +1,631 @@ +/** Interface to ObjC runtime for GNUStep + Copyright (C) 1995, 1997, 2000, 2002, 2003 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum + Date: 1995 + Written by: Richard Frith-Macdonald + Date: 2002 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + + AutogsdocSource: Additions/GSObjCRuntime.m + + */ + +#ifndef __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE +#define __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE + +#import "GSVersionMacros.h" +#import "GSConfig.h" + +#include + +#if 1 || NeXT_RUNTIME + #include + #include + #include + #ifndef _C_ATOM + #define _C_ATOM '%' + #endif + #define _F_CONST 0x01 + #define _F_IN 0x01 + #define _F_OUT 0x02 + #define _F_INOUT 0x03 + #define _F_BYCOPY 0x04 + #define _F_ONEWAY 0x08 + #define _C_CONST 'r' + #define _C_IN 'n' + #define _C_INOUT 'N' + #define _C_OUT 'o' + #define _C_BYCOPY 'O' + #define _C_ONEWAY 'V' +#else /* GNU Objective C Runtime */ + #include + #if defined (__GNU_LIBOBJC__) + #include + #else + #include + #include + #endif +#endif + +/* + * Hack for older compiler versions that don't have all defines + * needed in objc-api.h + */ +#ifndef _C_LNG_LNG +#define _C_LNG_LNG 'q' +#endif +#ifndef _C_ULNG_LNG +#define _C_ULNG_LNG 'Q' +#endif + +#if OBJC2RUNTIME +/* We have a real ObjC2 runtime. + */ +#include +#else +/* We emulate an ObjC2 runtime. + */ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +@class NSArray; +@class NSDictionary; +@class NSObject; +@class NSString; +@class NSValue; + +#ifndef YES +#define YES 1 +#endif +#ifndef NO +#define NO 0 +#endif +#ifndef nil +#define nil 0 +#endif + +#if !defined(_C_CONST) +#define _C_CONST 'r' +#endif +#if !defined(_C_IN) +#define _C_IN 'n' +#endif +#if !defined(_C_INOUT) +#define _C_INOUT 'N' +#endif +#if !defined(_C_OUT) +#define _C_OUT 'o' +#endif +#if !defined(_C_BYCOPY) +#define _C_BYCOPY 'O' +#endif +#if !defined(_C_BYREF) +#define _C_BYREF 'R' +#endif +#if !defined(_C_ONEWAY) +#define _C_ONEWAY 'V' +#endif +#if !defined(_C_GCINVISIBLE) +#define _C_GCINVISIBLE '!' +#endif + +/* + * Functions for accessing instance variables directly - + * We can copy an ivar into arbitrary data, + * Get the type encoding for a named ivar, + * and copy a value into an ivar. + */ +GS_EXPORT BOOL +GSObjCFindVariable(id obj, const char *name, + const char **type, unsigned int *size, int *offset); + +GS_EXPORT void +GSObjCGetVariable(id obj, int offset, unsigned int size, void *data); + +GS_EXPORT void +GSObjCSetVariable(id obj, int offset, unsigned int size, const void *data); + +GS_EXPORT NSArray * +GSObjCMethodNames(id obj, BOOL recurse); + +GS_EXPORT NSArray * +GSObjCVariableNames(id obj, BOOL recurse); + +/** + *

A Behavior can be seen as a "Protocol with an implementation" or a + * "Class without any instance variables". A key feature of behaviors + * is that they give a degree of multiple inheritance. + *

+ *

Behavior methods, when added to a class, override the class's + * superclass methods, but not the class's methods. + *

+ *

Whan a behavior class is added to a receiver class, not only are the + * methods defined in the behavior class added, but the methods from the + * behavior's class hierarchy are also added (unless already present). + *

+ *

It's not the case that a class adding behaviors from another class + * must have "no instance vars". The receiver class just has to have the + * same layout as the behavior class (optionally with some additional + * ivars after those of the behavior class). + *

+ *

This function provides Behaviors without adding any new syntax to + * the Objective C language. Simply define a class with the methods you + * want to add, then call this function with that class as the behavior + * argument. + *

+ *

This function should be called in the +initialize method of the receiver. + *

+ *

If you add several behaviors to a class, be aware that the order of + * the additions is significant. + *

+ */ +GS_EXPORT void +GSObjCAddClassBehavior(Class receiver, Class behavior); + +/** + *

An Override can be seen as a "category implemented as a separate class + * and manually added to the receiver class under program control, rather + * than automatically added by the compiler/runtime. + *

+ *

Override methods, when added to a receiver class, replace the class's + * class's methods of the same name (or are added if the class did not define + * methods with that name). + *

+ *

It's not the case that a class adding overrides from another class + * must have "no instance vars". The receiver class just has to have the + * same layout as the override class (optionally with some additional + * ivars after those of the override class). + *

+ *

This function provides overrides without adding any new syntax to + * the Objective C language. Simply define a class with the methods you + * want to add, then call this function with that class as the override + * argument. + *

+ *

This function should usually be called in the +initialize method + * of the receiver. + *

+ *

If you add several overrides to a class, be aware that the order of + * the additions is significant. + *

+ */ +GS_EXPORT void +GSObjCAddClassOverride(Class receiver, Class override); + +/** Turn on (YES), off (NO) or test (-1) behavior debugging. + */ +GS_EXPORT BOOL GSObjCBehaviorDebug(int setget); + +GS_EXPORT NSValue * +GSObjCMakeClass(NSString *name, NSString *superName, NSDictionary *iVars); + +GS_EXPORT void +GSObjCAddClasses(NSArray *classes); + +/** + * Given a NULL terminated list of methods, add them to the class.
+ * If the method already exists in a superclass, the new version overrides + * that one, but if the method already exists in the class itsself, the + * new one is quietly ignored (replace==NO) or replaced with the new + * version (if replace==YES).
+ * To add class methods, cls should be the metaclass of the class to + * which the methods are being added. + */ +GS_EXPORT void +GSObjCAddMethods(Class cls, Method *list, BOOL replace); + +/* + * Functions for key-value encoding ... they access values in an object + * either by selector or directly, but do so using NSNumber for the + * scalar types of data. + */ +GS_EXPORT id +GSObjCGetVal(NSObject *self, const char *key, SEL sel, + const char *type, unsigned size, int offset); + +GS_EXPORT void +GSObjCSetVal(NSObject *self, const char *key, id val, SEL sel, + const char *type, unsigned size, int offset); + +/* + * This section includes runtime functions + * to query and manipulate the ObjC runtime structures. + * These functions take care to not use ObjC code so + * that they can safely be used in +(void)load implementations + * where applicable. + */ + +/** + * Deprecated ... use objc_getClassList() + */ +GS_EXPORT unsigned int +GSClassList(Class *buffer, unsigned int max, BOOL clearCache); + +/** + * GSObjCClass() is deprecated ... use object_getClass() + */ +GS_EXPORT Class GSObjCClass(id obj); + +/** + * GSObjCSuper() is deprecated ... use class_getSuperclass() + */ +GS_EXPORT Class GSObjCSuper(Class cls); + +/** + * GSObjCIsInstance() is deprecated ... use object_getClass() + * in conjunction with class_isMetaClass() + */ +GS_EXPORT BOOL GSObjCIsInstance(id obj); + +/** + * GSObjCIsClass() is deprecated ... use object_getClass() + * in conjunction with class_isMetaClass() + */ +GS_EXPORT BOOL GSObjCIsClass(Class cls); + +/** + * Test to see if class inherits from another class + * The argument to this function must NOT be nil. + */ +GS_EXPORT BOOL GSObjCIsKindOf(Class cls, Class other); + +/** + * GSClassFromName() is deprecated ... use objc_lookUpClass() + */ +GS_EXPORT Class GSClassFromName(const char *name); + +/** + * GSNameFromClass() is deprecated ... use class_getName() + */ +GS_EXPORT const char *GSNameFromClass(Class cls); + +/** + * GSClassNameFromObject() is deprecated ... use object_getClass() + * in conjunction with class_getName() + */ +GS_EXPORT const char *GSClassNameFromObject(id obj); + +/** + * GSNameFromSelector() is deprecated ... use sel_getName() + */ +GS_EXPORT const char *GSNameFromSelector(SEL sel); + +/** + * GSSelectorFromName() is deprecated ... use sel_getUid() + */ +GS_EXPORT SEL +GSSelectorFromName(const char *name); + +/** + * Return the selector for the specified name and types.
+ * Returns a nul pointer if the name is nul.
+ * Creates a new selector if necessary.
+ * Code must NOT rely on this providing a selector with type information. + */ +GS_EXPORT SEL +GSSelectorFromNameAndTypes(const char *name, const char *types); + +/** + * Return the type information from the specified selector.
+ * May return a nul pointer if the selector was a nul pointer or if it + * was not typed (or if the runtime does not support typed selectors).
+ * Code must NOT rely on this providing any type information. + */ +GS_EXPORT const char * +GSTypesFromSelector(SEL sel); + +/** + * Compare only the type information ignoring qualifiers, the frame layout + * and register markers. Unlike sel_types_match, this function also + * handles comparisons of types with and without any layout information. + */ +GS_EXPORT BOOL +GSSelectorTypesMatch(const char *types1, const char *types2); + +/** Takes full type information and skips forward to the actual type + * as specified in the _C_... constants. + */ +GS_EXPORT const char * +GSSkipTypeQualifierAndLayoutInfo(const char *types); + +/** + * Returns a protocol object with the corresponding name. + * This function searches the registered classes for any protocol + * with the supplied name. If one is found, it is cached in + * for future requests. If efficiency is a factor then use + * GSRegisterProtocol() to insert a protocol explicitly into the cache + * used by this function. If no protocol is found this function returns + * nil. + */ +GS_EXPORT Protocol * +GSProtocolFromName(const char *name); + +/** + * Registers proto in the cache used by GSProtocolFromName(). + */ +GS_EXPORT void +GSRegisterProtocol(Protocol *proto); + +/** + * A variant of protocol_getMethodDescription which recursively searches + * parent protocols if the requested selector isn't found in the given + * protocol. + * + * Returns a {NULL, NULL} structure if the requested selector couldn't be + * found. + */ +GS_EXPORT struct objc_method_description +GSProtocolGetMethodDescriptionRecursive(Protocol *aProtocol, SEL aSel, BOOL isRequired, BOOL isInstance); + +/* + * Unfortunately the definition of the symbols + * 'Method(_t)', 'MethodList(_t)' and 'IVar(_t)' + * are incompatible between the GNU and NeXT/Apple runtimes. + * We introduce GSMethod, GSMethodList and GSIVar to allow portability. + */ +typedef Method GSMethod; +typedef Ivar GSIVar; + +/** + * Returns the pointer to the method structure + * for the selector in the specified class. + * Depending on searchInstanceMethods, this function searches + * either instance or class methods. + * Depending on searchSuperClassesm this function searches + * either the specified class only or also its superclasses.
+ * To obtain the implementation pointer IMP use returnValue->method_imp + * which should be safe across all runtimes.
+ * It should be safe to use this function in +load implementations.
+ * This function should currently (June 2004) be considered WIP. + * Please follow potential changes (Name, parameters, ...) closely until + * it stabilizes. + */ +GS_EXPORT GSMethod +GSGetMethod(Class cls, SEL sel, + BOOL searchInstanceMethods, + BOOL searchSuperClasses); + +/** + * Deprecated .. does nothing. + */ +GS_EXPORT void +GSFlushMethodCacheForClass (Class cls); + +/** + * Deprecated .. use class_getInstanceVariable() + */ +GS_EXPORT GSIVar +GSCGetInstanceVariableDefinition(Class cls, const char *name); + +/** + * Deprecated .. use class_getInstanceVariable() + */ +GS_EXPORT GSIVar +GSObjCGetInstanceVariableDefinition(Class cls, NSString *name); + +/** + * GSObjCVersion() is deprecated ... use class_getVersion() + */ +GS_EXPORT int GSObjCVersion(Class cls); + +/** + * Quickly return autoreleased data storage area. + */ +GS_EXPORT void * +GSAutoreleasedBuffer(unsigned size); + +/** + *

Prints a message to fptr using the format string provided and any + * additional arguments. The format string is interpreted as by + * the NSString formatted initialisers, and understands the '%@' syntax + * for printing an object. + *

+ *

The data is written to the file pointer in the default CString + * encoding if possible, as a UTF8 string otherwise. + *

+ *

This function is recommended for printing general log messages. + * For debug messages use NSDebugLog() and friends. For error logging + * use NSLog(), and for warnings you might consider NSWarnLog(). + *

+ */ +GS_EXPORT BOOL +GSPrintf (FILE *fptr, NSString *format, ...); + + + +GS_EXPORT NSArray * +GSObjCAllSubclassesOfClass(Class cls); + +GS_EXPORT NSArray * +GSObjCDirectSubclassesOfClass(Class cls); + +/** Function to change the class of the specified instance to newClass. + * This handles memory debugging issues in GNUstep-base and also + * deals with class finalisation issues in a garbage collecting + * environment, so you should use this function rather than attempting + * to swizzle class pointers directly. + */ +GS_EXPORT void +GSClassSwizzle(id instance, Class newClass); + +#if !defined(GS_GNUSTEP_V) || (GS_GNUSTEP_V >= GS_API_ANY && GS_GNUSTEP_V < 011500) +//GS_API_VERSION(GS_API_ANY,011500) + +GS_EXPORT const char * +GSLastErrorStr(long error_id) GS_DEPRECATED_FUNC; + +#endif + + + +#ifndef GS_MAX_OBJECTS_FROM_STACK +/** + * The number of objects to try to get from varargs into an array on + * the stack ... if there are more than this, use the heap. + * NB. This MUST be a multiple of 2 + */ +#define GS_MAX_OBJECTS_FROM_STACK 128 +#endif + +/** + *

This is a macro designed to minimise the use of memory allocation and + * deallocation when you need to work with a vararg list of objects.
+ * The objects are unpacked from the vararg list into two 'C' arrays and + * then a code fragment you specify is able to make use of them before + * that 'C' array is destroyed. + *

+ *

The firstObject argument is the name of the formal parameter in your + * method or function which precedes the ', ...' denoting variable args. + *

+ *

The code argument is a piece of objective-c code to be executed to + * make use of the objects stored in the 'C' arrays.
+ * When this code is called the unsigned integer '__count' will contain the + * number of objects unpacked, the pointer '__objects' will point to + * the first object in each pair, and the pointer '__pairs' will point + * to an array containing the second halves of the pairs of objects + * whose first halves are in '__objects'.
+ * This lets you pack a list of the form 'key, value, key, value, ...' + * into an array of keys and an array of values. + *

+ */ +#define GS_USEIDPAIRLIST(firstObject, code...) ({\ + va_list __ap; \ + unsigned int __max = GS_MAX_OBJECTS_FROM_STACK; \ + unsigned int __count = 0; \ + id __buf[__max]; \ + id *__objects = __buf; \ + id *__pairs = &__objects[__max/2]; \ + id __obj = firstObject; \ + va_start(__ap, firstObject); \ + while (__obj != nil && __count < __max) \ + { \ + if ((__count % 2) == 0) \ + { \ + __objects[__count/2] = __obj; \ + } \ + else \ + { \ + __pairs[__count/2] = __obj; \ + } \ + __obj = va_arg(__ap, id); \ + if (++__count == __max) \ + { \ + while (__obj != nil) \ + { \ + __count++; \ + __obj = va_arg(__ap, id); \ + } \ + } \ + } \ + if ((__count % 2) == 1) \ + { \ + __pairs[__count/2] = nil; \ + __count++; \ + } \ + va_end(__ap); \ + if (__count > __max) \ + { \ + unsigned int __tmp; \ + __objects = (id*)malloc(__count*sizeof(id)); \ + __pairs = &__objects[__count/2]; \ + __objects[0] = firstObject; \ + va_start(__ap, firstObject); \ + for (__tmp = 1; __tmp < __count; __tmp++) \ + { \ + if ((__tmp % 2) == 0) \ + { \ + __objects[__tmp/2] = va_arg(__ap, id); \ + } \ + else \ + { \ + __pairs[__tmp/2] = va_arg(__ap, id); \ + } \ + } \ + va_end(__ap); \ + } \ + code; \ + if (__objects != __buf) free(__objects); \ +}) + +/** + *

This is a macro designed to minimise the use of memory allocation and + * deallocation when you need to work with a vararg list of objects.
+ * The objects are unpacked from the vararg list into a 'C' array and + * then a code fragment you specify is able to make use of them before + * that 'C' array is destroyed. + *

+ *

The firstObject argument is the name of the formal parameter in your + * method or function which precedes the ', ...' denoting variable args. + *

+ *

The code argument is a piece of objective-c code to be executed to + * make use of the objects stored in the 'C' array.
+ * When this code is called the unsigned integer '__count' will contain the + * number of objects unpacked, and the pointer '__objects' will point to + * the unpacked objects, ie. firstObject followed by the vararg arguments + * up to (but not including) the first nil. + *

+ */ +#define GS_USEIDLIST(firstObject, code...) ({\ + va_list __ap; \ + unsigned int __max = GS_MAX_OBJECTS_FROM_STACK; \ + unsigned int __count = 0; \ + id __buf[__max]; \ + id *__objects = __buf; \ + id __obj = firstObject; \ + va_start(__ap, firstObject); \ + while (__obj != nil && __count < __max) \ + { \ + __objects[__count] = __obj; \ + __obj = va_arg(__ap, id); \ + if (++__count == __max) \ + { \ + while (__obj != nil) \ + { \ + __count++; \ + __obj = va_arg(__ap, id); \ + } \ + } \ + } \ + va_end(__ap); \ + if (__count > __max) \ + { \ + unsigned int __tmp; \ + __objects = (id*)NSZoneMalloc(NSDefaultMallocZone(),__count*sizeof(id)); \ + va_start(__ap, firstObject); \ + __objects[0] = firstObject; \ + for (__tmp = 1; __tmp < __count; __tmp++) \ + { \ + __objects[__tmp] = va_arg(__ap, id); \ + } \ + va_end(__ap); \ + } \ + code; \ + if (__objects != __buf) NSZoneFree (NSDefaultMallocZone(),__objects); \ +}) + + +#ifdef __cplusplus +} +#endif + +#endif /* __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSVersionMacros.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSVersionMacros.h new file mode 100644 index 00000000000..e7cfb5ea880 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSVersionMacros.h @@ -0,0 +1,460 @@ +/* GSVersionMacros.h - macros for managing API versioning and visibility + Copyright (C) 2006-2014 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald + Date: Oct, October 2006 + + This file is part of GNUstep. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ +#define __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ + +/* By default we defined NO_GNUSTEP to 0 so that we will include extensions. + */ +#if !defined(NO_GNUSTEP) +# define NO_GNUSTEP 0 +#endif + +/* Check consistency of definitions for system compatibility. + */ +#if defined(STRICT_OPENSTEP) +# define GS_OPENSTEP_V 10000 +# undef NO_GNUSTEP +# define NO_GNUSTEP 1 +#elif defined(STRICT_MACOS_X) +# define GS_OPENSTEP_V 100600 +# undef NO_GNUSTEP +# define NO_GNUSTEP 1 +#endif + +/* Define the GS_OSX_ADJUST() macro to adjust OSX style version macros + * to GNUstep style version macros. + */ +#define GS_OSX_ADJUST(V) ((V) >= 10000 ? (V) : ((V)/100*10000 + (V)%100*10)) + +/* Define OSX compatibility version macros if necessary. + */ +#if !defined(MAC_OS_X_VERSION_10_0) +#define MAC_OS_X_VERSION_10_0 1000 +#define MAC_OS_X_VERSION_10_1 1010 +#define MAC_OS_X_VERSION_10_2 1020 +#define MAC_OS_X_VERSION_10_3 1030 +#define MAC_OS_X_VERSION_10_4 1040 +#define MAC_OS_X_VERSION_10_5 1050 +#define MAC_OS_X_VERSION_10_6 1060 +#define MAC_OS_X_VERSION_10_7 1070 +#define MAC_OS_X_VERSION_10_8 1080 +#define MAC_OS_X_VERSION_10_9 1090 +#define MAC_OS_X_VERSION_10_10 1100 +#define MAC_OS_X_VERSION_10_11 1110 +#define MAC_OS_X_VERSION_10_12 1120 +#define MAC_OS_X_VERSION_10_13 1130 +#define MAC_OS_X_VERSION_10_14 1140 +#endif /* MAC_OS_X_VERSION_10_0 */ + +/* Allow MAC_OS_X_VERSION_MAX_ALLOWED to be used in place of GS_OPENSTEP_V + * if GS_OPENSTEP_V is not defined. + */ +#ifndef GS_OPENSTEP_V +#ifdef MAC_OS_X_VERSION_MAX_ALLOWED +#define GS_OPENSTEP_V GS_OSX_ADJUST(MAC_OS_X_VERSION_MAX_ALLOWED) +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#endif /* GS_OPENSTEP_V */ + +/* + * NB. The version values below must be integers ... by convention these are + * made up of two digits each for major, minor and subminor version numbers + * (ie each is in the range 00 to 99 though a leading zero in the major + * number is not permitted). + * So for a MacOS-X 10.3.9 release the version number would be 100309 + * + * You may define GS_GNUSTEP_V or GS_OPENSTEP_V to ensure that your + * program only 'sees' the specified varsion of the API. + */ + +/** + *

Macro to check a defined GNUstep version number (GS_GNUSTEP_V) against + * the supplied arguments. Returns true if no GNUstep version is specified, + * or if ADD <= version < REM, where ADD is the version + * number at which a feature guarded by the macro was introduced and + * REM is the version number at which it was removed. + *

+ *

The version number arguments are six digit integers where the first + * 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 + * with a zero where necessary). However, for convenience you can also + * use the predefined constants ... + * GS_API_NONE, + * GS_API_LATEST, + *

+ *

Also see OS_API_VERSION + *

+ *

NB. If you are changing the API (eg adding a new feature) you need + * to control the visibility io the new header file code using
+ * #if GS_API_VERSION(ADD,GS_API_LATEST)
+ * where ADD is the version number of the next minor + * release after the most recent one.
+ * As a general principle you should not change the API with + * changing subminor version numbers ... as that tends to confuse + * people (though Apple has sometimes done it). + *

+ */ +#define GS_API_VERSION(ADD,REM) \ + (!defined(GS_GNUSTEP_V) || (GS_GNUSTEP_V >= ADD && GS_GNUSTEP_V < REM)) + +/** + *

Macro to check a defined OpenStep/OPENSTEP/MacOS-X version against the + * supplied arguments. Returns true if no version is specified, or if + * ADD <= version < REM, where ADD is the version + * number at which a feature guarded by the macro was introduced and + * REM is the version number at which it was removed. + *

+ *

The version number arguments are six digit integers where the first + * 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 + * with a zero where necessary). However, for convenience you can also + * use any of several predefined constants ... + * GS_API_NONE, + * GS_API_LATEST, + * GS_API_OSSPEC, + * GS_API_OPENSTEP, + * GS_API_MACOSX + *

+ *

Also see GS_API_VERSION + *

+ *

For OSX compatibility, this macro also supports the use of Apple's + * symbolic constants for version numbering. Their contants are currently + * four digit values (two digits for the major version, one for the minor, + * and one for the subminor). + *

+ *

The Apple compatibility version macros are currently: + * MAC_OS_X_VERSION_10_0, + * MAC_OS_X_VERSION_10_1, + * MAC_OS_X_VERSION_10_2, + * MAC_OS_X_VERSION_10_3, + * MAC_OS_X_VERSION_10_4, + * MAC_OS_X_VERSION_10_5, + * MAC_OS_X_VERSION_10_6, + * MAC_OS_X_VERSION_10_7, + * MAC_OS_X_VERSION_10_8 + * MAC_OS_X_VERSION_10_9 + *

+ */ +#define OS_API_VERSION(ADD,REM) \ + (!defined(GS_OPENSTEP_V) \ + || (GS_OPENSTEP_V>=GS_OSX_ADJUST(ADD) && GS_OPENSTEP_V + * eg.
+ * #if OS_API_VERSION + * (GS_API_NONE, GS_API_NONE)
+ * denotes code not present in OpenStep/OPENSTEP/MacOS-X + */ +#define GS_API_NONE 0 + +/** + * A constant to represent a feature which is still present in the latest + * version. This is the highest possible version number.
+ * eg.
+ * #if OS_API_VERSION + * (GS_API_MACOSX, GS_API_LATEST)
+ * denotes code present from the initial MacOS-X version onwards. + */ +#define GS_API_LATEST 999999 + +/** + * The version number of the initial OpenStep specification.
+ * eg.
+ * #if OS_API_VERSION + * (GS_API_OSSPEC, GS_API_LATEST)
+ * denotes code present from the OpenStep specification onwards. + */ +#define GS_API_OSSPEC 10000 + +/** + * The version number of the first OPENSTEP implementation.
+ * eg.
+ * #if OS_API_VERSION + * (GS_API_OPENSTEP, GS_API_LATEST)
+ * denotes code present from the initial OPENSTEP version onwards. + */ +#define GS_API_OPENSTEP 40000 + +/** + * The version number of the first MacOS-X implementation.
+ * eg.
+ * #if OS_API_VERSION + * (GS_API_MACOSX, GS_API_LATEST)
+ * denotes code present from the initial MacOS-X version onwards. + */ +#define GS_API_MACOSX 100000 + +/* Allow OSX code comparing MAC_OS_X_VERSION_MAX_ALLOWED with a specific + * version to see if that version is allowed, to always have it allowed + * on GNUstep. + */ +#ifndef MAC_OS_X_VERSION_MAX_ALLOWED +#define MAC_OS_X_VERSION_MAX_ALLOWED GS_API_LATEST +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ + + +#if defined(GNUSTEP_BASE_INTERNAL) +#include "GNUstepBase/GSConfig.h" +#else +#include "GSConfig.h" +#endif + + +#if defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__clang__) +# define GS_GCC_MINREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define GS_GCC_MINREQ(maj, min) 0 +#endif + +#if defined(__clang__) +# define GS_CLANG_MINREQ(maj, min) \ + ((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min)) +#else +# define GS_CLANG_MINREQ(maj, min) 0 +#endif + +/* Attribute definitions for attributes which may or may not be supported + * depending on the compiler being used. + * NB we currently expect gcc to be version 4 or later. + * + * The definition should be of the form GS_XXX_CONTEXT where XXX is the + * name of the attribute and CONTEXT is one of FUNC, METH, or IVAR + * depending on where the attribute can be applied. + */ + +#if defined(__clang__) || GS_GCC_MINREQ(3,1) +# define GS_DEPRECATED_FUNC __attribute__ ((deprecated)) +#else +# define GS_DEPRECATED_FUNC +#endif + +#define GS_UNUSED_ARG __attribute__((unused)) + +#define GS_UNUSED_FUNC __attribute__((unused)) + +// FIXME ... what version of gcc? +#if __clang__ +# define GS_UNUSED_IVAR __attribute__((unused)) +#else +# define GS_UNUSED_IVAR +#endif + + + +#ifndef __has_feature +#define __has_feature(x) 0 +#endif + +/* The following is for deciding whether private instance variables + * should be visible ... if we are building with a compiler which + * does not define __has_feature then we know we don't have non-fragile + * ivar support. + * In the header we bracket instance variable declarations in a + * '#if GS_EXPOSE(classname) ... #endif' sequence, so that the variables + * will not be visible to code which uses the library. + * In the source file we define EXPOSE_classname_IVARS to be 1 + * before including the header, so that the ivars are always available + * in the class source itsself + */ + +#if GS_MIXEDABI +# undef GS_NONFRAGILE +# define GS_NONFRAGILE 0 /* Mixed is treated as fragile */ +#else +# if (__has_feature(objc_nonfragile_abi)) +# if !GS_NONFRAGILE +# if defined(GNUSTEP_BASE_INTERNAL) +# error "You are building gnustep-base using the objc-nonfragile-abi but your gnustep-base was not configured to use it." +# endif +# endif +# else +# if GS_NONFRAGILE +# error "Your gnustep-base was configured for the objc-nonfragile-abi but you are not using it now." +# endif +# endif +#endif + +#define GS_EXPOSE(X) (!GS_NONFRAGILE || defined(EXPOSE_##X##_IVARS)) + +/* Static analyser macros: Provide annotations to help the analyser */ +#ifdef __clang__ +# define GS_NORETURN_METHOD __attribute__((__noreturn__)) +#else +# define GS_NORETURN_METHOD +#endif + +#ifndef NS_RETURNS_RETAINED +# if __has_feature(attribute_ns_returns_retained) +# define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) +# else +# define NS_RETURNS_RETAINED +# endif +#endif + +#ifndef NS_RETURNS_NOT_RETAINED +# if __has_feature(attribute_ns_returns_not_retained) +# define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) +# else +# define NS_RETURNS_NOT_RETAINED +# endif +#endif + +#ifndef NS_CONSUMED +# if __has_feature(attribute_ns_consumed) +# define NS_CONSUMED __attribute__((ns_consumed)) +# else +# define NS_CONSUMED +# endif +#endif + + +#ifndef NS_CONSUMES_SELF +# if __has_feature(attribute_ns_consumes_self) +# define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) +# else +# define NS_CONSUMES_SELF +# endif +#endif + +#if defined(__clang__) && defined(__OBJC__) +static inline void gs_consumed(id NS_CONSUMED o) GS_UNUSED_FUNC; +static inline void gs_consumed(id NS_CONSUMED GS_UNUSED_ARG o) { return; } +#define GS_CONSUMED(O) gs_consumed(O); +#else +#define GS_CONSUMED(O) +#endif + +/* Include the appropriate header for ObjC2 blocks support if it is in use. + * + * FIXME: "OBJC2RUNTIME" is set to "1" if the runtime supports the ObjC2 + * runtime API, which is unrelated to whether the compiler has blocks + * support or not. + */ +#if __has_feature(blocks) +# if OBJC2RUNTIME +# if defined(__APPLE__) +# include +# else +# include +# endif +# else +# include +# 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 + + + +#if defined(GNUSTEP_WITH_DLL) + +#if BUILD_libgnustep_base_DLL +# +# if defined(__MINGW__) + /* On Mingw, the compiler will export all symbols automatically, so + * __declspec(dllexport) is not needed. + */ +# define GS_EXPORT extern +# define GS_DECLARE +# else +# define GS_EXPORT __declspec(dllexport) +# define GS_DECLARE __declspec(dllexport) +# endif +#else +# define GS_EXPORT extern __declspec(dllimport) +# define GS_DECLARE __declspec(dllimport) +#endif + +#else /* GNUSTEP_WITH[OUT]_DLL */ + +# define GS_EXPORT extern +# define GS_DECLARE + +#endif + + +/* Attribute macros compatible with Apple. + */ + +#ifndef NS_FORMAT_ARGUMENT +#if defined(__clang__) || GS_GCC_MINREQ(4,2) +# define NS_FORMAT_ARGUMENT(A) __attribute__((format_arg(A))) +#else +# define NS_FORMAT_ARGUMENT(F,A) +#endif +#endif + +// FIXME ... what version of gcc? +#ifndef NS_FORMAT_FUNCTION +#if __clang__ +# define NS_FORMAT_FUNCTION(F,A) __attribute__((format(__NSString__, F, A))) +#else +# define NS_FORMAT_FUNCTION(F,A) +#endif +#endif + +#ifndef NS_REQUIRES_NIL_TERMINATION +#define NS_REQUIRES_NIL_TERMINATION __attribute__((sentinel)) +#endif + +// FIXME ... what exact version of clang and gcc? +#ifndef UNAVAILABLE_ATTRIBUTE +#if defined(__clang__) || GS_GCC_MINREQ(4,0) +# define UNAVAILABLE_ATTRIBUTE __attribute__((unavailable)) +#else +# define UNAVAILABLE_ATTRIBUTE +#endif +#endif + +/* Check if compiler supports @optional in protocols + */ +#if defined(__clang__) || GS_GCC_MINREQ(4,6) +# define GS_PROTOCOLS_HAVE_OPTIONAL 1 +#else +# define GS_PROTOCOLS_HAVE_OPTIONAL 0 +#endif + +/* Check if compiler supports declared properties + */ +#if defined(__clang__) || GS_GCC_MINREQ(4,6) +# define GS_HAS_DECLARED_PROPERTIES 1 +#else +# define GS_HAS_DECLARED_PROPERTIES 0 +#endif + +#endif /* __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSArray+GNUstepBase.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSArray+GNUstepBase.h new file mode 100644 index 00000000000..c9b595aa2f6 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSArray+GNUstepBase.h @@ -0,0 +1,78 @@ +/** Declaration of extension methods for base additions + + Copyright (C) 2003-2010 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald + and: Adam Fedor + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + +*/ + +#ifndef INCLUDED_NSArray_GNUstepBase_h +#define INCLUDED_NSArray_GNUstepBase_h + +#import "../GNUstepBase/GSVersionMacros.h" +#import "../Foundation/NSArray.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +#if OS_API_VERSION(GS_API_NONE,GS_API_LATEST) + +@interface NSArray (GNUstepBase) + +/**

Method for working with sorted arrays - use a binary chop + * to determine the insertion location for an object. If equal objects + * already exist in the array, they will be located immediately before + * the insertion position. + *

+ *

The comparator function takes two items as arguments, the first is the + * item to be added, the second is the item already in the array. + * The function should return NSOrderedAscending if the item to be + * added is 'less than' the item in the array, NSOrderedDescending + * if it is greater, and NSOrderedSame if it is equal. + *

+ */ +- (NSUInteger) insertionPosition: (id)item + usingFunction: (NSComparisonResult (*)(id, id, void *))sorter + context: (void *)context; + +/*

Method for working with sorted arrays - use a binary chop + * to determine the insertion location for an object. If equal objects + * already exist in the array, they will be located immediately before + * the insertion position. + *

+ *

The selector identifies a method returning NSOrderedAscending if + * the receiver is 'less than' the argument, and NSOrderedDescending if + * it is greate. + *

+ */ +- (NSUInteger) insertionPosition: (id)item + usingSelector: (SEL)comp; +@end + +#endif /* OS_API_VERSION */ + +#if defined(__cplusplus) +} +#endif + +#endif /* INCLUDED_NSArray_GNUstepBase_h */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSMutableString+GNUstepBase.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSMutableString+GNUstepBase.h new file mode 100644 index 00000000000..b3f71909c0c --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSMutableString+GNUstepBase.h @@ -0,0 +1,57 @@ +/** Declaration of extension methods for base additions + + Copyright (C) 2003-2010 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald + and: Adam Fedor + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + +*/ + +#ifndef INCLUDED_NSMutableString_GNUstepBase_h +#define INCLUDED_NSMutableString_GNUstepBase_h + +#import "GSVersionMacros.h" +#import "../Foundation/NSString.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +#if OS_API_VERSION(GS_API_NONE,GS_API_LATEST) + +@interface NSMutableString (GNUstepBase) +- (void) deleteSuffix: (NSString*)suffix; +- (void) deletePrefix: (NSString*)prefix; +- (NSString*) immutableProxy; +- (void) replaceString: (NSString*)replace + withString: (NSString*)by; +- (void) trimLeadSpaces; +- (void) trimTailSpaces; +- (void) trimSpaces; +@end + +#endif /* OS_API_VERSION */ + +#if defined(__cplusplus) +} +#endif + +#endif /* INCLUDED_NSMutableString_GNUstepBase_h */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSNumber+GNUstepBase.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSNumber+GNUstepBase.h new file mode 100644 index 00000000000..1bed065303b --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSNumber+GNUstepBase.h @@ -0,0 +1,56 @@ +/** Declaration of extension methods for base additions + + Copyright (C) 2003-2010 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald + and: Adam Fedor + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + +*/ + +#ifndef INCLUDED_NSNumber_GNUstepBase_h +#define INCLUDED_NSNumber_GNUstepBase_h + +#import "GSVersionMacros.h" +#import "../Foundation/NSValue.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +#if OS_API_VERSION(GS_API_NONE,GS_API_LATEST) + +@interface NSNumber(GNUstepBase) +/** + * Parses string as a double, int, or unsigned + * int depending on what characters are present. Uses + * atof and atoi which don't report errors, so be + * careful if the string might contain an invalid value. + */ ++ (NSValue*) valueFromString: (NSString *)string; +@end + +#endif /* OS_API_VERSION */ + +#if defined(__cplusplus) +} +#endif + +#endif /* INCLUDED_NSNumber_GNUstepBase_h */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSObject+GNUstepBase.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSObject+GNUstepBase.h new file mode 100644 index 00000000000..d3b2574341b --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSObject+GNUstepBase.h @@ -0,0 +1,242 @@ +/** Declaration of extension methods for base additions + + Copyright (C) 2003-2010 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald + and: Adam Fedor + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + +*/ + +#ifndef INCLUDED_NSObject_GNUstepBase_h +#define INCLUDED_NSObject_GNUstepBase_h + +#import "GSVersionMacros.h" +#import "../Foundation/NSObject.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +#if OS_API_VERSION(GS_API_NONE,GS_API_LATEST) + +@class NSHashTable; + +@interface NSObject (GNUstepBase) + +/** + WARNING: The -compare: method for NSObject is deprecated + due to subclasses declaring the same selector with + conflicting signatures. + Comparision of arbitrary objects is not just meaningless + but also dangerous as most concrete implementations + expect comparable objects as arguments often accessing + instance variables directly. + This method will be removed in a future release. +*/ +- (NSComparisonResult) compare: (id)anObject; + +/** For backward compatibility only ... use class_isMetaClass() on the + * class of the receiver instead. + */ +- (BOOL) isInstance; + +/** DEPRECATED ... do not use. + * Transmutes the receiver into an immutable version of the same object + * and returns the result.
+ * If the receiver is not a mutable object or cannot be simply transmuted, + * then this method either returns the receiver unchanged or, + * if the force flag is set to YES, returns an autoreleased copy of the + * receiver.
+ * Mutable classes should override this default implementation.
+ * This method is used in methods which are declared to return immutable + * objects (eg. an NSArray), but which create and build mutable ones + * internally. + */ +- (id) makeImmutableCopyOnFail: (BOOL)force; + +/** Transmutes the receiver into an immutable version of the same object. + * Returns YES if the receiver has become immutable, NO otherwise.
+ * The default implementation returns NO.
+ * Mutable classes which have an immutable counterpart they can efficiently + * change into, should override to transmute themselves and return YES.
+ * Immutable classes should override this to simply return YES with no + * further action.
+ * This method is used in methods which are declared to return immutable + * objects (eg. an NSArray), but which create and build mutable ones + * internally. + */ +- (BOOL) makeImmutable; + +/** + * Message sent when an implementation wants to explicitly exclude a method + * (but cannot due to compiler constraint), and wants to make sure it is not + * called by mistake. Default implementation raises an exception at runtime. + */ +- (id) notImplemented: (SEL)aSel GS_NORETURN_METHOD; + +/** + * Message sent when an implementation wants to explicitly require a subclass + * to implement a method (but cannot at compile time since there is no + * abstract keyword in Objective-C). Default implementation + * raises an exception at runtime to alert developer that he/she forgot to + * override a method. + */ +- (id) subclassResponsibility: (SEL)aSel GS_NORETURN_METHOD; + +/** + * Message sent when an implementation wants to explicitly exclude a method + * (but cannot due to compiler constraint) and forbid that subclasses + * implement it. Default implementation raises an exception at runtime. If a + * subclass does implement this method, however, the superclass's + * implementation will not be called, so this is not a perfect mechanism. + */ +- (id) shouldNotImplement: (SEL)aSel GS_NORETURN_METHOD; + +@end + +/** This is an informal protocol ... classes may implement the method to + * report how much memory is used by the instance and any objects it acts + * as a container for. + */ +@interface NSObject(MemoryFootprint) +/* This method returns the memory usage of the receiver, excluding any + * objects already present in the exclude table.
+ * The argument is a hash table configured to hold non-retained pointer + * objects and is used to inform the receiver that its size should not + * be counted again if it's already in the table.
+ * The NSObject implementation returns zero if the receiver is in the + * table, but otherwise adds itself to the table and returns its memory + * footprint (the sum of all of its instance variables, but not any + * memory pointed to by those variables).
+ * Subclasses should override this method by calling the superclass + * implementation, and either return the result (if it was zero) or + * return that value plus the sizes of any memory owned by the receiver + * (eg found by calling the same method on objects pointed to by the + * receiver's instance variables). + */ +- (NSUInteger) sizeInBytesExcluding: (NSHashTable*)exclude; +@end + +/** This is an informal protocol ... classes may implement the method and + * register themselves to have it called on process exit. + */ +@interface NSObject(GSAtExit) +/** This method is called on exit for any class which implements it and which + * has called +registerAtExit to register it to be called.
+ * The order in which methods for different classes is called is the reverse + * of the order in which the classes were registered, but it's best to assume + * the method can not depend on any other class being in a usable state + * at the point when the method is called (rather like +load).
+ * Typical use would be to release memory occupied by class data structures + * so that memory usage analysis software will not think the memory has + * been leaked. + */ ++ (void) atExit; +@end + +/** Category for methods handling leaked memory cleanup on exit of process + * (for use when debugging memory leaks).
+ * You enable this by calling the +setShouldCleanUp: method (done implicitly + * by gnustep-base if the GNUSTEP_SHOULD_CLEAN_UP environment variable is + * set to YES).
+ * Your class then has two options for performing cleanup when the process + * ends: + *

1. Use the +leak: method to register objects which are simply to be + * retained until the process ends, and then either ignored or released + * depending on the cleanup setting in force. This mechanism is simple + * and should be sufficient for many classes. + *

+ *

2. Implement a +atExit method to be run when the process ends and, + * within your +initialize implementation, call +shouldCleanUp to determine + * whether cleanup should be done, and if it returns YES then call + * +registerAtExit to have your +atExit method called when the process + * terminates. + *

+ *

The order in which 'leaked' objects are released and +atExit methods + * are called on process exist is the reverse of the order in which they + * werse set up suing this API. + *

+ */ +@interface NSObject(GSCleanup) + + +/** This method simply retains its argument so that it will never be + * deallocated during normal operation, but keeps track of it so that + * it is released during process exit if cleanup is enabled.
+ * Returns its argument. + */ ++ (id) NS_RETURNS_RETAINED leak: (id)anObject; + +/** This method retains the object at *anAddress so that it will never be + * deallocated during normal operation, but keeps track of the address + * so that the object is released and the address is zeroed during process + * exit if cleanup is enabled.
+ * Returns the object at *anAddress. + */ ++ (id) NS_RETURNS_RETAINED leakAt: (id*)anAddress; + +/** Sets the receiver to have its +atExit method called at the point when + * the process terminates.
+ * Returns YES on success and NO on failure (if the class does not implement + * the method or if it is already registered to call it).
+ * Implemented as a call to +registerAtExit: with the selector for the +atExit + * method as its argument. + */ ++ (BOOL) registerAtExit; + +/** Sets the receiver to have the specified method called at the point when + * the process terminates.
+ * Returns YES on success and NO on failure (if the class does not implement + * the method ir if it is already registered to call it). + */ ++ (BOOL) registerAtExit: (SEL)aSelector; + +/** Specifies the default cleanup behavior on process exit ... the value + * returned by the NSObject implementation of the +shouldClanUp method.
+ * Calling this method with a YES argument implicitly calls the +enableAtExit + * method as well.
+ * The GNUstep Base library calls this method with the value obtained from + * the GNUSTEP_SHOULD_CLEAN_UP environment variable when NSObject is + * initialised. + */ ++ (void) setShouldCleanUp: (BOOL)aFlag; + +/** Returns a flag indicating whether the receiver should clean up + * its data structures etc at process exit.
+ * The NSObject implementation returns the value set by the +setShouldCleanUp: + * method but subclasses may override this. + */ ++ (BOOL) shouldCleanUp; + +@end + +/* Macro to take an autoreleased object and either make it immutable or + * create an autoreleased copy of the original. + */ +#define GS_IMMUTABLE(O) ([O makeImmutable] == YES ? O : AUTORELEASE([O copy])) + +#endif /* OS_API_VERSION */ + +#if defined(__cplusplus) +} +#endif + +#endif /* INCLUDED_NSObject_GNUstepBase_h */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSString+GNUstepBase.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSString+GNUstepBase.h new file mode 100644 index 00000000000..48633cde5d7 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSString+GNUstepBase.h @@ -0,0 +1,105 @@ +/** Declaration of extension methods for base additions + + Copyright (C) 2003-2010 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald + and: Adam Fedor + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + +*/ + +#ifndef INCLUDED_NSString_GNUstepBase_h +#define INCLUDED_NSString_GNUstepBase_h + +#import "GSVersionMacros.h" +#import "../Foundation/NSString.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +#if OS_API_VERSION(GS_API_NONE,GS_API_LATEST) + +/** + * Provides some additional (non-standard) utility methods. + */ +@interface NSString (GNUstepBase) + +/** + * Alternate way to invoke stringWithFormat if you have or wish + * to build an explicit va_list structure. + */ ++ (id) stringWithFormat: (NSString*)format + arguments: (va_list)argList NS_FORMAT_FUNCTION(1,0); + +/** + * Returns a string formed by removing the prefix string from the + * receiver. Raises an exception if the prefix is not present. + */ +- (NSString*) stringByDeletingPrefix: (NSString*)prefix; + +/** + * Returns a string formed by removing the suffix string from the + * receiver. Raises an exception if the suffix is not present. + */ +- (NSString*) stringByDeletingSuffix: (NSString*)suffix; + +/** + * Returns a string formed by removing leading white space from the + * receiver. + */ +- (NSString*) stringByTrimmingLeadSpaces; + +/** + * Returns a string formed by removing trailing white space from the + * receiver. + */ +- (NSString*) stringByTrimmingTailSpaces; + +/** + * Returns a string formed by removing both leading and trailing + * white space from the receiver. + */ +- (NSString*) stringByTrimmingSpaces; + +/** + * Returns a string in which any (and all) occurrences of + * replace in the receiver have been replaced with by. + * Returns the receiver if replace + * does not occur within the receiver. NB. an empty string is + * not considered to exist within the receiver. + */ +- (NSString*) stringByReplacingString: (NSString*)replace + withString: (NSString*)by; + +/** + * An obsolete name for -substringWithRange: ... deprecated. + */ +- (NSString*) substringFromRange: (NSRange)aRange; + +@end + +#endif /* OS_API_VERSION */ + +#if defined(__cplusplus) +} +#endif + +#endif /* INCLUDED_NSString_GNUstepBase_h */ +