Last active
February 5, 2022 21:52
-
-
Save theoknock/76cbed7470d146e9d351a30590f64b9a to your computer and use it in GitHub Desktop.
Bitwise branching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static long (^(^animate)(long))(void(^__strong)(long *)) = ^ (long duration) { | |
__block typeof(CADisplayLink *) display_link; | |
__block long frames = duration; | |
return ^ long (void (^__strong animator)(long *)) { | |
display_link = [CADisplayLink displayLinkWithTarget:^{ | |
frames >>= 01; | |
return | |
((frames & 01) && | |
^ long { | |
animator(&frames); | |
return active_component_bit_vector; | |
}()) | |
|| | |
((frames | 01) && | |
^ long { | |
printf("COMPLETE\n"); | |
[display_link invalidate]; | |
return active_component_bit_vector; | |
}()); | |
} selector:@selector(invoke)]; | |
[display_link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; | |
return active_component_bit_vector; | |
}; | |
}; | |
/* | |
*/ | |
animate(30)(^ (long * frame) { | |
printf("%ld\n", *frame); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment