[Top][All Lists]

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

Re: [Chicken-users] C++ FFI and member variable access

From: Joel Reymont
Subject: Re: [Chicken-users] C++ FFI and member variable access
Date: Mon, 3 Jan 2005 15:36:29 +0000

> Joel Reymont wrote:

>Assuming that I had 
>class foo {
>    int a;
>    int b;
>What FFI code do I need to write to access the member variables? The docs
>say that member variables are ignored.

There's nothing like helping yourself:
(declare (uses tinyclos))

#include "foo.hpp"

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

(define-method (a-ref (foo <foo>))
  (let ((p (slot-ref foo 'this)))
    ((foreign-lambda* integer ((foo f))
                      "return(f.a);") p)))

P.S. Shamelessly stolen from Tony G's SDL code :)

OpenPoker: The Linux of poker software
* Tenerife * Canary Islands * Spain

reply via email to

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