]> err.no Git - sope/blob - sope-core/NGExtensions/FdExt.subproj/NSMethodSignature+misc.m
fixed bugs in logger, improved performance
[sope] / sope-core / NGExtensions / FdExt.subproj / NSMethodSignature+misc.m
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #import "common.h"
24 #import "NSMethodSignature+misc.h"
25
26 @implementation NSMethodSignature(misc)
27
28 #if NeXT_Foundation_LIBRARY
29 - (NSString *)objCTypes {
30   return [NSString stringWithCString:self->_types];
31 }
32 #else
33 - (NSString *)objCTypes {
34   char buf[256], *bufPos = buf;
35   int  argCount = [self numberOfArguments];
36   char *pos1    = NULL, *pos2 = NULL;
37   
38   // return type
39 #if GNUSTEP_BASE_LIBRARY
40   pos1 = (char *)[self methodType];
41 #else
42   pos1 = (char *)[self types];
43 #endif
44   pos2 = (char *)objc_skip_typespec(pos1);
45   strncpy(bufPos, pos1, pos2 - pos1);
46   bufPos += pos2 - pos1;
47   //*bufPos = '\0';
48   pos1 = (char *)objc_skip_offset(pos2);
49
50   // arguments
51   {
52     register int i;
53
54     for (i = 0; i < argCount; i++) {
55       pos2 = (char *)objc_skip_typespec(pos1); // forward to offset
56       strncpy(bufPos, pos1, pos2 - pos1);
57       bufPos += pos2 - pos1;
58       //*bufPos = '\0';
59       pos1 = (char *)objc_skip_offset(pos2);   // forward to next type
60     }
61   }
62   *bufPos = '\0';
63
64   return [NSString stringWithCString:buf];
65 }
66 #endif
67
68 @end /* NSMethodSignature(misc) */
69
70 void __link_NSMethodSignature_misc() {
71   __link_NSMethodSignature_misc();
72 }