mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-30 03:50:46 +00:00
Most of these changes involve simply removing direct manipulation of any runtime structures and replacing them with runtime function calls. For example class->name becomes class_getName(class) and so on. libobjc2, like the Apple runtime, the NeXT runtime, and every version of the Objective-C spec, calls the class pointer in id isa. A few files now have #define class_pointer isa at the top. This line replaces class_pointer in the old GNU libobjc headers with isa so either class_pointer or isa can be used for accessing the class of an object. Note: object_getClass() should be used in most cases because, in some future version of the runtime, this will skip things like lock classes and other hidden classes (e.g. KVO classes). All of the old forwarding stuff has been removed. Most of this stuff followed convoluted code paths that ended with an exception. A few simply broke in exciting ways. Hopefully no one has used them for the last ten years or so, but we can bring them back with some #ifndef stuff if they're really needed by anyone. There is currently a bug in configure, which prevents dladdr() from being detected, so you need to manually tweak config.h to build - I have not fixed the fall-back code in objc-load.m to work with libobjc2, I just added a new version that uses the loader's functionality directly. Although -base now builds, it builds with a lot of warnings. <string.h> is missing from a lot of files, so memcpy() and strlen() generate implicit function declaration warnings. Additionally, libobjc2 does still provide the sel_{get,register}_*() functions, but they're wrappers around the newer API ones. These are deprecated and are not exposed in the headers. Although they work, we should be replacing them with the libobjc2 versions as soon as possible. This incorporates a patch by Eric. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31265 72102866-910b-0410-8b05-ffd578937521
155 lines
4.3 KiB
Objective-C
155 lines
4.3 KiB
Objective-C
/* Interface for NSInvocation for GNUStep
|
|
Copyright (C) 1998,2003 Free Software Foundation, Inc.
|
|
|
|
Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
Date: 1998
|
|
Based on code by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
This library 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
|
|
Library General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with this library; if not, write to the Free
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Boston, MA 02111 USA.
|
|
*/
|
|
|
|
#ifndef __NSInvocation_h_GNUSTEP_BASE_INCLUDE
|
|
#define __NSInvocation_h_GNUSTEP_BASE_INCLUDE
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
|
|
|
#import <Foundation/NSMethodSignature.h>
|
|
|
|
#if defined(__cplusplus)
|
|
extern "C" {
|
|
#endif
|
|
|
|
@interface NSInvocation : NSObject
|
|
{
|
|
#if GS_EXPOSE(NSInvocation)
|
|
@public
|
|
NSMethodSignature *_sig;
|
|
void *_cframe;
|
|
void *_retval;
|
|
id _target;
|
|
SEL _selector;
|
|
unsigned int _numArgs;
|
|
void *_info;
|
|
BOOL _argsRetained;
|
|
BOOL _targetRetained;
|
|
BOOL _validReturn;
|
|
BOOL _sendToSuper;
|
|
void *_retptr;
|
|
#endif
|
|
#if !GS_NONFRAGILE
|
|
void *_unused;
|
|
#endif
|
|
}
|
|
|
|
/*
|
|
* Creating instances.
|
|
*/
|
|
+ (NSInvocation*) invocationWithMethodSignature: (NSMethodSignature*)_signature;
|
|
|
|
/*
|
|
* Accessing message elements.
|
|
*/
|
|
- (void) getArgument: (void*)buffer
|
|
atIndex: (NSInteger)index;
|
|
- (void) getReturnValue: (void*)buffer;
|
|
- (SEL) selector;
|
|
- (void) setArgument: (void*)buffer
|
|
atIndex: (NSInteger)index;
|
|
- (void) setReturnValue: (void*)buffer;
|
|
- (void) setSelector: (SEL)aSelector;
|
|
- (void) setTarget: (id)anObject;
|
|
- (id) target;
|
|
|
|
/*
|
|
* Managing arguments.
|
|
*/
|
|
- (BOOL) argumentsRetained;
|
|
- (void) retainArguments;
|
|
|
|
#if OS_API_VERSION(GS_API_NONE,GS_API_NONE) && GS_API_VERSION( 11101,GS_API_LATEST)
|
|
- (BOOL) targetRetained;
|
|
- (void) retainArgumentsIncludingTarget: (BOOL)retainTargetFlag;
|
|
#endif
|
|
|
|
/*
|
|
* Dispatching an Invocation.
|
|
*/
|
|
- (void) invoke;
|
|
- (void) invokeWithTarget: (id)anObject;
|
|
|
|
/*
|
|
* Getting the method signature.
|
|
*/
|
|
- (NSMethodSignature*) methodSignature;
|
|
|
|
@end
|
|
|
|
#if GS_API_VERSION(GS_API_NONE, 011700)
|
|
@interface NSInvocation (GNUstep)
|
|
/**
|
|
* Returns the status of the flag set by -setSendsToSuper:
|
|
*/
|
|
- (BOOL) sendsToSuper;
|
|
/**
|
|
* Sets the flag to tell the invocation that it should actually invoke a
|
|
* method in the superclass of the target rather than the method of the
|
|
* target itself.<br />
|
|
* This extension permits an invocation to act like a regular method
|
|
* call sent to <em>super</em> in the method of a class.
|
|
*/
|
|
- (void) setSendsToSuper: (BOOL)flag;
|
|
@end
|
|
#endif
|
|
|
|
/* Do NOT use these methods ... internal use only ... not public API */
|
|
@interface NSInvocation (MacroSetup)
|
|
+ (id) _newProxyForInvocation: (id)target;
|
|
+ (id) _newProxyForMessage: (id)target;
|
|
+ (NSInvocation*) _returnInvocationAndDestroyProxy: (id)proxy;
|
|
- (id) initWithMethodSignature: (NSMethodSignature*)aSignature;
|
|
@end
|
|
|
|
/**
|
|
* Creates and returns an autoreleased invocation containing a
|
|
* message to an instance of the class. The 'message' consists
|
|
* of selector and arguments like a standard ObjectiveC method
|
|
* call.<br />
|
|
* Before using the returned invocation, you need to set its target.
|
|
*/
|
|
#define NS_INVOCATION(aClass, message...) ({\
|
|
id __proxy = [NSInvocation _newProxyForInvocation: aClass]; \
|
|
[__proxy message]; \
|
|
[NSInvocation _returnInvocationAndDestroyProxy: __proxy]; \
|
|
})
|
|
|
|
/**
|
|
* Creates and returns an autoreleased invocation containing a
|
|
* message to the target object. The 'message' consists
|
|
* of selector and arguments like a standard ObjectiveC method
|
|
* call.
|
|
*/
|
|
#define NS_MESSAGE(target, message...) ({\
|
|
id __proxy = [NSInvocation _newProxyForMessage: target]; \
|
|
[__proxy message]; \
|
|
[NSInvocation _returnInvocationAndDestroyProxy: __proxy]; \
|
|
})
|
|
|
|
#if defined(__cplusplus)
|
|
}
|
|
#endif
|
|
|
|
#endif /* __NSInvocation_h_GNUSTEP_BASE_INCLUDE */
|