Permalink
Browse files

Fixed timer scripts.

  • Loading branch information...
1 parent faf771a commit 8bac57074c3fc607d44b038d7000203c99d1600b @mmower committed Nov 2, 2008
Showing with 47 additions and 6 deletions.
  1. +37 −0 Elysium.bridgesupport
  2. +0 −2 src/scripting/ELScriptPackage.m
  3. +2 −0 src/scripting/ELTimerCallback.h
  4. +8 −4 src/scripting/ELTimerCallback.m
View
@@ -32,4 +32,41 @@
</method>
</class>
+
+ <class name='ELScriptPackage'>
+
+ <method selector='f1'>
+ <retval type='B'/>
+ </method>
+
+ <method selector='setF1'>
+ <arg type='B' index='0'/>
+ </method>
+
+ <method selector='f2'>
+ <retval type='B'/>
+ </method>
+
+ <method selector='setF2'>
+ <arg type='B' index='0'/>
+ </method>
+
+ <method selector='f3'>
+ <retval type='B'/>
+ </method>
+
+ <method selector='setF3'>
+ <arg type='B' index='0'/>
+ </method>
+
+ <method selector='f4'>
+ <retval type='B'/>
+ </method>
+
+ <method selector='setF4'>
+ <arg type='B' index='0'/>
+ </method>
+
+ </class>
+
</signatures>
@@ -31,8 +31,6 @@ - (id)initWithPlayer:(ELPlayer *)_player_ {
}
}
- NSLog( @"Timer 1 interval = %f", [timer[0] interval] );
-
return self;
}
@@ -28,4 +28,6 @@
@property (readonly) RubyBlock *callback;
@property (assign) ELPlayer *player;
+- (void)runCallback:(NSTimer *)_timer_;
+
@end
@@ -37,13 +37,17 @@ - (id)initWithPlayer:(ELPlayer *)_player_ {
- (void)observeValueForKeyPath:(NSString *)_keyPath_ ofObject:(id)_object_ change:(NSDictionary *)_change_ context:(id)_context_ {
if( [_keyPath_ isEqualToString:@"active"] ) {
- timer = [NSTimer timerWithTimeInterval:[self interval] target:self selector:@selector(run) userInfo:nil repeats:YES];
- } else {
- [timer invalidate];
+ if( [self active] ) {
+ timer = [NSTimer timerWithTimeInterval:[self interval] target:self selector:@selector(runCallback:) userInfo:nil repeats:YES];
+ [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
+ } else {
+ [timer invalidate];
+ }
}
}
-- (void)run {
+- (void)runCallback:(NSTimer *)_timer_ {
+ NSLog( @"Timer has fired." );
[callback evalWithArg:[self player] arg:self];
}

0 comments on commit 8bac570

Please sign in to comment.