#import "type-test.h" @implementation TypeTest + (BOOL)printInt:(int)i Double:(double)d Float:(float)f { printf("printInt: %d %.20g %.20f\n", i, d, f); return YES; } + (int)printSel:(SEL)sel { printf("printSel: %s\n", (char *)sel); } + (double)returnDoublePlusOneHalf:(double)d { return(d + 0.5); } + (float)returnFloatPlusOneHalf:(float)f { return(f + 0.5f); } /* test of BOOL */ + (BOOL)isGreaterThanThree:(int)i { return i > 3 ? YES : NO; } + (unsigned char)convertIntToUChar:(int) i { return (unsigned char)i; } + (short)convertIntToShort:(int)i { return i; } + (unsigned short)convertIntToUShort:(int)i { return i; } + (id)returnNSStringHiMom { id str = [[NSString alloc] initWithCString: "hi, mom!"]; [[str retain] autorelease]; // necessary to retain? return str; } + (id)returnNullObject { return NULL; } + (int)returnIntMinusOne:(int)i { return i - 1; } + (unsigned int)convertIntToUInt:(int)i { return i; } + (long)convertIntToLong:(int)i { return i; } + (unsigned long)convertIntToULong:(int)i { return i; } + (int)addShort:(short)i toUShort:(unsigned short)j { return i + j; } + (long)addLong:(long)i toULong:(unsigned long)j { return i + j; } + (int)addInt:(int)i toUInt:(unsigned int)j { return i + j; } + (BOOL)isTrue:(BOOL)b { return b ? YES : NO; // transmute non-zero input to YES, zero to NO } + (unsigned char)nextChar:(unsigned char)c { return c + (unsigned char)1; } + (void)describeId:(id)o { printf("description: %s\n", [[o description] cString]); } + (id)returnTypeTest { return [[[TypeTest alloc] init] autorelease]; } - (id)init { [super init]; i = 3; ui = -1; d = 2.1 + 0.5; f = 6.9; str = @"hi"; return self; } - (int)getInt { return i; } - (void)setInt:(int)val { i = val; } - (int)testdbl:(double)dbl integer:(int)val { printf("dbl %g int %d\n", dbl, val); } + (NSRect)printRect:(NSRect)r { printf("rect: x, y = %f, %f w, h = %f, %f\n", r.origin.x, r.origin.y, r.size.width, r.size.height); return r; } #if 0 - release { printf("releasing Typetest %p\n", self); [super release]; } - (id)retain { printf("retaining %s\n", [[self description] cString]); return [super retain]; } #endif /* Print a message when this object is deallocated. */ - (void)dealloc { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; printf("deallocating %s\n", [[self description] cString]); [pool release]; return [super dealloc]; } @end