Hello pluijzer
As i know chicken didnt have pass-by-value FFI type.
This is little bit verbose workaround. Note that you should use
foreign-safe-lambda for callbacks from C.
(import scheme chicken foreign)
#>
typedef struct { int x, y; } Point;
typedef void (*SomeCallbackFuncType)(Point point);
void someFunc(SomeCallbackFuncType callback)
{
Point p = {1, 1};
callback(p);
}
static void callbackFunctionJumper(Point point)
{
callbackFunction(&point);
}
<#
(define-external (callbackFunction (c-pointer point))
void
(print "Hello from callback!"))
((foreign-safe-lambda* void () "someFunc(callbackFunctionJumper);"))
Hello chickeners,
I am trying to wrap a function that accepts a function pointer with an
argument to a struct passed by value.
I don't know how to do this (and fear it is not possible) but maybe
somebody else has a solution.
A little example of what I mean:
----
#>
typedef struct { int x, y; } Point;
typedef void (*SomeCallbackFuncType)(Point point);
void someFunc(SomeCallbackFuncType callback)
{
Point p = {1, 1};
callback(p);
}
<#
(define-external (callbackFunction (??? point))
void
(print "Hello from callback!"))
((foreign-lambda void "someFunc" c-pointer) #$callbackFunction)
----
I don't actually need the the value of the object in my callback.
Maybe that helps.
Thank you in advance,
Pluijzer
_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users
_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users