chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] FFI and references


From: Joel Reymont
Subject: Re: [Chicken-users] FFI and references
Date: Mon, 3 Jan 2005 15:47:46 +0000

> felix winkelmann wrote:

>This is likely to break. getPixel returns a color instance,
>but the result-value unmarshalling will take it's address and return a
>pointer,
>which (AFAIK) would on return from the wrapper procedure be deallocated.
>Does getPixel return a true instance or a reference? Actually the
>C++ compiler should complain in both cases.

The following works just fine provided that you pass (slot-ref 'this
color) into print-color:

(declare (unit foo))
(declare (uses tinyclos)
         (uses color))

#>
#include "color.hpp"

extern void print_color(const color& c);

<# 

(define-foreign-type color (ref "color"))

(define print-color (foreign-lambda void "print_color"
                                    color))

    Joel

-- 
OpenPoker: The Linux of poker software
http://wagerlabs.com/forums
* Tenerife * Canary Islands * Spain





reply via email to

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