1998-09-21 03:22:07 +02:00
|
|
|
/* Basic data types for Objective C.
|
2010-09-11 14:38:56 +02:00
|
|
|
Copyright (C) 1993, 1995, 1996, 2004, 2009,
|
|
|
|
2010 Free Software Foundation, Inc.
|
1998-09-21 03:22:07 +02:00
|
|
|
|
Makefile.in, [...]: Replace "GNU CC" with "GCC".
2003-05-23 Nathanael Nerode <neroden@gcc.gnu.org>
* Makefile.in, NXConstStr.m, Object.m, Protocol.m, archive.c,
class.c, encoding.c, gc.c, objc/NXConstStr.h, objc/Object.h,
objc/Protocol.h, objc/encoding.h, objc/hash.h, objc/objc-api.h,
objc/objc-list.h, objc/objc.h, ocjc/runtime.h, objc/sarray.h,
objc/thr.h, objc/typedstream.h: Replace "GNU CC" with "GCC".
From-SVN: r67131
2003-05-23 22:04:58 +02:00
|
|
|
This file is part of GCC.
|
1998-09-21 03:22:07 +02:00
|
|
|
|
Makefile.in, [...]: Replace "GNU CC" with "GCC".
2003-05-23 Nathanael Nerode <neroden@gcc.gnu.org>
* Makefile.in, NXConstStr.m, Object.m, Protocol.m, archive.c,
class.c, encoding.c, gc.c, objc/NXConstStr.h, objc/Object.h,
objc/Protocol.h, objc/encoding.h, objc/hash.h, objc/objc-api.h,
objc/objc-list.h, objc/objc.h, ocjc/runtime.h, objc/sarray.h,
objc/thr.h, objc/typedstream.h: Replace "GNU CC" with "GCC".
From-SVN: r67131
2003-05-23 22:04:58 +02:00
|
|
|
GCC is free software; you can redistribute it and/or modify
|
1998-09-21 03:22:07 +02:00
|
|
|
it under the terms of the GNU General Public License as published by
|
2009-04-09 17:00:19 +02:00
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
1998-09-21 03:22:07 +02:00
|
|
|
any later version.
|
|
|
|
|
Makefile.in, [...]: Replace "GNU CC" with "GCC".
2003-05-23 Nathanael Nerode <neroden@gcc.gnu.org>
* Makefile.in, NXConstStr.m, Object.m, Protocol.m, archive.c,
class.c, encoding.c, gc.c, objc/NXConstStr.h, objc/Object.h,
objc/Protocol.h, objc/encoding.h, objc/hash.h, objc/objc-api.h,
objc/objc-list.h, objc/objc.h, ocjc/runtime.h, objc/sarray.h,
objc/thr.h, objc/typedstream.h: Replace "GNU CC" with "GCC".
From-SVN: r67131
2003-05-23 22:04:58 +02:00
|
|
|
GCC is distributed in the hope that it will be useful,
|
1998-09-21 03:22:07 +02:00
|
|
|
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.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1998-09-21 03:22:07 +02:00
|
|
|
|
|
|
|
#ifndef __objc_INCLUDE_GNU
|
|
|
|
#define __objc_INCLUDE_GNU
|
|
|
|
|
2010-09-12 00:47:14 +02:00
|
|
|
/* This file contains the definition of the basic types used by the
|
|
|
|
Objective-C language. It needs to be included to do almost
|
2010-12-19 02:29:09 +01:00
|
|
|
anything with Objective-C. */
|
2010-09-12 00:47:14 +02:00
|
|
|
|
1998-09-21 03:22:07 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2010-12-19 02:29:09 +01:00
|
|
|
/* objc-decls.h is included because deprecated/objc_msg_sendv.h needs
|
|
|
|
it. When that goes away, the include of objc-decls.h should be
|
|
|
|
removed. */
|
|
|
|
#include "objc-decls.h"
|
|
|
|
|
2010-09-12 00:47:14 +02:00
|
|
|
/* The current version of the GNU Objective-C Runtime library in
|
|
|
|
compressed ISO date format. This should be updated any time a new
|
|
|
|
version is released with changes to the public API (there is no
|
|
|
|
need to update it if there were no API changes since the previous
|
|
|
|
release). This macro is only defined starting with the GNU
|
|
|
|
Objective-C Runtime shipped with GCC 4.6.0. If it is not defined,
|
2010-12-19 02:29:09 +01:00
|
|
|
it is either an older version of the runtime, or another runtime. */
|
2010-09-12 00:47:14 +02:00
|
|
|
#define __GNU_LIBOBJC__ 20100911
|
|
|
|
|
2010-12-19 02:29:09 +01:00
|
|
|
/* Definition of the boolean type.
|
2010-09-11 14:38:56 +02:00
|
|
|
|
2010-12-19 02:29:09 +01:00
|
|
|
Compatibility note: the Apple/NeXT runtime defines a BOOL as a
|
|
|
|
'signed char'. The GNU runtime uses an 'unsigned char'.
|
2010-09-11 14:38:56 +02:00
|
|
|
|
2010-12-19 02:29:09 +01:00
|
|
|
Important: this could change and we could switch to 'typedef bool
|
|
|
|
BOOL' in the future. Do not depend on the type of BOOL. */
|
2008-11-21 13:07:43 +01:00
|
|
|
#undef BOOL
|
1998-09-21 03:22:07 +02:00
|
|
|
typedef unsigned char BOOL;
|
2010-09-11 14:38:56 +02:00
|
|
|
|
1998-09-21 03:22:07 +02:00
|
|
|
#define YES (BOOL)1
|
|
|
|
#define NO (BOOL)0
|
|
|
|
|
2010-09-11 14:38:56 +02:00
|
|
|
/* The basic Objective-C types (SEL, Class, id) are defined as pointer
|
|
|
|
to opaque structures. The details of the structures are private to
|
|
|
|
the runtime and may potentially change from one version to the
|
2010-12-19 02:29:09 +01:00
|
|
|
other. */
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-09-11 14:38:56 +02:00
|
|
|
/* A SEL (selector) represents an abstract method (in the
|
|
|
|
object-oriented sense) and includes all the details of how to
|
|
|
|
invoke the method (which means its name, arguments and return
|
|
|
|
types) but provides no implementation of its own. You can check
|
|
|
|
whether a class implements a selector or not, and if you have a
|
|
|
|
selector and know that the class implements it, you can use it to
|
2010-12-19 02:29:09 +01:00
|
|
|
call the method for an object in the class. */
|
2010-09-11 14:38:56 +02:00
|
|
|
typedef const struct objc_selector *SEL;
|
|
|
|
#include "deprecated/struct_objc_selector.h"
|
|
|
|
|
|
|
|
/* A Class is a class (in the object-oriented sense). In Objective-C
|
|
|
|
there is the complication that each Class is an object itself, and
|
|
|
|
so belongs to a class too. This class that a class belongs to is
|
2010-12-19 02:29:09 +01:00
|
|
|
called its 'meta class'. */
|
2010-09-11 14:38:56 +02:00
|
|
|
typedef struct objc_class *Class;
|
|
|
|
#include "deprecated/MetaClass.h"
|
|
|
|
#include "deprecated/struct_objc_class.h"
|
|
|
|
|
2010-10-11 01:28:12 +02:00
|
|
|
/* An 'id' is an object of an unknown class. The way the object data
|
|
|
|
is stored inside the object is private and what you see here is
|
|
|
|
only the beginning of the actual struct. The first field is always
|
2010-12-19 02:29:09 +01:00
|
|
|
a pointer to the Class that the object belongs to. */
|
2010-09-11 14:38:56 +02:00
|
|
|
typedef struct objc_object
|
|
|
|
{
|
|
|
|
/* 'class_pointer' is the Class that the object belongs to. In case
|
2010-10-11 01:28:12 +02:00
|
|
|
of a Class object, this pointer points to the meta class.
|
|
|
|
|
|
|
|
Compatibility Note: The Apple/NeXT runtime calls this field
|
2010-12-19 02:29:09 +01:00
|
|
|
'isa'. To access this field, use object_getClass() from
|
|
|
|
runtime.h, which is an inline function so does not add any
|
|
|
|
overhead and is also portable to other runtimes. */
|
2010-09-11 14:38:56 +02:00
|
|
|
Class class_pointer;
|
1998-09-21 03:22:07 +02:00
|
|
|
} *id;
|
|
|
|
|
2010-12-19 02:29:09 +01:00
|
|
|
/* 'IMP' is a C function that implements a method. When retrieving
|
|
|
|
the implementation of a method from the runtime, this is the type
|
|
|
|
of the pointer returned. The idea of the definition of IMP is to
|
|
|
|
represent a 'pointer to a general function taking an id, a SEL,
|
|
|
|
followed by other unspecified arguments'. You must always cast an
|
|
|
|
IMP to a pointer to a function taking the appropriate, specific
|
|
|
|
types for that function, before calling it - to make sure the
|
|
|
|
appropriate arguments are passed to it. The code generated by the
|
|
|
|
compiler to perform method calls automatically does this cast
|
|
|
|
inside method calls. */
|
1998-09-21 03:22:07 +02:00
|
|
|
typedef id (*IMP)(id, SEL, ...);
|
|
|
|
|
2010-09-11 14:38:56 +02:00
|
|
|
/* 'nil' is the null object. Messages to nil do nothing and always
|
|
|
|
return 0. */
|
|
|
|
#define nil (id)0
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-09-11 14:38:56 +02:00
|
|
|
/* 'Nil' is the null class. Since classes are objects too, this is
|
|
|
|
actually the same object as 'nil' (and behaves in the same way),
|
|
|
|
but it has a type of Class, so it is good to use it instead of
|
|
|
|
'nil' if you are comparing a Class object to nil as it enables the
|
|
|
|
compiler to do some type-checking. */
|
|
|
|
#define Nil (Class)0
|
|
|
|
|
|
|
|
#include "deprecated/STR.h"
|
|
|
|
|
|
|
|
/* TODO: Move the 'Protocol' declaration into objc/runtime.h. A
|
|
|
|
Protocol is simply an object, not a basic Objective-C type. The
|
|
|
|
Apple runtime defines Protocol in objc/runtime.h too, so it's good
|
2010-12-19 02:29:09 +01:00
|
|
|
to move it there for API compatibility. */
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-09-11 14:38:56 +02:00
|
|
|
/* A 'Protocol' is a formally defined list of selectors (normally
|
|
|
|
created using the @protocol Objective-C syntax). It is mostly used
|
|
|
|
at compile-time to check that classes implement all the methods
|
|
|
|
that they are supposed to. Protocols are also available in the
|
2010-12-19 02:29:09 +01:00
|
|
|
runtime system as Protocol objects. */
|
1998-09-21 03:22:07 +02:00
|
|
|
#ifndef __OBJC__
|
2010-09-11 14:38:56 +02:00
|
|
|
/* Once we stop including the deprecated struct_objc_protocol.h
|
|
|
|
there is no reason to even define a 'struct objc_protocol'. As
|
|
|
|
all the structure details will be hidden, a Protocol basically is
|
2010-12-19 02:29:09 +01:00
|
|
|
simply an object (as it should be). */
|
2010-09-11 14:38:56 +02:00
|
|
|
/* typedef struct objc_object Protocol; */
|
|
|
|
#include "deprecated/struct_objc_protocol.h"
|
1998-09-21 03:22:07 +02:00
|
|
|
#else /* __OBJC__ */
|
2010-09-11 14:38:56 +02:00
|
|
|
@class Protocol;
|
1998-09-21 03:22:07 +02:00
|
|
|
#endif
|
|
|
|
|
2010-09-11 14:38:56 +02:00
|
|
|
/* Deprecated include - here temporarily, for backwards-compatibility
|
|
|
|
as reval_t, apply_t, arglist_t and objc_msg_lookup() used to be
|
2010-12-19 02:29:09 +01:00
|
|
|
defined here. objc_msg_lookup() is now defined in message.h,
|
|
|
|
included by objc-api.h or runtime.h. */
|
|
|
|
#include "deprecated/objc_msg_sendv.h"
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-09-11 14:38:56 +02:00
|
|
|
/* Compatibility note: the Apple/NeXT runtime defines sel_getName(),
|
|
|
|
sel_registerName(), object_getClassName(), object_getIndexedIvars()
|
|
|
|
in this file while the GNU runtime defines them in runtime.h.
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-09-11 14:38:56 +02:00
|
|
|
The reason the GNU runtime does not define them here is that they
|
|
|
|
are not basic Objective-C types (defined in this file), but are
|
2010-12-19 02:29:09 +01:00
|
|
|
part of the runtime API (defined in runtime.h). */
|
1998-09-21 03:22:07 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* not __objc_INCLUDE_GNU */
|