Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Martin Simmons <martin <at> lispworks.com>
Subject: Re: Passing Lisp objects to through the FLI?
Newsgroups: gmane.lisp.lispworks.general
Date: Wednesday 12th November 2008 17:19:48 UTC (over 8 years ago)
>>>>> On Tue, 11 Nov 2008 12:59:12 -0800, massung  said:
> 
> Is it possible to pass a Lisp object (not a foreign object or a simple  
> literal ala fixnum/string) to a foreign function and be returned later? I
 
> assume the big concern would be the garbage collector moving (or even  
> releasing) the memory for the Lisp object, but perhaps #'in-static-area
can  
> help here?
> 
> Basically, there are some functions I'd like to call that accept a void* 

> for user data. It would be incredibly convenient if I could send a
specific  
> or class instance or struct through the user data and get it back later
via  
> another foreign function call.
> 
> Is that doable somehow? Or, if someone knows a another method, I'm all  
> ears. ;-)

The only kinds of Lisp object that are safe to pass directly to C are
static
arrays (see http://www.lispworks.com/documentation/lw51/FLI/html/fli-130.htm
and http://www.lispworks.com/documentation/lw51/FLI/html/fli-152.htm
for ways
to do that).

For other objects, you need to pass a handle, e.g. an integer with a lookup
table as suggested by Luke.

-- 
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/
 
CD: 10ms