[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] #<invalid forwarded object> using FFI callback

From: pluijzer .
Subject: Re: [Chicken-users] #<invalid forwarded object> using FFI callback
Date: Sat, 21 Dec 2013 19:07:33 +0100

Hello Alyn,

Thank you for the extra info.

For my sitituation, which is a little different to yours I think, a work
aroundt he issue at the moment by wrapping the scheme-object around a
structure that contains a root node.

I do not know how appropriate or convinient this is to your situation.


typedef struct
    void* node;
} Object;

(define make-object
  (foreign-lambda* (c-pointer "Object") ((scheme-object value)) "
    Object* object = malloc(sizeof(Object));
    object->node = CHICKEN_new_gc_root();
    CHICKEN_gc_root_set(object->node, value);
    C_return( object );"))

(define read-object
  (foreign-lambda* scheme-object (((c-pointer "Object") object)) "
    C_return( CHICKEN_gc_root_ref(object->node) );"))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]