aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/objc')
-rw-r--r--gcc/testsuite/objc/execute/_cmd.m2
-rw-r--r--gcc/testsuite/objc/execute/next_mapping.h52
-rw-r--r--gcc/testsuite/objc/execute/string1.m2
-rw-r--r--gcc/testsuite/objc/execute/string2.m2
-rw-r--r--gcc/testsuite/objc/execute/string3.m2
-rw-r--r--gcc/testsuite/objc/execute/string4.m2
6 files changed, 56 insertions, 6 deletions
diff --git a/gcc/testsuite/objc/execute/_cmd.m b/gcc/testsuite/objc/execute/_cmd.m
index f2b05b6527b..72c555e6d42 100644
--- a/gcc/testsuite/objc/execute/_cmd.m
+++ b/gcc/testsuite/objc/execute/_cmd.m
@@ -14,7 +14,7 @@
@end
@implementation TestClass
-+ (const char*) method;
++ (const char*) method
{
return sel_get_name (_cmd);
}
diff --git a/gcc/testsuite/objc/execute/next_mapping.h b/gcc/testsuite/objc/execute/next_mapping.h
index 67c2ce34257..0a361896e12 100644
--- a/gcc/testsuite/objc/execute/next_mapping.h
+++ b/gcc/testsuite/objc/execute/next_mapping.h
@@ -1,10 +1,12 @@
/* This file "renames" various ObjC GNU runtime entry points
(and fakes the existence of several others)
if the NeXT runtime is being used. */
-/* Author: Ziemowit Laski <zlaski@apple.com> */
+/* Authors: Ziemowit Laski <zlaski@apple.com> */
+/* David Ayers <d.ayers@inode.at> */
#ifdef __NEXT_RUNTIME__
#include <objc/objc-class.h>
+#include <objc/Object.h>
#include <ctype.h>
#define objc_get_class(C) objc_getClass(C)
@@ -848,4 +850,52 @@ void objc_layout_structure_get_info (struct objc_struct_layout *layout,
*type = layout->prev_type;
}
+/* A small, portable NSConstantString implementation for use with the 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.
+*/
+
+struct objc_class _NSConstantStringClassReference;
+
+@interface NSConstantString : Object
+{
+ char *c_string;
+ unsigned int len;
+}
+
+-(const char *) cString;
+-(unsigned int) length;
+
+@end
+
+@implementation NSConstantString
+
+-(const char *) cString
+{
+ return (c_string);
+}
+
+-(unsigned int) length
+{
+ return (len);
+}
+
+@end
+
+/* 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 /* #ifdef __NEXT_RUNTIME__ */
diff --git a/gcc/testsuite/objc/execute/string1.m b/gcc/testsuite/objc/execute/string1.m
index 58a603c1f1f..ac49bd1f4f3 100644
--- a/gcc/testsuite/objc/execute/string1.m
+++ b/gcc/testsuite/objc/execute/string1.m
@@ -4,7 +4,7 @@
#include <stdlib.h>
#ifdef __NEXT_RUNTIME__
-#import <Foundation/NSString.h>
+#include "next_mapping.h"
#else
#include <objc/NXConstStr.h>
#endif
diff --git a/gcc/testsuite/objc/execute/string2.m b/gcc/testsuite/objc/execute/string2.m
index 01fb85c1189..63b0e9b8056 100644
--- a/gcc/testsuite/objc/execute/string2.m
+++ b/gcc/testsuite/objc/execute/string2.m
@@ -4,7 +4,7 @@
#include <stdlib.h>
#ifdef __NEXT_RUNTIME__
-#import <Foundation/NSString.h>
+#include "next_mapping.h"
#else
#include <objc/NXConstStr.h>
#endif
diff --git a/gcc/testsuite/objc/execute/string3.m b/gcc/testsuite/objc/execute/string3.m
index a8d29696899..442952478b7 100644
--- a/gcc/testsuite/objc/execute/string3.m
+++ b/gcc/testsuite/objc/execute/string3.m
@@ -4,7 +4,7 @@
#include <stdlib.h>
#ifdef __NEXT_RUNTIME__
-#import <Foundation/NSString.h>
+#include "next_mapping.h"
#else
#include <objc/NXConstStr.h>
#endif
diff --git a/gcc/testsuite/objc/execute/string4.m b/gcc/testsuite/objc/execute/string4.m
index 16025cbaed6..87b081c084d 100644
--- a/gcc/testsuite/objc/execute/string4.m
+++ b/gcc/testsuite/objc/execute/string4.m
@@ -4,7 +4,7 @@
#include <stdlib.h>
#ifdef __NEXT_RUNTIME__
-#import <Foundation/NSString.h>
+#include "next_mapping.h"
#else
#include <objc/NXConstStr.h>
#endif