2002-10-09 09:54:43 +00:00
|
|
|
/** Interface to ObjC runtime for GNUStep
|
2000-10-31 11:05:23 +00:00
|
|
|
Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc.
|
1995-07-01 19:01:11 +00:00
|
|
|
|
1996-04-17 20:17:45 +00:00
|
|
|
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
1995-07-01 19:01:11 +00:00
|
|
|
Date: 1995
|
2012-03-20 16:28:59 +00:00
|
|
|
|
1996-05-12 00:56:10 +00:00
|
|
|
This file is part of the GNUstep Base Library.
|
1995-03-23 03:51:32 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-09-14 11:36:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1995-03-23 03:51:32 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-08 10:38:33 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
2012-03-20 16:28:59 +00:00
|
|
|
|
1995-03-23 03:51:32 +00:00
|
|
|
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
|
2019-12-09 23:36:00 +00:00
|
|
|
Lesser General Public License for more details.
|
2012-03-20 16:28:59 +00:00
|
|
|
|
2007-09-14 11:36:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1995-03-23 03:51:32 +00:00
|
|
|
License along with this library; if not, write to the Free
|
2006-10-31 07:05:46 +00:00
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2019-12-09 23:36:00 +00:00
|
|
|
Boston, MA 02110 USA.
|
2002-10-09 09:54:43 +00:00
|
|
|
|
|
|
|
AutogsdocSource: NSObjCRuntime.m
|
|
|
|
AutogsdocSource: NSLog.m
|
|
|
|
|
2012-03-20 16:28:59 +00:00
|
|
|
*/
|
1995-03-23 03:51:32 +00:00
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
#ifndef __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE
|
2010-02-20 18:32:07 +00:00
|
|
|
|
2012-04-06 12:01:34 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
#ifndef __STDC_LIMIT_MACROS
|
|
|
|
#define __STDC_LIMIT_MACROS 1
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
2008-02-26 08:54:58 +00:00
|
|
|
#import <GNUstepBase/GSConfig.h>
|
2015-10-05 18:43:44 +00:00
|
|
|
#import <GNUstepBase/GNUstep.h>
|
2012-09-19 13:31:09 +00:00
|
|
|
#import <GNUstepBase/GSBlocks.h>
|
2008-11-13 10:09:50 +00:00
|
|
|
|
2013-10-29 09:14:45 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <float.h>
|
|
|
|
|
2013-11-29 17:42:44 +00:00
|
|
|
/* PA HP-UX kludge. */
|
|
|
|
#if defined(__hppa__) && defined(__hpux__) && !defined(PRIuPTR)
|
|
|
|
#define PRIuPTR "lu"
|
|
|
|
#endif
|
2016-02-22 21:04:18 +00:00
|
|
|
|
2013-11-29 17:42:44 +00:00
|
|
|
/* IRIX kludge. */
|
|
|
|
#if defined(__sgi)
|
|
|
|
/* IRIX 6.5 <inttypes.h> 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 <inttypes.h>, which always has "lld" here, but the
|
|
|
|
arguments are uint64_t, int64_t, which are unsigned long, long for
|
|
|
|
64-bit in <sgidefs.h>. */
|
|
|
|
#if (_MIPS_SZLONG == 64)
|
|
|
|
#define PRId64 "ld"
|
|
|
|
#define PRIu64 "lu"
|
|
|
|
#endif
|
|
|
|
/* This doesn't match <inttypes.h>, which has "u" here, but the arguments
|
|
|
|
are uintptr_t, which is always unsigned long. */
|
|
|
|
#define PRIuPTR "lu"
|
|
|
|
#endif
|
2016-02-22 21:04:18 +00:00
|
|
|
|
2013-11-29 17:42:44 +00:00
|
|
|
/* 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
|
|
|
|
|
|
|
|
|
2008-11-13 10:09:50 +00:00
|
|
|
/* These typedefs must be in place before GSObjCRuntime.h is imported.
|
|
|
|
*/
|
2009-02-23 20:42:32 +00:00
|
|
|
|
2010-01-21 22:41:52 +00:00
|
|
|
#if !defined(NSINTEGER_DEFINED)
|
2009-02-22 20:01:53 +00:00
|
|
|
typedef intptr_t NSInteger;
|
|
|
|
typedef uintptr_t NSUInteger;
|
2011-04-21 11:06:18 +00:00
|
|
|
# define NSIntegerMax INTPTR_MAX
|
|
|
|
# define NSIntegerMin INTPTR_MIN
|
|
|
|
# define NSUIntegerMax UINTPTR_MAX
|
2010-01-21 22:41:52 +00:00
|
|
|
#endif /* !defined(NSINTEGER_DEFINED) */
|
2010-02-15 17:51:07 +00:00
|
|
|
|
2010-01-21 22:41:52 +00:00
|
|
|
#if !defined(CGFLOAT_DEFINED)
|
2009-02-23 20:42:32 +00:00
|
|
|
#if GS_SIZEOF_VOIDP == 8
|
|
|
|
#define CGFLOAT_IS_DBL 1
|
|
|
|
typedef double CGFloat;
|
2011-04-26 23:43:05 +00:00
|
|
|
#define CGFLOAT_MIN DBL_MIN
|
|
|
|
#define CGFLOAT_MAX DBL_MAX
|
2009-02-22 20:01:53 +00:00
|
|
|
#else
|
2009-02-23 20:42:32 +00:00
|
|
|
typedef float CGFloat;
|
2011-04-26 23:43:05 +00:00
|
|
|
#define CGFLOAT_MIN FLT_MIN
|
|
|
|
#define CGFLOAT_MAX FLT_MAX
|
2009-02-22 20:01:53 +00:00
|
|
|
#endif
|
2010-01-21 22:41:52 +00:00
|
|
|
#endif /* !defined(CGFLOAT_DEFINED) */
|
2008-11-13 10:09:50 +00:00
|
|
|
|
2009-02-16 23:04:30 +00:00
|
|
|
#define NSINTEGER_DEFINED 1
|
2010-01-21 22:41:52 +00:00
|
|
|
#define CGFLOAT_DEFINED 1
|
2011-07-31 15:31:39 +00:00
|
|
|
#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
|
|
|
|
|
2009-02-16 23:04:30 +00:00
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-10-05 18:43:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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__)
|
|
|
|
|
2016-02-12 09:00:10 +00:00
|
|
|
/*
|
|
|
|
* 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")
|
2016-02-22 21:04:18 +00:00
|
|
|
#else
|
2016-02-12 09:00:10 +00:00
|
|
|
# define NS_ASSUME_NONNULL_BEGIN
|
|
|
|
# define NS_ASSUME_NONNULL_END
|
|
|
|
#endif
|
|
|
|
|
2016-02-22 21:04:18 +00:00
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
|
2016-07-12 14:30:21 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
|
2015-10-05 18:43:44 +00:00
|
|
|
/** Bitfield used to specify options to control enumeration over collections.
|
|
|
|
*/
|
|
|
|
typedef NS_OPTIONS(NSUInteger, NSEnumerationOptions)
|
2009-12-27 16:49:52 +00:00
|
|
|
{
|
2011-02-14 10:57:57 +00:00
|
|
|
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.
|
2010-02-18 08:45:00 +00:00
|
|
|
*/
|
2011-02-14 10:57:57 +00:00
|
|
|
|
|
|
|
NSEnumerationReverse = (1UL << 1) /** Specifies that the enumeration should
|
|
|
|
* happen in the opposite of the natural order of the collection.
|
2010-02-18 08:45:00 +00:00
|
|
|
*/
|
2009-12-27 16:49:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-10-05 18:43:44 +00:00
|
|
|
/** Bitfield used to specify options to control the sorting of collections.
|
|
|
|
*/
|
|
|
|
typedef NS_OPTIONS(NSUInteger, NSSortOptions)
|
2012-09-19 13:31:09 +00:00
|
|
|
{
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-03-10 14:53:51 +00:00
|
|
|
#import <GNUstepBase/GSObjCRuntime.h>
|
2010-03-05 09:30:18 +00:00
|
|
|
|
2013-07-01 07:08:55 +00:00
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST)
|
2008-06-06 13:57:06 +00:00
|
|
|
GS_EXPORT NSString *NSStringFromProtocol(Protocol *aProtocol);
|
|
|
|
GS_EXPORT Protocol *NSProtocolFromString(NSString *aProtocolName);
|
|
|
|
#endif
|
|
|
|
GS_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);
|
2000-10-31 11:05:23 +00:00
|
|
|
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,
|
2010-03-01 05:43:08 +00:00
|
|
|
NSUInteger *sizep, NSUInteger *alignp);
|
1995-03-23 03:51:32 +00:00
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
|
1997-01-06 22:05:50 +00:00
|
|
|
/* Logging */
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* 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
|
2005-12-05 07:03:21 +00:00
|
|
|
* like this and assign a pointer to it to _NSLog_printf_handler.
|
2004-06-22 22:27:39 +00:00
|
|
|
*/
|
1997-01-06 22:05:50 +00:00
|
|
|
typedef void NSLog_printf_handler (NSString* message);
|
2000-10-31 11:05:23 +00:00
|
|
|
GS_EXPORT NSLog_printf_handler *_NSLog_printf_handler;
|
2002-10-09 09:54:43 +00:00
|
|
|
GS_EXPORT int _NSLogDescriptor;
|
|
|
|
@class NSRecursiveLock;
|
2002-11-09 06:45:31 +00:00
|
|
|
GS_EXPORT NSRecursiveLock *GSLogLock(void);
|
2002-10-09 09:54:43 +00:00
|
|
|
#endif
|
1997-01-06 22:05:50 +00:00
|
|
|
|
2013-07-02 15:53:46 +00:00
|
|
|
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);
|
1997-01-06 22:05:50 +00:00
|
|
|
|
1995-03-23 03:51:32 +00:00
|
|
|
#ifndef YES
|
|
|
|
#define YES 1
|
2001-01-03 15:40:22 +00:00
|
|
|
#endif
|
1995-03-23 03:51:32 +00:00
|
|
|
#ifndef NO
|
|
|
|
#define NO 0
|
2001-01-03 15:40:22 +00:00
|
|
|
#endif
|
1995-03-23 03:51:32 +00:00
|
|
|
#ifndef nil
|
|
|
|
#define nil 0
|
2001-01-03 15:40:22 +00:00
|
|
|
#endif
|
1995-03-23 03:51:32 +00:00
|
|
|
|
2011-12-15 09:09:59 +00:00
|
|
|
/**
|
|
|
|
* Contains values <code>NSOrderedSame</code>, <code>NSOrderedAscending</code>
|
|
|
|
* <code>NSOrderedDescending</code>, for left hand side equals, less than, or
|
|
|
|
* greater than right hand side.
|
|
|
|
*/
|
2017-03-27 09:00:35 +00:00
|
|
|
typedef NS_ENUM(NSInteger, NSComparisonResult)
|
2011-12-15 09:09:59 +00:00
|
|
|
{
|
2017-03-27 09:00:35 +00:00
|
|
|
NSOrderedAscending = (NSInteger)-1, NSOrderedSame, NSOrderedDescending
|
|
|
|
};
|
2011-12-15 09:09:59 +00:00
|
|
|
|
|
|
|
enum {NSNotFound = NSIntegerMax};
|
|
|
|
|
2012-09-19 13:31:09 +00:00
|
|
|
DEFINE_BLOCK_TYPE(NSComparator, NSComparisonResult, id, id);
|
2012-03-20 16:28:59 +00:00
|
|
|
|
2016-02-26 12:52:31 +00:00
|
|
|
/**
|
|
|
|
* Declare the foundation export macro as an alias to GS_EXPORT
|
|
|
|
*/
|
|
|
|
#define FOUNDATION_EXPORT GS_EXPORT
|
|
|
|
|
2020-03-26 13:29:55 +00:00
|
|
|
/**
|
|
|
|
* Declare NSExceptionName
|
|
|
|
*/
|
|
|
|
typedef NSString* NSExceptionName;
|
2020-03-27 04:48:07 +00:00
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
2020-03-26 13:29:55 +00:00
|
|
|
|
2017-06-15 17:39:05 +00:00
|
|
|
/**
|
|
|
|
* Declare Apple availability macros for compatibility purposes as no-ops.
|
|
|
|
*/
|
2017-08-04 02:41:59 +00:00
|
|
|
#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
|
2017-06-15 17:39:05 +00:00
|
|
|
|
2017-06-20 23:25:49 +00:00
|
|
|
/* 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
|
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
#endif /* __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */
|