mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Initial revision
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
86aae03ebe
commit
a457b29979
11 changed files with 1172 additions and 0 deletions
80
Source/NSMethodSignature.m
Normal file
80
Source/NSMethodSignature.m
Normal file
|
@ -0,0 +1,80 @@
|
|||
|
||||
#include "foundation/NSMethodSignature.h"
|
||||
#include "objc/objc-malloc.h"
|
||||
|
||||
static int
|
||||
types_get_size_of_arguments(const char *types)
|
||||
{
|
||||
const char* type = objc_skip_typespec (types);
|
||||
return atoi (type);
|
||||
}
|
||||
|
||||
static int
|
||||
types_get_number_of_arguments (const char *types)
|
||||
{
|
||||
int i = 0;
|
||||
const char* type = types;
|
||||
while (*type)
|
||||
{
|
||||
type = objc_skip_argspec (type);
|
||||
i += 1;
|
||||
}
|
||||
return i - 1;
|
||||
}
|
||||
|
||||
@implementation NSMethodSignature
|
||||
|
||||
+ (NSMethodSignature*) signatureWithObjCTypes: (const char*)types
|
||||
{
|
||||
int len;
|
||||
NSMethodSignature *newMs = [NSMethodSignature alloc];
|
||||
len = strlen(types);
|
||||
OBJC_MALLOC(newMs->types, char, len);
|
||||
bcopy(types, newMs->types, len);
|
||||
len = str??();
|
||||
OBJC_MALLOC(newMs->returnTypes, char, len);
|
||||
bcopy(types, newMs->returnTypes, len);
|
||||
newMs->argFrameLength = types_get_size_of_arguments(types);
|
||||
newMs->returnFrameLength = objc_size_of_type(types);
|
||||
newMs->numArgs = types_get_number_of_arguments(types);
|
||||
return newMs;
|
||||
}
|
||||
|
||||
- (NSArgumentInfo) argumentInfoAtIndex: (unsigned)index
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (unsigned) frameLength
|
||||
{
|
||||
return argFrameLength;
|
||||
}
|
||||
|
||||
- (BOOL) isOneway
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (unsigned) methodReturnLength
|
||||
{
|
||||
return returnFrameLength;
|
||||
}
|
||||
|
||||
- (char*) methodReturnType
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
- (unsigned) numberOfArguments
|
||||
{
|
||||
return numArgs;
|
||||
}
|
||||
|
||||
- free
|
||||
{
|
||||
OBJC_FREE(types);
|
||||
return [super free];
|
||||
}
|
||||
|
||||
@end
|
Loading…
Add table
Add a link
Reference in a new issue