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 13:26:17 +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.

One of the functions that I'm trying to wrap:

color getPixel(SDL_Surface* target, int x, int y)

I like the fact that it's returning an instance of the color class (as
opposed to a reference or pointer) as C/C++ compilers have an
optimization for this case. 

Apart from that I also have code like this:

class color {
...
  color& add(const color& c)
  {
    r += c.r;
    g += c.g;
    b += c.b;

    r = (r>255?255:(r<0?0:r));
    g = (g>255?255:(g<0?0:g));
    b = (b>255?255:(b<0?0:b));

    return *this; 
  };
};

This would be very easy to wrap with SWIG but I can't use it with Tony
G's SDL egg. I don't really understand how to define the foreign type for
the color class to be able to pass it around :-(.

    Thanks, 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]