(module cbtest () (import scheme) (import chicken.base) (import chicken.string) (import chicken.format) (import chicken.foreign) (import chicken.memory) (import object-evict) ; so this is a generic wrapper that converts a fn/arg pointer and calls one on the other ; if I stick a vector in the args then it can just setbang stuff in it between cycles ig (define-external (cb_wrapper2 (c-pointer v)) void (let ((f/a (pointer->object v))) (apply (car f/a) (cdr f/a)))) ; reexpose the name to scheme (define-foreign-variable cb-wrapper2 (function void (c-pointer)) "cb_wrapper2") ; this sorta simulates nng-aio-alloc. ie, a scheme wrapper on a c function that accepts a c callback ; so this takes the cb_wrapper2 function and address of a pair of scheme function and args ; in theory if we can execute in here it'd work in an aio too (define mk-aio (foreign-safe-lambda* void (((function void (c-pointer)) fn) (c-pointer arg)) "fn(arg);")) ; and then this simulates external interface (define (create-aio fn . args) (let ((f/a (object-evict (cons fn args)))) (mk-aio cb-wrapper2 (object->pointer f/a)))) (define (testfn s n) (printf "maztest: ~S ~S\n" s n)) (define (main) (create-aio testfn "hi" 1) (exit 0)) (main) )