Add words for working with CFTimeInterval and CFAbsoluteDate types

db4
Slava Pestov 2008-12-12 21:06:46 -06:00
parent b3428c61e6
commit 50a78db9bd
2 changed files with 14 additions and 3 deletions

View File

@ -1,6 +1,6 @@
! Copyright (C) 2006, 2008 Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax destructors accessors kernel ;
USING: alien.syntax destructors accessors kernel calendar ;
IN: core-foundation
TYPEDEF: void* CFTypeRef
@ -30,3 +30,10 @@ M: CFRelease-destructor dispose* alien>> CFRelease ;
: |CFRelease ( alien -- alien )
dup f CFRelease-destructor boa |dispose drop ; inline
: >CFTimeInterval ( duration -- interval )
duration>seconds ; inline
: >CFAbsoluteTime ( timestamp -- time )
T{ timestamp { year 2001 } { month 1 } { day 1 } } time-
duration>seconds ; inline

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax system math kernel core-foundation ;
USING: alien.syntax system math kernel core-foundation calendar ;
IN: core-foundation.timers
TYPEDEF: void* CFRunLoopTimerRef
@ -18,12 +18,16 @@ FUNCTION: CFRunLoopTimerRef CFRunLoopTimerCreate (
) ;
: <CFTimer> ( callback -- timer )
[ f millis 1000 /f 60 0 0 ] dip f CFRunLoopTimerCreate ;
[ f now >CFAbsoluteTime 60 0 0 ] dip f CFRunLoopTimerCreate ;
FUNCTION: void CFRunLoopTimerInvalidate (
CFRunLoopTimerRef timer
) ;
FUNCTION: Boolean CFRunLoopTimerIsValid (
CFRunLoopTimerRef timer
) ;
FUNCTION: void CFRunLoopTimerSetNextFireDate (
CFRunLoopTimerRef timer,
CFAbsoluteTime fireDate