[racket-users] async-apply in FFI not being called

2019-05-09 Thread Андрей Кравчук
Hello.
I'm trying to fix SDL2 library bindings for Racket. The library includes 
the function SDL_AddTimer, which, according to documentation, takes 
callback and runs it in another thread. Without #:async-apply keyword on 
FFI callback definition the call to SDL_AddTimer segfaults, which is to be 
expected. Adding #:async-apply fixes the crash, but in that case it seems 
that the callback is not being called (and even async-apply helper itself).
Here's the code:

(define (async-apply thunk)
(displayln "in async-apply")  ;; never gets called
(thunk))

(define _SDL_TimerCallback (_fun #:async-apply async-apply _uint32 _pointer 
-> _uint32))

(define-sdl2 SDL_AddTimer (_fun _uint32 _SDL_TimerCallback _pointer -> 
_int))

(SDL_AddTimer
  1000
 (lambda (interval dummy)
 (displayln "in callback")  ;; never gets called
 1000)
 #f)

(sleep 10)

Could someone please point me at what am I doing wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/0cc49a07-c070-4636-8901-a13ae5a47e6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Packed struct in FFI

2019-05-06 Thread Андрей Кравчук
Ohh, how could I miss it. Thanks a lot!

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Packed struct in FFI

2019-05-06 Thread Андрей Кравчук
Hello!
I'm writing bindings for C library that contains some struct declared 
with __attribute__((packed)). How do I mirror such struct in the bindings? 
I wasn't been able to find any reference to packed structs in FFI 
documentation.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.