Commit d5dc93f4 by Iain Sandoe

ObjC NeXT, split encode-support code from next-mapping.h

	* objc-obj-c++-shared/next-mapping.h: Move code and definitions for
	emulation of libobjc-gnu structure layout functionality to ..
	* objc-obj-c++-shared/objc-test-suite-next-encode-assist.h: New.
	* objc-obj-c++-shared/objc-test-suite-next-encode-assist-impl.h: New.
	* objc/execute/bf-common.h: Adjust headers.
	* objc/execute/bf-1.m: Likewise.
	* objc/execute/bf-2.m: Likewise.
	* objc/execute/bf-3.m: Likewise.
	* objc/execute/bf-4.m: Likewise.
	* objc/execute/bf-5.m: Likewise.
	* objc/execute/bf-6.m: Likewise.
	* objc/execute/bf-7.m: Likewise.
	* objc/execute/bf-8.m: Likewise.
	* objc/execute/bf-9.m: Likewise.
	* objc/execute/bf-10.m: Likewise.
	* objc/execute/bf-11.m: Likewise.
	* objc/execute/bf-12.m: Likewise.
	* objc/execute/bf-13.m: Likewise.
	* objc/execute/bf-14.m: Likewise.
	* objc/execute/bf-15.m: Likewise.
	* objc/execute/bf-16.m: Likewise.
	* objc/execute/bf-17.m: Likewise.
	* objc/execute/bf-18.m: Likewise.
	* objc/execute/bf-19.m: Likewise.
	* objc/execute/bf-20.m: Likewise.
	* objc/execute/bf-21.m: Likewise.
	* objc/execute/bycopy-3.m: Adjust headers, add next-specific code for
	objc_get_type_qualifiers ().

From-SVN: r168597
parent ecb3baaa
2011-01-08 Iain Sandoe <iains@gcc.gnu.org>
* objc-obj-c++-shared/next-mapping.h: Move code and definitions for
emulation of libobjc-gnu structure layout functionality to ..
* objc-obj-c++-shared/objc-test-suite-next-encode-assist.h: New.
* objc-obj-c++-shared/objc-test-suite-next-encode-assist-impl.h: New.
* objc/execute/bf-common.h: Adjust headers.
* objc/execute/bf-1.m: Likewise.
* objc/execute/bf-2.m: Likewise.
* objc/execute/bf-3.m: Likewise.
* objc/execute/bf-4.m: Likewise.
* objc/execute/bf-5.m: Likewise.
* objc/execute/bf-6.m: Likewise.
* objc/execute/bf-7.m: Likewise.
* objc/execute/bf-8.m: Likewise.
* objc/execute/bf-9.m: Likewise.
* objc/execute/bf-10.m: Likewise.
* objc/execute/bf-11.m: Likewise.
* objc/execute/bf-12.m: Likewise.
* objc/execute/bf-13.m: Likewise.
* objc/execute/bf-14.m: Likewise.
* objc/execute/bf-15.m: Likewise.
* objc/execute/bf-16.m: Likewise.
* objc/execute/bf-17.m: Likewise.
* objc/execute/bf-18.m: Likewise.
* objc/execute/bf-19.m: Likewise.
* objc/execute/bf-20.m: Likewise.
* objc/execute/bf-21.m: Likewise.
* objc/execute/bycopy-3.m: Adjust headers, add next-specific code for
objc_get_type_qualifiers ().
2011-01-08 Thomas Koenig <tkoenig@gcc.gnu.org> 2011-01-08 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/45777 PR fortran/45777
......
#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;
#endif
/* The NeXT headers do not define NULL. */
#ifndef NULL
#define NULL 0
#endif
/* 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. */
/* Not sure why the following are missing from NeXT objc headers... */
#ifndef _C_LNG_LNG
#define _C_LNG_LNG 'q'
#endif
#ifndef _C_ULNG_LNG
#define _C_ULNG_LNG 'Q'
#endif
#ifndef _C_ATOM
#define _C_ATOM '%'
#endif
#ifndef _C_BOOL
#define _C_BOOL 'B'
#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
/* Functions available in the GNU runtime, emulated here for testing with NeXT. */
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_ */
#import "../../objc-obj-c++-shared/Object1.h" #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
struct A { struct A {
int i; int i;
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
struct A { struct A {
int i; int i;
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
typedef enum typedef enum
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#import "../../objc-obj-c++-shared/Object1.h"
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/objc-api.h>
@interface MyObject @interface MyObject
{ {
......
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "../../objc-obj-c++-shared/next-mapping.h"
#ifndef __NEXT_RUNTIME__ #ifndef __NEXT_RUNTIME__
#include <objc/encoding.h> #include <objc/encoding.h>
#else
/* The following header, together with the implementation included below,
emulate functionality provided by the GNU runtime but not available from
the NeXT runtime. */
#include "../../objc-obj-c++-shared/objc-test-suite-next-encode-assist.h"
#define objc_get_class(C) objc_getClass(C)
#endif #endif
void print_ivars (Class class) void print_ivars (Class class)
...@@ -63,7 +70,6 @@ int main () ...@@ -63,7 +70,6 @@ int main ()
}; };
int size1, size2; int size1, size2;
Class class = objc_get_class ("MyObject"); Class class = objc_get_class ("MyObject");
printf ("type = %s\n", @encode (struct class_vars)); printf ("type = %s\n", @encode (struct class_vars));
print_ivars (class); print_ivars (class);
...@@ -77,3 +83,5 @@ int main () ...@@ -77,3 +83,5 @@ int main ()
exit (0); exit (0);
} }
#include "../../objc-obj-c++-shared/objc-test-suite-next-encode-assist-impl.h"
...@@ -9,8 +9,10 @@ ...@@ -9,8 +9,10 @@
* interfere with what we are testing, which is that the `bycopy' * interfere with what we are testing, which is that the `bycopy'
* keyword generates the _F_BYCOPY qualifier for the return type. */ * keyword generates the _F_BYCOPY qualifier for the return type. */
#include "../../objc-obj-c++-shared/next-mapping.h" extern void exit (int) __attribute__ ((noreturn));
#include "../../objc-obj-c++-shared/Protocol1.h" extern int printf (const char *, ...);
#include <objc/Protocol.h>
#ifndef __NEXT_RUNTIME__ #ifndef __NEXT_RUNTIME__
#include <objc/encoding.h> #include <objc/encoding.h>
...@@ -31,6 +33,11 @@ ...@@ -31,6 +33,11 @@
} }
@end @end
/* The following header, together with the implementation included below,
emulate functionality provided by the GNU runtime but not available from
the NeXT runtime. */
#include "../../objc-obj-c++-shared/objc-test-suite-next-encode-assist.h"
int main (void) int main (void)
{ {
struct objc_method_description *method; struct objc_method_description *method;
...@@ -69,3 +76,28 @@ int main (void) ...@@ -69,3 +76,28 @@ int main (void)
/* Else, happy end */ /* Else, happy end */
return 0; return 0;
} }
#ifdef __NEXT_RUNTIME__
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;
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment