chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Passing C pointers into C++ code


From: John Lenz
Subject: Re: [Chicken-users] Passing C pointers into C++ code
Date: Sun, 19 Dec 2004 19:41:34 +0000

On 12/19/04 04:15:09, felix winkelmann wrote:
On Thu, 16 Dec 2004 21:52:52 +0000, Joel Reymont <address@hidden> wrote:
> Folks,
>
> I'm trying to pass a C pointer into a C++ function. This is what I get:
>
> (setTarget graphics (slot-ref screen 'swig-this))
>
> Error: (class-of) can not compute class of primitive object: #<SWIG-
> pointer 163c4a0>
>
> What does this mean?
>

TinyCLOS currently doesn't know about swig-pointers. I'll fix
this. `setTarget' looks like a generic function, so it want's to compute
the
class of the argument values to dispatch to the proper method.



Yeah, the guile module is able to extract the SWIG pointer from the wrapped proxy class, but I am not sure how to do it for chicken. Basicly, in the function that accepts a SWIG pointer, we need to do something like (this is what the guile module does)

if (arg is tinyclos class) {
 arg = (slot-ref arg 'swig-this)
}

if (arg is SWIG pointer) {
 ... whatever
}

The problem is, is there any way to access (slot-ref arg 'swig-this) from C code? The only way I could think of to do it is to use a callback. That is, inside the SWIG generated scheme file do something like

(Foo-registerswighelperfunction (lambda (x) (if (slot-ref x 'swig-this))) or better yet (lambda (x) (if (instance? x) (if (memq? 'swig-this (class-slots (class-of x))) (slot-ref x 'swig-this) x) x))

Just for reference, here is my response to the original question on the SWIG mailing list.
http://mailman.cs.uchicago.edu/pipermail/swig/2004-December/011208.html





reply via email to

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