diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/objc-obj-c++-shared | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/objc-obj-c++-shared')
14 files changed, 1647 insertions, 0 deletions
diff --git a/gcc/testsuite/objc-obj-c++-shared/Object1-implementation.h b/gcc/testsuite/objc-obj-c++-shared/Object1-implementation.h new file mode 100644 index 000000000..0dc36b10c --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/Object1-implementation.h @@ -0,0 +1,169 @@ +/* Compatibility code between APIs and ABIs for the objc test suite. + Copyright (C) 2010, 2011 Free Software Foundation, Inc. + Contributed by Iain Sandoe + +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 +<http://www.gnu.org/licenses/>. */ + +/* + * Implementation of a compatibility layer for the ObjC* test-suite. + * + * Four cases: + * GNU + * Uses the 'old' Object with API and ABI = 0. + * Compatibility methods are added. + * NeXT pre-Darwin9 + * Uses the 'old' Object with API and ABI = 0. + * NeXT Darwin >= 9 with no implementation of ABI 2 + * Uses API 2 and ABI 0 for m32, uses the 'old' Object' + * Uses API 2 for m64 but only compile tests can be expected to work. + * NeXT Darwin >= 9 with __OBJC2__ + * Uses API 2 and ABI 0 for m32, uses the 'old' Object' + * Uses API 2 and ABI 2 - the libobjc implementation of Object is very + * basic, and we add a category to expand this for test-suite use. + */ + +#ifndef _OBJC_OBJECT1_IMPLEMENTATION_H_ +#define _OBJC_OBJECT1_IMPLEMENTATION_H_ + +#include "Object1.h" + +#ifndef __NEXT_RUNTIME__ + +/* Save us from repeating this. */ +@implementation Object (TEST_SUITE_ADDITIONS) ++ initialize +{ + return self; +} +@end + +#else + +/* For NeXT pre-Darwin 9 or m32 we need do nothing. */ + +# if NEXT_OBJC_ABI_VERSION >= 2 + +/* Pick up the API=2 header. */ +# include <objc/runtime.h> + +# ifndef __OBJC2__ + +/* On a Darwin system >= 9 when there is no __OBJC2__ compiler, the testcases + will not link. So we provide a dummy Object for this purpose. */ + +@implementation Object + ++ (Class) class +{ + return self; +} + +- (BOOL)isEqual: (id)anObject +{ + return self == anObject; +} + +@end +# endif /* __OBJC2__ */ + +/* In any case, since the library does not provide a complete (enough) + implementation we need to provide the additions. */ + +@implementation Object (TEST_SUITE_ADDITIONS) + ++ initialize +{ + return self; +} + +- init +{ + return self; +} + +- (Class) class +{ + return isa; +} + ++ (Class) superclass +{ + return class_getSuperclass(object_getClass(self)); +} + ++ new +{ + return [[self alloc] init]; +} + ++ free +{ + return nil; +} + +- free +{ + return object_dispose(self); +} + ++ alloc +{ + return class_createInstance (self, 0); +} + +- (Class) superclass { + return class_getSuperclass([self class]); +} + +- (const char *) name { + return class_getName([self class]); +} + +-(BOOL)conformsTo:(Protocol *)protocol { + Class cls; + for (cls = [self class]; cls; cls = [cls superclass]) + { + if (class_conformsToProtocol(cls, protocol)) + return YES; + } + return NO; +} + +#ifdef __cplusplus +extern "C" { +#endif +extern int printf (const char *, ...); +extern void abort (void); +#ifdef __cplusplus +} +#endif + +/* This is a helper to catch cases where we need to add more functionality + to our test-suite category - more informative than fail with 'does not + respond to forward:' */ +- forward: (SEL)sel : (marg_list)args +{ + const char * onam = object_getClassName (self); + const char * snam = sel_getName (sel); + printf ("%s: tried to forward: %s\n", onam, snam); + abort (); +} +@end + +# endif /* NEXT_OBJC_ABI_VERSION >= 2 */ +# endif /* __NEXT_RUNTIME__ */ +#endif /* _OBJC_OBJECT1_IMPLEMENTATION_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/Object1.h b/gcc/testsuite/objc-obj-c++-shared/Object1.h new file mode 100644 index 000000000..293d0468f --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/Object1.h @@ -0,0 +1,175 @@ +/* Compatibility code between APIs and ABIs for the objc test suite. + Copyright (C) 2010, 2011 Free Software Foundation, Inc. + Contributed by Iain Sandoe + +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 +<http://www.gnu.org/licenses/>. */ + +/* + * Compatibility header. + * + * Four cases: + * GNU + * Uses the 'old' Object with API and ABI = 0. + * Compatibility methods are added. + * NeXT pre-Darwin9 + * Uses the 'old' Object with API and ABI = 0. + * NeXT Darwin >= 9 with no implementation of ABI 2 + * Uses API 2 and ABI 0 for m32, uses the 'old' Object' + * Uses API 2 for m64 but only compile tests can be expected to work. + * NeXT Darwin >= 9 with __OBJC2__ + * Uses API 2 and ABI 0 for m32, uses the 'old' Object' + * Uses API 2 and ABI 2 - the libobjc implementation of Object is very + * basic, and we add a category to expand this for test-suite use. + */ +#ifndef _OBJC_OBJECT1_H_ +#define _OBJC_OBJECT1_H_ + +#ifndef __NEXT_RUNTIME__ +/* Case 1 = GNU. */ +# include <objc/Object.h> +/* NeXT requires a +initialize (or forward:) method, and it makes testcases more + readable if the conditional code can be reduced, so we add one to the GNU tests + too. This saves us from having to introduce it every time. */ +@interface Object (TEST_SUITE_ADDITIONS) ++ initialize; +@end + +#else /* NeXT */ + +# include "next-abi.h" +# if !defined(NEXT_OBJC_ABI_VERSION) || (NEXT_OBJC_ABI_VERSION < 2) +/* Cases 2, Case 3/m32 and 4/m32 are handled as default. */ +# include <objc/Object.h> +# else +# include <objc/objc.h> + +/* This is a cut-down Object with only the methods currently required + by the testsuite declared. The implementation is provided in + Object1-implementation.h +*/ + +/* The m64 libobjc implementation of Object provides only the 'class' and + isEqual: methods. + + We add the others required as a test-suite category. + + Please leave the unimplemented methods as comments - so that they can + be inserted as required by future tests. */ + +@interface Object +{ + Class isa; +} ++ (Class) class; +- (BOOL)isEqual: (id)anObject; +@end + +/* Dummy definition. */ +typedef void * marg_list; + +@interface Object (TEST_SUITE_ADDITIONS) + ++ initialize; +- init; + ++ new; ++ free; +- free; ++ alloc; +//- copy; +//+ allocFromZone:(void *)zone; +//- copyFromZone:(void *)zone; +//- (void *)zone; + +- (Class) class; ++ (Class) superclass; +//+ (const char *) name; +//- superclass; +- (const char *) name; + +//- self; +//- (unsigned int) hash; + +/* Testing inheritance relationships */ + +//- (BOOL) isKindOf: aClassObject; +//- (BOOL) isMemberOf: aClassObject; +//- (BOOL) isKindOfClassNamed: (const char *)aClassName; +//- (BOOL) isMemberOfClassNamed: (const char *)aClassName; + +/* Testing class functionality */ + +//+ (BOOL) instancesRespondTo:(SEL)aSelector; +//- (BOOL) respondsTo:(SEL)aSelector; + +/* Testing protocol conformance */ + +- (BOOL) conformsTo: (Protocol *)aProtocolObject; +//+ (BOOL) conformsTo: (Protocol *)aProtocolObject; + +/* Obtaining method descriptors from protocols */ + +//- (struct objc_method_description *) descriptionForMethod:(SEL)aSel; +//+ (struct objc_method_description *) descriptionForInstanceMethod:(SEL)aSel; + +/* Obtaining method handles */ + +//- (IMP) methodFor:(SEL)aSelector; +//+ (IMP) instanceMethodFor:(SEL)aSelector; + +/* Sending messages determined at run time */ + +//- perform:(SEL)aSelector; +//- perform:(SEL)aSelector with:anObject; +//- perform:(SEL)aSelector with:object1 with:object2; + +/* Posing */ + +//+ poseAs: aClassObject; + +/* Enforcing intentions */ + +//- subclassResponsibility:(SEL)aSelector; +//- notImplemented:(SEL)aSelector; + +/* Error handling */ + +//- doesNotRecognize:(SEL)aSelector; +//- error:(const char *)aString, ...; + +/* Debugging */ + +//- (void) printForDebugger:(void *)stream; + +/* Archiving */ + +//- awake; +//- write:(void *)stream; +//- read:(void *)stream; +//+ (int) version; +//+ setVersion: (int) aVersion; + +/* Forwarding */ + +- forward: (SEL)sel : (marg_list)args; +//- performv: (SEL)sel : (marg_list)args; + +@end + +# endif /* NeXT case 3 & 4 m64 */ +# endif /* NEXT */ +#endif /* _OBJC_OBJECT1_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/Object1.m b/gcc/testsuite/objc-obj-c++-shared/Object1.m new file mode 100644 index 000000000..d5fe4c086 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/Object1.m @@ -0,0 +1,4 @@ +/* This will generate compatibility code for the test-suite provided as a + category on Object. +*/ +#include "Object1-implementation.h" diff --git a/gcc/testsuite/objc-obj-c++-shared/Object1.mm b/gcc/testsuite/objc-obj-c++-shared/Object1.mm new file mode 100644 index 000000000..04fdd0562 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/Object1.mm @@ -0,0 +1,4 @@ +/* This will generate compatibility code for the test-suite provided as a + category on Object. +*/ +#import "Object1-implementation.h" diff --git a/gcc/testsuite/objc-obj-c++-shared/Protocol1.h b/gcc/testsuite/objc-obj-c++-shared/Protocol1.h new file mode 100644 index 000000000..d375ac0d5 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/Protocol1.h @@ -0,0 +1,52 @@ +/* + * Temporary work-around to avoid the need for method attributes in + * the NeXT Runtime Protocol header. + */ +#ifndef _OBJC_PROTOCOL1_H_ +#define _OBJC_PROTOCOL1_H_ + +# ifndef __NEXT_RUNTIME__ +# include <objc/Protocol.h> +# else +# include "next-abi.h" +# ifndef NEXT_OBJC_USE_NEW_INTERFACE +/* We are on a NeXT version without method __attributes__ */ +# import <objc/Protocol.h> +# else +/* We make our own interface without the deprecation messages + * This is essentially <objc/Protocol.h> without the OBJC2 + * flags. + * + */ +# ifndef _OBJC_PROTOCOL_H_ +# define _OBJC_PROTOCOL_H_ +# import "Object1.h" + +@interface Protocol : Object +{ +@private + char *protocol_name ; + struct objc_protocol_list *protocol_list ; + struct objc_method_description_list *instance_methods ; + struct objc_method_description_list *class_methods ; +} + +/* Obtaining attributes intrinsic to the protocol */ +#if (NEXT_OBJC_ABI_VERSION==0) +- (const char *)name ; /* Not avail in v2, deprecated in prior */ +/* Testing protocol conformance */ +- (BOOL) conformsTo: (Protocol *)aProtocolObject ; /* Not avail in v2 */ +#endif + +/* Looking up information specific to a protocol */ +/* Deprecated, but available */ + +- (struct objc_method_description *) descriptionForInstanceMethod:(SEL)aSel ; +- (struct objc_method_description *) descriptionForClassMethod:(SEL)aSel ; + +@end + +# endif /* __NEXT_RUNTIME__ */ +# endif /* _OBJC_PROTOCOL_H_ */ +# endif /* NEXT_OBJC_ABI_VERSION */ +#endif /* _OBJC_PROTOCOL1_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/next-abi.h b/gcc/testsuite/objc-obj-c++-shared/next-abi.h new file mode 100644 index 000000000..0ffa0fcba --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/next-abi.h @@ -0,0 +1,64 @@ +/* Check which version of the API and ABI are appropriate for the target. + Copyright (C) 2010, 2011 Free Software Foundation, Inc. + + Contributed by Iain Sandoe <iains@gcc.gnu.org> + +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 +<http://www.gnu.org/licenses/>. */ + +#ifndef _OBJC_NEXT_ABI_H_ +#define _OBJC_NEXT_ABI_H_ +/* Produce a define that allows us to figure out what facilities are + available for this gcc and OS combination. +*/ + +/* By default we do nothing - therefore ifdef NEXT_OBJC_USE_NEW_INTERFACE + * is reliable for detecting versions of the target that require either + * API=2, or both API & ABI = 2 (m64 code). + * + * This applies for versions of OSX >= 10.5 (darwin9). + * + * A compiler capable of producing ObjC V2 ABI should define __OBJC2__ +*/ + +#undef NEXT_OBJC_ABI_VERSION +#undef NEXT_OBJC_USE_NEW_INTERFACE + +#ifdef __NEXT_RUNTIME__ +# if (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 || __OBJC2__) + /* We have to use an updated interface for 32bit NeXT to avoid + * 'deprecated' warnings. + * For 64bit NeXT the ABI is different (and the interfaces 'deprecated' + * for 32bit have been removed). + */ +# define NEXT_OBJC_USE_NEW_INTERFACE 1 +# if __OBJC2__ || __LP64__ + /* We have OBJC v2 ABI compiler, + (or, at least, the available NeXT runtime requires one) */ +# define NEXT_OBJC_ABI_VERSION 2 +# else + /* We leave it open to define ABI 1 if and when we implement those + * extensions. + */ +# define NEXT_OBJC_ABI_VERSION 0 +# endif +# else + /* Pre-OSX 10.5 all is ABI 0. */ +# define NEXT_OBJC_ABI_VERSION 0 +# endif /* MAC_OS_X_VERSION_MIN_REQUIRED > 10.5 or OBJC2 */ +#endif /* __NEXT_RUNTIME__ */ + +#endif /* _OBJC_NEXT_ABI_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/next-mapping.h b/gcc/testsuite/objc-obj-c++-shared/next-mapping.h new file mode 100644 index 000000000..d2ae8e9e6 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/next-mapping.h @@ -0,0 +1,109 @@ +/* Compatibility header between runtimes and APIs. + Copyright (C) 2010, 2011 Free Software Foundation, Inc. + + Original Authors: Ziemowit Laski <zlaski@apple.com> + David Ayers <d.ayers@inode.at> + + re-work for ObjC2 by Iain Sandoe <iains@gcc.gnu.org> + +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 +<http://www.gnu.org/licenses/>. */ + +#ifndef _OBJC_NEXT_MAPPING_H_ +#define _OBJC_NEXT_MAPPING_H_ + +/* This file provides a two-way mapping of API names for the original + GNU & NeXT APIs. + + It is being expanded to provide mapping (where possible) between between the + older API and API-2. +*/ + +#include "objc-test-suite-types.h" + +#ifndef __NEXT_RUNTIME__ + +# define CLASSFIELD class_pointer +# define CLASSPTRFIELD(x) (x)->class_pointer +# define SUPERCLASS superClass +# define OBJC_GETCLASS objc_get_class + +# ifdef __objc_api_INCLUDE_GNU +# define class_createInstance(C, S) class_create_instance(C) +# endif +# define method_get_types(M) (M)->method_types + +#else /* NeXT */ + +/* Include next-abi.h to set NEXT_OBJC_USE_NEW_INTERFACE etc.*/ +# include "next-abi.h" + +# ifdef NEXT_OBJC_USE_NEW_INTERFACE + /* API=2. */ +# include <objc/runtime.h> +# else + /* API=0. */ +# include <objc/objc-class.h> +# endif + +# define CLASSPTRFIELD(x) (x)->isa +# define SUPERCLASS superclass +# define OBJC_GETCLASS objc_getClass + +# define objc_get_class(C) objc_getClass(C) +# define objc_get_meta_class(C) objc_getMetaClass(C) +# define class_get_class_method(C, S) class_getClassMethod(C, S) +# define class_get_instance_method(C, S) class_getInstanceMethod(C, S) +# define sel_get_name(S) sel_getName(S) +# define class_create_instance(C) class_createInstance(C, 0) +# define class_get_class_name(C) object_getClassName(C) +# define objc_lookup_class(N) objc_lookUpClass(N) + +# ifdef NEXT_OBJC_USE_NEW_INTERFACE + +# define object_class_name(O) (object_getClassName(O)) +# define object_get_class(O) (object_getClass((id)O)) +# define object_get_super_class(O) class_get_super_class(object_get_class(O)) +# define object_is_class(O) class_is_meta_class(object_get_class(O)) +# define object_is_meta_class(O) (object_is_class(O) && class_is_meta_class(O) \ + && class_is_meta_class(object_get_class(O))) + +# define method_get_imp(M) (method_getImplementation((Method)M)) +# define method_get_types(M) (method_getTypeEncoding((Method)M)) + +# define class_get_super_class(C) (class_getSuperclass((Class)C)) +# define class_is_meta_class(C) (class_isMetaClass((Class)C) ? YES: NO) +# define class_is_class(C) (class_is_meta_class(C) == NO) + +# else /* OLD API */ + +# define object_class_name(O) (O->name) +# define object_get_super_class(O) class_get_super_class(*(struct objc_class **)O) +# define object_get_class(O) (*(struct objc_class **)O) +# define object_is_class(O) class_is_meta_class(*(struct objc_class **)O) +# define object_is_meta_class(O) (class_is_meta_class(O) && class_is_meta_class(*(struct objc_class **)O)) + +# define method_get_imp(M) (((Method)M)->method_imp) +# define method_get_types(M) (((Method)M)->method_types) + +# define class_get_super_class(C) (((struct objc_class *)C)->super_class) +# define class_is_meta_class(C) (CLS_GETINFO((struct objc_class *)C, CLS_META)? YES: NO) +# define class_is_class(C) (CLS_GETINFO((struct objc_class *)C, CLS_CLASS)? YES: NO) + +# endif /* NEXT_OBJC_USE_NEW_INTERFACE */ + +# endif /*__NEXT_RUNTIME__ */ +#endif /* _OBJC_NEXT_MAPPING_H_ */
\ No newline at end of file diff --git a/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class-impl.h b/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class-impl.h new file mode 100644 index 000000000..0068b4a2a --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class-impl.h @@ -0,0 +1,61 @@ +/* A small NSConstantString implementation for use with the NeXT runtime. + Copyright (C) 2011 Free Software Foundation, Inc. + + Contributed by Iain Sandoe <iains@gcc.gnu.org> + +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 +<http://www.gnu.org/licenses/>. */ + +#ifdef __NEXT_RUNTIME__ + +#include "nsconstantstring-class.h" +#include <string.h> + +/* On full-fledged Mac OS X systems, NSConstantString is provided + as part of the Foundation framework. However, on bare Darwin systems, + Foundation is not included, and hence there is no NSConstantString + implementation to link against. + + This code is derived from the GNU runtime's NXConstantString implementation. +*/ + +@implementation NSConstantString +/* NeXT requires this or forward: */ ++initialize { return self; } + +-(const char *) cString +{ + return (c_string); +} + +-(unsigned int) length +{ + return (len); +} +@end + +TNS_STRING_REF_T _NSConstantStringClassReference; + +/* The NSConstantString metaclass will need to be initialized before we can + send messages to strings. */ + +void objc_constant_string_init (void) __attribute__((constructor)); +void objc_constant_string_init (void) { + memcpy (&_NSConstantStringClassReference, + objc_getClass ("NSConstantString"), + sizeof (_NSConstantStringClassReference)); +} +#endif diff --git a/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class-impl.m b/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class-impl.m new file mode 100644 index 000000000..cd9c7dd8f --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class-impl.m @@ -0,0 +1,3 @@ +/* Allow code to be shared between the FEs but avoid issues with + C++-only flags. */ +#include "nsconstantstring-class-impl.h" diff --git a/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class-impl.mm b/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class-impl.mm new file mode 100644 index 000000000..cd9c7dd8f --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class-impl.mm @@ -0,0 +1,3 @@ +/* Allow code to be shared between the FEs but avoid issues with + C++-only flags. */ +#include "nsconstantstring-class-impl.h" diff --git a/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class.h b/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class.h new file mode 100644 index 000000000..485e39e6f --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/nsconstantstring-class.h @@ -0,0 +1,51 @@ +/* A small NSConstantString implementation for use with the NeXT runtime. + Copyright (C) 2011 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 +<http://www.gnu.org/licenses/>. */ + +#ifndef _test_suite_nsconstantstring_class_h_ +#define _test_suite_nsconstantstring_class_h_ +#ifdef __NEXT_RUNTIME__ + +/* On full-fledged Mac OS X systems, NSConstantString is provided + as part of the Foundation framework. However, on bare Darwin systems, + Foundation is not included, and hence there is no NSConstantString + implementation to link against. + + This code is derived from the GNU runtime's NXConstantString implementation. +*/ + +#include "objc-test-suite-types.h" + +extern TNS_STRING_REF_T _NSConstantStringClassReference; + +@interface NSConstantString +{ + Class isa; + char *c_string; + unsigned int len; +} + ++ (id) initialize; + +- (const char *) cString; +- (unsigned int) length; + +@end + +#endif /* __NEXT_RUNTIME__ */ +#endif /* _test_suite_nsconstantstring_class_h_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/objc-test-suite-next-encode-assist-impl.h b/gcc/testsuite/objc-obj-c++-shared/objc-test-suite-next-encode-assist-impl.h new file mode 100644 index 000000000..b98188033 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/objc-test-suite-next-encode-assist-impl.h @@ -0,0 +1,785 @@ +#ifndef _OBJC_TEST_SUITE_NEXT_ENCODE_ASSIST_IMPL_H_ +#define _OBJC_TEST_SUITE_NEXT_ENCODE_ASSIST_IMPL_H_ + +#ifdef __NEXT_RUNTIME__ + +/* Determine which API to use. */ +#include "next-abi.h" +#ifdef NEXT_OBJC_USE_NEW_INTERFACE +#include <objc/runtime.h> +typedef void * PMETH; +#else +#include <objc/objc-runtime.h> +typedef struct objc_method * PMETH; +#endif + +/* ---- */ + +#undef MAX +#undef MIN +#undef ROUND + +#ifdef __cplusplus +# define MAX(X, Y) ((X > Y) ? X : Y) +# define MIN(X, Y) ((X < Y) ? X : Y) +# define ROUND(V, A) (A * ((V + A - 1) / A)) +#else +# define MAX(X, Y) \ + ({ typeof (X) __x = (X), __y = (Y); \ + (__x > __y ? __x : __y); }) +# define MIN(X, Y) \ + ({ typeof (X) __x = (X), __y = (Y); \ + (__x < __y ? __x : __y); }) +# define ROUND(V, A) \ + ({ typeof (V) __v = (V); typeof (A) __a = (A); \ + __a * ((__v+__a - 1)/__a); }) +#endif + +#define BITS_PER_UNIT __CHAR_BIT__ +typedef struct{ char a; } __small_struct; +#define STRUCTURE_SIZE_BOUNDARY (BITS_PER_UNIT * sizeof (__small_struct)) + +/* + return the size of an object specified by type +*/ + +int +objc_sizeof_type (const char *type) +{ + /* Skip the variable name if any */ + if (*type == '"') + { + for (type++; *type++ != '"';) + /* do nothing */; + } + + switch (*type) { + case _C_ID: + return sizeof (id); + break; + + case _C_CLASS: + return sizeof (Class); + break; + + case _C_SEL: + return sizeof (SEL); + break; + + case _C_CHR: + return sizeof (char); + break; + + case _C_UCHR: + return sizeof (unsigned char); + break; + + case _C_SHT: + return sizeof (short); + break; + + case _C_USHT: + return sizeof (unsigned short); + break; + + case _C_INT: + return sizeof (int); + break; + + case _C_UINT: + return sizeof (unsigned int); + break; + + case _C_LNG: + return sizeof (long); + break; + + case _C_ULNG: + return sizeof (unsigned long); + break; + + case _C_LNG_LNG: + return sizeof (long long); + break; + + case _C_ULNG_LNG: + return sizeof (unsigned long long); + break; + + case _C_FLT: + return sizeof (float); + break; + + case _C_DBL: + return sizeof (double); + break; + + case _C_PTR: + case _C_ATOM: + case _C_CHARPTR: + return sizeof (char *); + break; + + case _C_ARY_B: + { + int len = atoi (type + 1); + while (isdigit ((unsigned char)*++type)) + ; + return len * objc_aligned_size (type); + } + break; + + case _C_BFLD: + { + /* The NeXT encoding of bitfields is _still_: b 'size' */ + int size = atoi (type + 1); + /* Return an upper bound on byte size */ + return (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT; + } + + case _C_STRUCT_B: + { + struct objc_struct_layout layout; + unsigned int size; + + objc_layout_structure (type, &layout); + while (objc_layout_structure_next_member (&layout)) + /* do nothing */ ; + objc_layout_finish_structure (&layout, &size, NULL); + + return size; + } + + case _C_UNION_B: + { + int max_size = 0; + while (*type != _C_UNION_E && *type++ != '=') + /* do nothing */; + while (*type != _C_UNION_E) + { + /* Skip the variable name if any */ + if (*type == '"') + { + for (type++; *type++ != '"';) + /* do nothing */; + } + max_size = MAX (max_size, objc_sizeof_type (type)); + type = objc_skip_typespec (type); + } + return max_size; + } + } + return 0; /* error */ +} + + +/* + Return the alignment of an object specified by type +*/ + +int +objc_alignof_type (const char *type) +{ + /* Skip the variable name if any */ + if (*type == '"') + { + for (type++; *type++ != '"';) + /* do nothing */; + } + switch (*type) { + case _C_ID: + return __alignof__ (id); + break; + + case _C_CLASS: + return __alignof__ (Class); + break; + + case _C_SEL: + return __alignof__ (SEL); + break; + + case _C_CHR: + return __alignof__ (char); + break; + + case _C_UCHR: + return __alignof__ (unsigned char); + break; + + case _C_SHT: + return __alignof__ (short); + break; + + case _C_USHT: + return __alignof__ (unsigned short); + break; + + case _C_INT: + case _C_BFLD: /* This is for the NeXT only */ + return __alignof__ (int); + break; + + case _C_UINT: + return __alignof__ (unsigned int); + break; + + case _C_LNG: + return __alignof__ (long); + break; + + case _C_ULNG: + return __alignof__ (unsigned long); + break; + + case _C_LNG_LNG: + return __alignof__ (long long); + break; + + case _C_ULNG_LNG: + return __alignof__ (unsigned long long); + break; + + case _C_FLT: + return __alignof__ (float); + break; + + case _C_DBL: + return __alignof__ (double); + break; + + case _C_PTR: + case _C_ATOM: + case _C_CHARPTR: + return __alignof__ (char *); + break; + + case _C_ARY_B: + while (isdigit ((unsigned char)*++type)) + /* do nothing */; + return objc_alignof_type (type); + + case _C_STRUCT_B: + { + struct objc_struct_layout layout; + unsigned int align; + + objc_layout_structure (type, &layout); + while (objc_layout_structure_next_member (&layout)) + /* do nothing */; + objc_layout_finish_structure (&layout, NULL, &align); + + return align; + } + + case _C_UNION_B: + { + int maxalign = 0; + while (*type != _C_UNION_E && *type++ != '=') + /* do nothing */; + while (*type != _C_UNION_E) + { + /* Skip the variable name if any */ + if (*type == '"') + { + for (type++; *type++ != '"';) + /* do nothing */; + } + maxalign = MAX (maxalign, objc_alignof_type (type)); + type = objc_skip_typespec (type); + } + return maxalign; + } + } + return 0; /* error */ +} + +/* + The aligned size if the size rounded up to the nearest alignment. +*/ + +int +objc_aligned_size (const char *type) +{ + int size, align; + + /* Skip the variable name */ + if (*type == '"') + { + for (type++; *type++ != '"';) + /* do nothing */; + } + + size = objc_sizeof_type (type); + align = objc_alignof_type (type); + + return ROUND (size, align); +} + +/* + The size rounded up to the nearest integral of the wordsize, taken + to be the size of a void *. +*/ + +int +objc_promoted_size (const char *type) +{ + int size, wordsize; + + /* Skip the variable name */ + if (*type == '"') + { + for (type++; *type++ != '"';) + /* do nothing */; + } + + size = objc_sizeof_type (type); + wordsize = sizeof (void *); + + return ROUND (size, wordsize); +} + +/* + Skip type qualifiers. These may eventually precede typespecs + occurring in method prototype encodings. +*/ + +const char * +objc_skip_type_qualifiers (const char *type) +{ + while (*type == _C_CONST + || *type == _C_IN + || *type == _C_INOUT + || *type == _C_OUT + || *type == _C_BYCOPY + || *type == _C_BYREF + || *type == _C_ONEWAY + || *type == _C_GCINVISIBLE) + { + type += 1; + } + return type; +} + +/* + Skip one typespec element. If the typespec is prepended by type + qualifiers, these are skipped as well. +*/ + +const char * +objc_skip_typespec (const char *type) +{ + /* Skip the variable name if any */ + if (*type == '"') + { + for (type++; *type++ != '"';) + /* do nothing */; + } + + type = objc_skip_type_qualifiers (type); + + switch (*type) { + + case _C_ID: + /* An id may be annotated by the actual type if it is known + with the @"ClassName" syntax */ + + if (*++type != '"') + return type; + else + { + while (*++type != '"') + /* do nothing */; + return type + 1; + } + + /* The following are one character type codes */ + case _C_CLASS: + case _C_SEL: + case _C_CHR: + case _C_UCHR: + case _C_CHARPTR: + case _C_ATOM: + case _C_SHT: + case _C_USHT: + case _C_INT: + case _C_UINT: + case _C_LNG: + case _C_ULNG: + case _C_LNG_LNG: + case _C_ULNG_LNG: + case _C_FLT: + case _C_DBL: + case _C_VOID: + case _C_UNDEF: + return ++type; + break; + + case _C_ARY_B: + /* skip digits, typespec and closing ']' */ + + while (isdigit ((unsigned char)*++type)) + ; + type = objc_skip_typespec (type); + if (*type == _C_ARY_E) + return ++type; + else + break; /* error */ + + case _C_BFLD: + /* The NeXT encoding for bitfields is _still_: b 'size' */ + while (isdigit ((unsigned char)*++type)) + ; /* skip type and size */ + return type; + + case _C_STRUCT_B: + /* skip name, and elements until closing '}' */ + + while (*type != _C_STRUCT_E && *type++ != '=') + ; + while (*type != _C_STRUCT_E) + { + type = objc_skip_typespec (type); + } + return ++type; + + case _C_UNION_B: + /* skip name, and elements until closing ')' */ + + while (*type != _C_UNION_E && *type++ != '=') + ; + while (*type != _C_UNION_E) + { + type = objc_skip_typespec (type); + } + return ++type; + + case _C_PTR: + /* Just skip the following typespec */ + + return objc_skip_typespec (++type); + } + return 0; /* error */ +} + +/* + Skip an offset as part of a method encoding. This is prepended by a + '+' if the argument is passed in registers. +*/ +const char * +objc_skip_offset (const char *type) +{ + if (*type == '+') + type++; + while (isdigit ((unsigned char) *++type)) + ; + return type; +} + +/* + Skip an argument specification of a method encoding. +*/ +const char * +objc_skip_argspec (const char *type) +{ + type = objc_skip_typespec (type); + type = objc_skip_offset (type); + return type; +} +/* + Return the number of arguments that the method MTH expects. + Note that all methods need two implicit arguments `self' and + `_cmd'. +*/ +int +method_get_number_of_arguments (PMETH mth) +{ + int i = 0; +#ifdef NEXT_OBJC_USE_NEW_INTERFACE + const char *type = method_getTypeEncoding((Method)mth); +#else + const char *type = mth->method_types; +#endif + while (*type) + { + type = objc_skip_argspec (type); + i += 1; + } + return i - 1; +} + +/* + Return the size of the argument block needed on the stack to invoke + the method MTH. This may be zero, if all arguments are passed in + registers. +*/ + +int +method_get_sizeof_arguments (PMETH mth) +{ +#ifdef NEXT_OBJC_USE_NEW_INTERFACE + const char *type = objc_skip_typespec (method_getTypeEncoding((Method)mth)); +#else + const char *type = objc_skip_typespec (mth->method_types); +#endif + return atoi (type); +} + +/* + Return a pointer to the next argument of ARGFRAME. type points to + the last argument. Typical use of this look like: + + { + char *datum, *type; + for (datum = method_get_first_argument (method, argframe, &type); + datum; datum = method_get_next_argument (argframe, &type)) + { + unsigned flags = objc_get_type_qualifiers (type); + type = objc_skip_type_qualifiers (type); + if (*type != _C_PTR) + [portal encodeData: datum ofType: type]; + else + { + if ((flags & _F_IN) == _F_IN) + [portal encodeData: *(char **) datum ofType: ++type]; + } + } + } +*/ + +char * +method_get_next_argument (arglist_t argframe, const char **type) +{ + const char *t = objc_skip_argspec (*type); + + if (*t == '\0') + return 0; + + *type = t; + t = objc_skip_typespec (t); + + if (*t == '+') + return argframe->arg_regs + atoi (++t); + else + return argframe->arg_ptr + atoi (t); +} + +/* + Return a pointer to the value of the first argument of the method + described in M with the given argumentframe ARGFRAME. The type + is returned in TYPE. type must be passed to successive calls of + method_get_next_argument. +*/ +char * +method_get_first_argument (PMETH m, + arglist_t argframe, + const char **type) +{ +#ifdef NEXT_OBJC_USE_NEW_INTERFACE + *type = method_getTypeEncoding((Method)m); +#else + *type = m->method_types; +#endif + + return method_get_next_argument (argframe, type); +} + +/* + Return a pointer to the ARGth argument of the method + M from the frame ARGFRAME. The type of the argument + is returned in the value-result argument TYPE +*/ + +char * +method_get_nth_argument (PMETH m, + arglist_t argframe, int arg, + const char **type) +{ +#ifdef NEXT_OBJC_USE_NEW_INTERFACE + const char *t = objc_skip_argspec (method_getTypeEncoding((Method)m)); +#else + const char *t = objc_skip_argspec (m->method_types); +#endif + + if (arg > method_get_number_of_arguments (m)) + return 0; + + while (arg--) + t = objc_skip_argspec (t); + + *type = t; + t = objc_skip_typespec (t); + + if (*t == '+') + return argframe->arg_regs + atoi (++t); + else + return argframe->arg_ptr + atoi (t); +} + +unsigned +objc_get_type_qualifiers (const char *type) +{ + unsigned res = 0; + BOOL flag = YES; + + while (flag) + switch (*type++) + { + case _C_CONST: res |= _F_CONST; break; + case _C_IN: res |= _F_IN; break; + case _C_INOUT: res |= _F_INOUT; break; + case _C_OUT: res |= _F_OUT; break; + case _C_BYCOPY: res |= _F_BYCOPY; break; + case _C_BYREF: res |= _F_BYREF; break; + case _C_ONEWAY: res |= _F_ONEWAY; break; + case _C_GCINVISIBLE: res |= _F_GCINVISIBLE; break; + default: flag = NO; + } + + return res; +} + + +/* The following three functions can be used to determine how a + structure is laid out by the compiler. For example: + + struct objc_struct_layout layout; + int i; + + objc_layout_structure (type, &layout); + while (objc_layout_structure_next_member (&layout)) + { + int position, align; + const char *type; + + objc_layout_structure_get_info (&layout, &position, &align, &type); + printf ("element %d has offset %d, alignment %d\n", + i++, position, align); + } + + These functions are used by objc_sizeof_type and objc_alignof_type + functions to compute the size and alignment of structures. The + previous method of computing the size and alignment of a structure + was not working on some architectures, particulary on AIX, and in + the presence of bitfields inside the structure. */ +void +objc_layout_structure (const char *type, + struct objc_struct_layout *layout) +{ + const char *ntype; + + layout->original_type = ++type; + + /* Skip "<name>=" if any. Avoid embedded structures and unions. */ + ntype = type; + while (*ntype != _C_STRUCT_E && *ntype != _C_STRUCT_B && *ntype != _C_UNION_B + && *ntype++ != '=') + /* do nothing */; + + /* If there's a "<name>=", ntype - 1 points to '='; skip the the name */ + if (*(ntype - 1) == '=') + type = ntype; + + layout->type = type; + layout->prev_type = NULL; + layout->record_size = 0; + layout->record_align = MAX (BITS_PER_UNIT, STRUCTURE_SIZE_BOUNDARY); +} + +BOOL +objc_layout_structure_next_member (struct objc_struct_layout *layout) +{ + register int desired_align = 0; + + /* The current type without the type qualifiers */ + const char *type; + + /* Add the size of the previous field to the size of the record. */ + if (layout->prev_type) + { + type = objc_skip_type_qualifiers (layout->prev_type); + + if (*type != _C_BFLD) + layout->record_size += objc_sizeof_type (type) * BITS_PER_UNIT; + else + layout->record_size += atoi (++type); + } + + if (*layout->type == _C_STRUCT_E) + return NO; + + /* Skip the variable name if any */ + if (*layout->type == '"') + { + for (layout->type++; *layout->type++ != '"';) + /* do nothing */; + } + + type = objc_skip_type_qualifiers (layout->type); + + desired_align = objc_alignof_type (type) * BITS_PER_UNIT; + + /* Record must have at least as much alignment as any field. + Otherwise, the alignment of the field within the record + is meaningless. */ + layout->record_align = MAX (layout->record_align, desired_align); + + if (*type == _C_BFLD) + { + int bfld_size = atoi (++type); + int int_align = __alignof__ (int) * BITS_PER_UNIT; + /* If this bitfield would traverse a word alignment boundary, push it out + to that boundary instead. */ + if (layout->record_size % int_align + && (layout->record_size / int_align + < (layout->record_size + bfld_size - 1) / int_align)) + layout->record_size = ROUND (layout->record_size, int_align); + } + else if (layout->record_size % desired_align != 0) + { + /* We need to skip space before this field. + Bump the cumulative size to multiple of field alignment. */ + layout->record_size = ROUND (layout->record_size, desired_align); + } + + /* Jump to the next field in record. */ + + layout->prev_type = layout->type; + layout->type = objc_skip_typespec (layout->type); /* skip component */ + + return YES; +} + + +void objc_layout_finish_structure (struct objc_struct_layout *layout, + unsigned int *size, + unsigned int *align) +{ + if (layout->type && *layout->type == _C_STRUCT_E) + { + /* Round the size up to be a multiple of the required alignment */ + layout->record_size = ROUND (layout->record_size, layout->record_align); + layout->type = NULL; + } + if (size) + *size = layout->record_size / BITS_PER_UNIT; + if (align) + *align = layout->record_align / BITS_PER_UNIT; +} + + +void objc_layout_structure_get_info (struct objc_struct_layout *layout, + unsigned int *offset, + unsigned int *align, + const char **type) +{ + if (offset) + *offset = layout->record_size / BITS_PER_UNIT; + if (align) + *align = layout->record_align / BITS_PER_UNIT; + if (type) + *type = layout->prev_type; +} + +#endif /* __NEXT_RUNTIME__ */ +#endif /* _OBJC_TEST_SUITE_NEXT_ENCODE_ASSIST_IMPL_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/objc-test-suite-next-encode-assist.h b/gcc/testsuite/objc-obj-c++-shared/objc-test-suite-next-encode-assist.h new file mode 100644 index 000000000..af02b278a --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/objc-test-suite-next-encode-assist.h @@ -0,0 +1,87 @@ +#ifndef _OBJC_TEST_SUITE_NEXT_ENCODE_ASSIST_H_ +#define _OBJC_TEST_SUITE_NEXT_ENCODE_ASSIST_H_ + +#ifdef __NEXT_RUNTIME__ + +#include "next-abi.h" +#ifdef NEXT_OBJC_USE_NEW_INTERFACE +#include <objc/runtime.h> +typedef void * PMETH; +#else +#include <objc/objc-runtime.h> +typedef struct objc_method * PMETH; + +/* Missing from old NeXT objc headers... */ +#define _C_LNG_LNG 'q' +#define _C_ULNG_LNG 'Q' +#define _C_ATOM '%' +#define _C_BOOL 'B' + +#endif + +/* The NeXT headers do not define NULL. */ +#ifndef NULL +#define NULL 0 +#endif + +#define _C_CONST 'r' +#define _C_IN 'n' +#define _C_INOUT 'N' +#define _C_OUT 'o' +#define _C_BYCOPY 'O' +#define _C_BYREF 'R' +#define _C_ONEWAY 'V' +#define _C_GCINVISIBLE '!' + +#define _F_CONST 0x01 +#define _F_IN 0x01 +#define _F_OUT 0x02 +#define _F_INOUT 0x03 +#define _F_BYCOPY 0x04 +#define _F_BYREF 0x08 +#define _F_ONEWAY 0x10 +#define _F_GCINVISIBLE 0x20 + +/* The NeXT runtimes do not include these functions (at least not through + any public API). They are required for the objc/execute/bf-* and bycopy-3. */ + +struct objc_struct_layout +{ + const char *original_type; + const char *type; + const char *prev_type; + unsigned int record_size; + unsigned int record_align; +}; + +typedef union arglist { + char *arg_ptr; + char arg_regs[sizeof (char*)]; +} *arglist_t; /* argument frame */ + +void objc_layout_structure_get_info (struct objc_struct_layout *,unsigned int *, + unsigned int *, const char **); +void objc_layout_structure (const char *, struct objc_struct_layout *); +BOOL objc_layout_structure_next_member (struct objc_struct_layout *); +void objc_layout_finish_structure (struct objc_struct_layout *, unsigned int *, + unsigned int *); + +int objc_sizeof_type (const char *); +int objc_alignof_type (const char *); +int objc_aligned_size (const char *); +int objc_promoted_size (const char *); + +unsigned objc_get_type_qualifiers (const char *); +const char *objc_skip_type_qualifiers (const char *); +const char *objc_skip_typespec (const char *); +const char *objc_skip_offset (const char *); +const char *objc_skip_argspec (const char *); + +int method_get_number_of_arguments (PMETH); +int method_get_sizeof_arguments (PMETH); +char *method_get_next_argument (arglist_t , const char **); +char *method_get_first_argument (PMETH, arglist_t, const char **); +char *method_get_nth_argument (PMETH, arglist_t, int, const char **); + +#endif /* __NEXT_RUNTIME__ */ +#endif /* _OBJC_TEST_SUITE_NEXT_ENCODE_ASSIST_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/objc-test-suite-types.h b/gcc/testsuite/objc-obj-c++-shared/objc-test-suite-types.h new file mode 100644 index 000000000..ab502d467 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/objc-test-suite-types.h @@ -0,0 +1,80 @@ +/* Define test-suite types to minimize conditional test-case source. + Copyright (C) 2011 Free Software Foundation, Inc. + Contributed by Iain Sandoe + +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 +<http://www.gnu.org/licenses/>. */ + +#ifndef _OBJC_TEST_SUITE_TYPES_H_ +#define _OBJC_TEST_SUITE_TYPES_H_ + +#ifdef __cplusplus +#define ProtoBool bool +#else +#define ProtoBool _Bool +#endif + +#ifndef __NEXT_RUNTIME__ + +#define METHOD Method_t +#define IVAR_T struct objc_ivar + +/* dummy const string class ref. */ +typedef void * TNS_STRING_REF_T; + +#else /* NeXT */ + +#include "next-abi.h" +#ifdef NEXT_OBJC_USE_NEW_INTERFACE +#include <objc/runtime.h> +#else +#include <objc/objc-runtime.h> +#endif + +/* Force a definition of nil that is compatible with GNU runtime. */ +#undef nil +#define nil ((id)0) + +#ifndef NULL +#define NULL 0 +#endif + +#define METHOD Method + +/* Where there are equivalent interfaces between APIs we substitute + a macro or typedef. */ +#ifdef NEXT_OBJC_USE_NEW_INTERFACE +typedef void * PMETH; +#define IVAR_T Ivar +#else +typedef struct objc_method * PMETH; +#define IVAR_T struct objc_ivar +#endif + +#ifdef __OBJC2__ +/* Const String Class ref. */ +typedef Class TNS_STRING_REF_T; +#else +/* Const String Class ref. */ +/* We need objc_class - but we don't need endless reminders that it's deprecated. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +typedef struct objc_class TNS_STRING_REF_T; +#pragma GCC diagnostic pop +#endif + +#endif /*__NEXT_RUNTIME__ */ +#endif /* _OBJC_TEST_SUITE_TYPES_H_ */
\ No newline at end of file |