1995-03-12 19:58:48 +00:00
|
|
|
/* Implementation of NSMethodSignature for GNUStep
|
1998-08-13 20:45:32 +00:00
|
|
|
Copyright (C) 1994, 1995, 1996, 1998 Free Software Foundation, Inc.
|
1995-03-12 19:58:48 +00:00
|
|
|
|
1996-04-17 20:17:45 +00:00
|
|
|
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
1995-03-12 19:58:48 +00:00
|
|
|
Date: August 1994
|
1998-08-13 20:45:32 +00:00
|
|
|
Rewritten: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
Date: August 1998
|
1995-03-12 19:58:48 +00:00
|
|
|
|
1996-05-12 00:56:10 +00:00
|
|
|
This file is part of the GNUstep Base Library.
|
1995-03-12 19:58:48 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library 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 Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
1999-09-09 02:56:20 +00:00
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
1995-03-12 19:58:48 +00:00
|
|
|
*/
|
1994-11-08 16:44:01 +00:00
|
|
|
|
1998-05-29 15:25:41 +00:00
|
|
|
#include <config.h>
|
1998-12-20 21:27:47 +00:00
|
|
|
#include <base/preface.h>
|
1998-12-14 06:17:12 +00:00
|
|
|
#include <mframe.h>
|
1998-01-26 14:18:18 +00:00
|
|
|
|
1995-11-06 17:36:48 +00:00
|
|
|
#include <Foundation/NSMethodSignature.h>
|
1995-11-06 17:38:33 +00:00
|
|
|
#include <Foundation/NSException.h>
|
|
|
|
#include <Foundation/NSString.h>
|
1994-11-08 16:44:01 +00:00
|
|
|
|
1998-04-30 20:11:42 +00:00
|
|
|
|
1994-11-08 16:44:01 +00:00
|
|
|
@implementation NSMethodSignature
|
|
|
|
|
1995-11-06 17:36:48 +00:00
|
|
|
+ (NSMethodSignature*) signatureWithObjCTypes: (const char*)t
|
1994-11-08 16:44:01 +00:00
|
|
|
{
|
1999-09-16 07:21:34 +00:00
|
|
|
NSMethodSignature *newMs = [[NSMethodSignature alloc] autorelease];
|
1998-04-30 20:11:42 +00:00
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
newMs->_methodTypes = mframe_build_signature(t, &newMs->_argFrameLength,
|
|
|
|
&newMs->_numArgs, 0);
|
1998-04-30 20:11:42 +00:00
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
return newMs;
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArgumentInfo) argumentInfoAtIndex: (unsigned)index
|
|
|
|
{
|
1999-09-16 07:21:34 +00:00
|
|
|
if (index >= _numArgs)
|
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
format: @"Index too high."];
|
1998-02-03 14:20:00 +00:00
|
|
|
}
|
1999-09-16 07:21:34 +00:00
|
|
|
if (_info == 0)
|
|
|
|
{
|
|
|
|
[self methodInfo];
|
1998-02-03 14:20:00 +00:00
|
|
|
}
|
1999-09-16 07:21:34 +00:00
|
|
|
return _info[index+1];
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (unsigned) frameLength
|
|
|
|
{
|
1999-09-16 07:21:34 +00:00
|
|
|
return _argFrameLength;
|
1998-08-13 20:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (const char*) getArgumentTypeAtIndex: (unsigned)index
|
|
|
|
{
|
1999-09-16 07:21:34 +00:00
|
|
|
if (index >= _numArgs)
|
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
format: @"Index too high."];
|
1998-08-13 20:45:32 +00:00
|
|
|
}
|
1999-09-16 07:21:34 +00:00
|
|
|
if (_info == 0)
|
|
|
|
{
|
|
|
|
[self methodInfo];
|
1998-08-13 20:45:32 +00:00
|
|
|
}
|
1999-09-16 07:21:34 +00:00
|
|
|
return _info[index+1].type;
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isOneway
|
|
|
|
{
|
1999-09-16 07:21:34 +00:00
|
|
|
if (_info == 0)
|
|
|
|
{
|
|
|
|
[self methodInfo];
|
1998-08-13 20:45:32 +00:00
|
|
|
}
|
1999-09-16 07:21:34 +00:00
|
|
|
return (_info[0].qual & _F_ONEWAY) ? YES : NO;
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (unsigned) methodReturnLength
|
|
|
|
{
|
1999-09-16 07:21:34 +00:00
|
|
|
if (_info == 0)
|
|
|
|
{
|
|
|
|
[self methodInfo];
|
1998-08-13 20:45:32 +00:00
|
|
|
}
|
1999-09-16 07:21:34 +00:00
|
|
|
return _info[0].size;
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
1998-08-13 20:45:32 +00:00
|
|
|
- (const char*) methodReturnType
|
1994-11-08 16:44:01 +00:00
|
|
|
{
|
1999-09-16 07:21:34 +00:00
|
|
|
if (_info == 0)
|
|
|
|
{
|
|
|
|
[self methodInfo];
|
1998-08-13 20:45:32 +00:00
|
|
|
}
|
1999-09-16 07:21:34 +00:00
|
|
|
return _info[0].type;
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (unsigned) numberOfArguments
|
|
|
|
{
|
1999-09-16 07:21:34 +00:00
|
|
|
return _numArgs;
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
1995-03-12 19:58:48 +00:00
|
|
|
- (void) dealloc
|
1994-11-08 16:44:01 +00:00
|
|
|
{
|
1999-09-16 07:21:34 +00:00
|
|
|
if (_methodTypes)
|
|
|
|
objc_free((void*)_methodTypes);
|
|
|
|
if (_info)
|
|
|
|
objc_free((void*)_info);
|
|
|
|
[super dealloc];
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
1998-01-26 14:18:18 +00:00
|
|
|
|
|
|
|
@implementation NSMethodSignature(GNU)
|
1998-08-13 20:45:32 +00:00
|
|
|
- (NSArgumentInfo*) methodInfo
|
|
|
|
{
|
1999-09-16 07:21:34 +00:00
|
|
|
if (_info == 0)
|
|
|
|
{
|
|
|
|
const char *types = _methodTypes;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
_info = objc_malloc(sizeof(NSArgumentInfo)*(_numArgs+1));
|
|
|
|
for (i = 0; i <= _numArgs; i++)
|
|
|
|
{
|
|
|
|
types = mframe_next_arg(types, &_info[i]);
|
1998-08-13 20:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
1999-09-16 07:21:34 +00:00
|
|
|
return _info;
|
1998-08-13 20:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (const char*) methodType
|
1998-01-26 14:18:18 +00:00
|
|
|
{
|
1999-09-16 07:21:34 +00:00
|
|
|
return _methodTypes;
|
1998-01-26 14:18:18 +00:00
|
|
|
}
|
|
|
|
@end
|