chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] easyffi c++ passing object pointers


From: felix
Subject: Re: [Chicken-users] easyffi c++ passing object pointers
Date: Wed, 05 Nov 2003 19:53:32 +0100
User-agent: Opera7.11/Linux M2 build 406

On Tue, 04 Nov 2003 21:07:50 -0500, Dave <address@hidden> wrote:

Hello,
How can I take pointers to objects that were created in C++, pass them via an entry point, and manipulate them as tinyclos objects? Examples exist for using c++ objects that are created by scheme and even pulling a pointer from the tinyclos object, but I cannot figure out how to turn this around. Here's one of my abortive attempts:

#>!
class ClientApp
{
public:
bool ChickenCallin(char *helo);

};
<#
;;; INITIALIZE
(define-entry-point 1
((a (pointer <ClientApp>)))
(int)
(print "Got client pointer")
(print a)
(print (ChickenCallin a "bing"))
1)



Argh. I didn't think of this. It's currently not really possible
to create a TinyCLOS instance from a C++ pointer. Thanks for pointing
this out! I have now implemented the following (slightly crude) method: the
initargs for the invocation of `make' can alternatively be the symbol 'this
followed by a pointer, so you would have something like this:

(define-entry-point 1 ((ptr c-pointer)) (int)
 (let ([a (make <ClientApp> 'this a)])
   (print (ChickenCallin a "bing"))
   1) )

Normally the initargs are passed to the C++ constructor. If 'this
is given, the C++ constructor will not be invoked.

I'll check this in the CVS in a few moments.


cheers,
felix





reply via email to

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