1997-09-01 21:59:51 +00:00
|
|
|
#include <Foundation/NSRunLoop.h>
|
1996-03-19 02:02:52 +00:00
|
|
|
#include <Foundation/NSTimer.h>
|
2000-08-07 22:00:31 +00:00
|
|
|
#include <Foundation/NSInvocation.h>
|
|
|
|
#include <Foundation/NSAutoreleasePool.h>
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
|
|
@interface TestDouble : NSObject
|
|
|
|
+ (double) testDouble;
|
|
|
|
- (double) testDoubleInstance;
|
|
|
|
@end
|
|
|
|
@implementation TestDouble
|
2000-08-07 22:00:31 +00:00
|
|
|
+ (void) sayCount
|
|
|
|
{
|
|
|
|
static int count = 0;
|
|
|
|
printf ("Timer fired %d times\n", ++count);
|
2003-07-07 11:20:03 +00:00
|
|
|
if (count == 20)
|
|
|
|
exit(0);
|
2000-08-07 22:00:31 +00:00
|
|
|
}
|
1996-03-19 02:02:52 +00:00
|
|
|
+ (double) testDouble
|
|
|
|
{
|
|
|
|
return 12345678912345.0;
|
|
|
|
}
|
|
|
|
- (double) testDoubleInstance
|
|
|
|
{
|
|
|
|
return 92345678912345.0;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
double test_double ()
|
|
|
|
{
|
|
|
|
return 92345678912345.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
1998-10-03 05:11:05 +00:00
|
|
|
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
1996-03-19 02:02:52 +00:00
|
|
|
volatile double foo, bar;
|
2000-08-07 22:00:31 +00:00
|
|
|
id inv;
|
1996-03-19 02:02:52 +00:00
|
|
|
id o;
|
|
|
|
id d;
|
2005-02-22 11:22:44 +00:00
|
|
|
|
|
|
|
inv = [NSInvocation invocationWithMethodSignature:
|
2000-08-07 22:00:31 +00:00
|
|
|
[TestDouble methodSignatureForSelector: @selector(sayCount)]];
|
|
|
|
[inv setSelector: @selector(sayCount)];
|
|
|
|
[inv setTarget: [TestDouble class]];
|
|
|
|
|
1996-03-19 02:02:52 +00:00
|
|
|
foo = [TestDouble testDouble];
|
|
|
|
printf ("TestDouble is %f\n", foo);
|
|
|
|
foo = [TestDouble testDouble];
|
|
|
|
printf ("TestDouble 2 is %f\n", foo);
|
|
|
|
o = [[TestDouble alloc] init];
|
|
|
|
bar = [o testDoubleInstance];
|
|
|
|
printf ("testDouble is %f\n", bar);
|
|
|
|
|
|
|
|
foo = test_double ();
|
|
|
|
printf ("test_double is %f\n", foo);
|
|
|
|
|
|
|
|
d = [NSDate date];
|
|
|
|
printf ("time interval since now %f\n", [d timeIntervalSinceNow]);
|
|
|
|
|
|
|
|
[NSTimer scheduledTimerWithTimeInterval: 3.0
|
|
|
|
invocation: inv
|
|
|
|
repeats: YES];
|
2002-02-26 10:38:50 +00:00
|
|
|
[[NSRunLoop currentRunLoop] run];
|
1998-10-03 05:11:05 +00:00
|
|
|
[arp release];
|
1996-03-19 02:02:52 +00:00
|
|
|
exit (0);
|
|
|
|
}
|