1
/* Interface to ObjC runtime for GNUStep
2
Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc.
4
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
7
This file is part of the GNUstep Base Library.
9
This library is free software; you can redistribute it and/or
10
modify it under the terms of the GNU Library General Public
11
License as published by the Free Software Foundation; either
12
version 2 of the License, or (at your option) any later version.
14
This library is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
Library General Public License for more details.
19
You should have received a copy of the GNU Library General Public
20
License along with this library; if not, write to the Free
21
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
24
#ifndef __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE
25
#define __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE
27
#include <objc/objc.h>
28
#include <objc/objc-api.h>
31
#if BUILD_libgnustep_base_DLL
32
# define GS_EXPORT __declspec(dllexport)
33
# define GS_DECLARE __declspec(dllexport)
34
#elif libgnustep_base_ISDLL
35
# define GS_EXPORT extern __declspec(dllimport)
36
# define GS_DECLARE __declspec(dllimport)
38
# define GS_EXPORT extern
45
GS_EXPORT NSString *NSStringFromSelector(SEL aSelector);
46
GS_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);
47
GS_EXPORT Class NSClassFromString(NSString *aClassName);
48
GS_EXPORT NSString *NSStringFromClass(Class aClass);
49
GS_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr,
50
unsigned int *sizep, unsigned int *alignp);
53
/* OpenStep spec states that log messages go to stderr, but just in case
54
someone wants them to go somewhere else, they can implement a function
56
typedef void NSLog_printf_handler (NSString* message);
57
GS_EXPORT NSLog_printf_handler *_NSLog_printf_handler;
59
GS_EXPORT void NSLog (NSString* format, ...);
60
GS_EXPORT void NSLogv (NSString* format, va_list args);
72
#define FOUNDATION_EXPORT
73
#define FOUNDATION_STATIC_INLINE static inline
77
* Functions for accessing instance variables directly -
78
* We can copy an ivar into arbitrary data,
79
* Get the type encoding for a named ivar,
80
* and copy a value into an ivar.
82
GS_EXPORT BOOL GSFindInstanceVariable(id obj, const char *name,
83
const char **type, unsigned int *size, int *offset);
84
GS_EXPORT void GSGetVariable(id obj, int offset, unsigned int size, void *data);
85
GS_EXPORT void GSSetVariable(id obj, int offset, unsigned int size,
89
* Functions for key-value encoding ... they access values in an object
90
* either by selector or directly, but do so using NSNumber for the
91
* scalar types of data.
93
GS_EXPORT id GSGetValue(NSObject *self, NSString *key, SEL sel,
94
const char *type, unsigned size, int offset);
95
GS_EXPORT void GSSetValue(NSObject *self, NSString *key, id val, SEL sel,
96
const char *type, unsigned size, int offset);
99
* The following three functions are deprecated and will be removed in future
101
GS_EXPORT BOOL GSInstanceVariableInfo(id obj, NSString *iVarName,
102
const char **type, unsigned *size, unsigned *offset);
103
GS_EXPORT BOOL GSGetInstanceVariable(id obj, NSString *name, void* data);
104
GS_EXPORT BOOL GSSetInstanceVariable(id obj, NSString *name, const void* data);
106
#include <base/objc-gnu2next.h>
109
* GSObjCClass() return the class of an instance.
110
* The argument to this function must NOT be nil.
112
FOUNDATION_STATIC_INLINE Class
115
return obj->class_pointer;
119
* GSObjCIsInstance() tests to see if an id is an instance.
120
* The argument to this function must NOT be nil.
122
FOUNDATION_STATIC_INLINE BOOL
123
GSObjCIsInstance(id obj)
125
return CLS_ISCLASS(obj->class_pointer);
129
* GSObjCIsKindOf() tests to see if a class inherits from another class
130
* The argument to this function must NOT be nil.
132
FOUNDATION_STATIC_INLINE BOOL
133
GSObjCIsKindOf(Class this, Class other)
141
this = class_get_super_class(this);
148
FOUNDATION_STATIC_INLINE const char*
149
GSObjCName(Class this)
151
return class_get_class_name(this);
156
FOUNDATION_STATIC_INLINE const char*
157
GSObjCSelectorName(SEL this)
161
return sel_get_name(this);
166
FOUNDATION_STATIC_INLINE const char*
167
GSObjCSelectorTypes(SEL this)
169
return sel_get_type(this);
176
* Given a class name, return the corresponding class or
177
* a nul pointer if the class cannot be found. <br />
178
* If the argument is nil, return a nul pointer.
180
FOUNDATION_STATIC_INLINE Class
181
GSClassFromName(const char *name)
185
return objc_lookup_class(name);
189
* Return the name of the supplied class, or a nul pointer if no class
192
FOUNDATION_STATIC_INLINE const char*
193
GSNameFromClass(Class this)
197
return class_get_class_name(this);
201
* Return the name of the supplied selector, or a nul pointer if no selector
204
FOUNDATION_STATIC_INLINE const char*
205
GSNameFromSelector(SEL this)
209
return sel_get_name(this);
213
* Return a selector matching the specified name, or nil if no name is
214
* supplied. The returned selector could be any one with the name.<br />
215
* If no selector exists, returns nil.
217
FOUNDATION_STATIC_INLINE SEL
218
GSSelectorFromName(const char *name)
226
return sel_get_any_uid(name);
231
* Return the selector for the specified name and types. Returns a nul
232
* pointer if the name is nul. Uses any available selector if the types
233
* argument is nul. <br />
234
* Creates a new selector if necessary.
236
FOUNDATION_STATIC_INLINE SEL
237
GSSelectorFromNameAndTypes(const char *name, const char *types)
249
s = sel_get_any_typed_uid(name);
253
s = sel_get_typed_uid(name, types);
259
s = sel_register_name(name);
263
s = sel_register_typed_name(name, types);
272
* Return the type information from the specified selector.
273
* May return a nul pointer if the selector was a nul pointer or if it
276
FOUNDATION_STATIC_INLINE const char*
277
GSTypesFromSelector(SEL this)
281
return sel_get_type(this);
285
FOUNDATION_STATIC_INLINE Class
286
GSObjCSuper(Class this)
288
return class_get_super_class(this);
291
FOUNDATION_STATIC_INLINE int
292
GSObjCVersion(Class this)
294
return class_get_version(this);
298
* Return the zone in which an object belongs, without using the zone method
300
#include <Foundation/NSZone.h>
301
GS_EXPORT NSZone *GSObjCZone(NSObject *obj);
304
* Quickly return autoreleased data.
306
void *_fastMallocBuffer(unsigned size);
308
/* Getting a system error message on a variety of systems */
309
GS_EXPORT const char *GSLastErrorStr(long error_id);
313
#endif /* __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */