...or how to get Lisp size of class instance, and override the GC memory allocator?...<br><br>Details:  I'm working interfacing CCL code to a large pre-established code source in C++.  Is there a standard means to do this, or can somebody recommend an approach that works?<br>
<br>Here's the backgorund, and a description of where I'm stuck right now.  I really like Clozure's h-to-ffi.sh and CDB database mechanism, but (please correct me if I'm wrong), this only applies to C code. I could not find switches to get it to also handle C++.<br>
<br>So next I've been trying SWIG, which uses CFFI and automatically generates extern "C" wrappers for C++ classes. Then I can link the SWIG wrapper C functions and the original C++ code into a shared object and dynamically loaded with (open-shared-library <file> ).<br>
<br>In addition, SWIG seems to automatically generate a .lisp file with defclass declarations. i.e. this declaration in a testlib.h file<br><br>class CDemo {<br> public:<br>  double b;<br>};<br><br>when run with "swig -c++ -cffi" produces this declaration in testlib-clos.lisp, using swig 2.0.2.  CCL<br>
 <br>(cl:defclass cdemo()<br>  ((ff-pointer :reader ff-pointer)))<br><br>Now to where I'm stuck, and probably because I'm new to CLOS.  I read section 12.11 of the CCL manual, and realize that I need to use (make-heap-ivector) to allocate these CLOS bridge objects on.<br>
<br>But how do I figure out the size of a class instance, so I know how many bytes to ask make-heap-ivector for?  And then, where would I override the default allocation mechanism to use make-heap-ivector instead?<br><br>
Of course, if there are better approaches, I'm totally open to hearing them.<br><br>Thank you.<br><br>Jason<br><br> Clozure Common Lisp Version 1.7-dev-r14684M-trunk  (Linuxx8664)<br>