I am using CFFI with ECL to interface to a C++ library, which has a C++ class with a data member of type 'cl_object'. Simplified, my C++ code is:
class LispObject { public: cl_object object; };
extern "C" cl_object getObject(LispObject* lo) { return lo->object; } extern "C" void setObject(LispObject* lo, cl_object clo) { lo->object = clo; }
The full code is:
https://common-lisp.net/viewvc/clive/trunk/src/extensions/corral/CliveCorral...
Can I somehow declare the 'cl_object' type for the 'getValue()' and 'setValue()' functions using CFFI 'defcfun' to get and set ECL objects? Is there a technique using the lower-level FFI? I am looking for a way to do this without compiling C code embedded in Lisp, which I am aware ECL can do.
Thank you for any ideas!
-- Stewart Milberger Kavalogic, Inc.
To clarify, the issue is not with C++, which I am successfully wrapping with C.
The actual issue is using the c_object type in Lisp--if it comes back as a CFFI pointer, how can I use it in Lisp as a Lisp object? Is there something like:
(ffi:pointer-to-lisp-object ptr)
-- Stewart Milberger Kavalogic, Inc.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On July 28, 2018 2:46 PM, Stewart M. sjm-mail@protonmail.com wrote:
I am using CFFI with ECL to interface to a C++ library, which has a C++ class with a data member of type 'cl_object'. Simplified, my C++ code is:
class LispObject { public: cl_object object; };
extern "C" cl_object getObject(LispObject* lo) { return lo->object; } extern "C" void setObject(LispObject* lo, cl_object clo) { lo->object = clo; }
The full code is:
https://common-lisp.net/viewvc/clive/trunk/src/extensions/corral/CliveCorral...
Can I somehow declare the 'cl_object' type for the 'getValue()' and 'setValue()' functions using CFFI 'defcfun' to get and set ECL objects? Is there a technique using the lower-level FFI? I am looking for a way to do this without compiling C code embedded in Lisp, which I am aware ECL can do.
Thank you for any ideas!
-- Stewart Milberger Kavalogic, Inc.
Hi Stewart,
cl_object's are declared as :object type in ECL's ffi, so
(ffi:def-function "getObject" ((lo :pointer-void)) :returning :object) (ffi:def-function "setObject" ((lo :pointer-void) (clo :object)))
should work. CFFI does not support this as far as i know.
Hope that helps, Marius Gerbershagen
Am 29.07.2018 um 00:40 schrieb Stewart M.:
To clarify, the issue is not with C++, which I am successfully wrapping with C.
The actual issue is using the c_object type in Lisp--if it comes back as a CFFI pointer, how can I use it in Lisp as a Lisp object? Is there something like:
(ffi:pointer-to-lisp-object ptr)
-- Stewart Milberger Kavalogic, Inc.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On July 28, 2018 2:46 PM, Stewart M. sjm-mail@protonmail.com wrote:
I am using CFFI with ECL to interface to a C++ library, which has a C++ class with a data member of type 'cl_object'. Simplified, my C++ code is:
class LispObject { public: cl_object object; };
extern "C" cl_object getObject(LispObject* lo) { return lo->object; } extern "C" void setObject(LispObject* lo, cl_object clo) { lo->object = clo; }
The full code is:
https://common-lisp.net/viewvc/clive/trunk/src/extensions/corral/CliveCorral...
Can I somehow declare the 'cl_object' type for the 'getValue()' and 'setValue()' functions using CFFI 'defcfun' to get and set ECL objects? Is there a technique using the lower-level FFI? I am looking for a way to do this without compiling C code embedded in Lisp, which I am aware ECL can do.
Thank you for any ideas!
-- Stewart Milberger Kavalogic, Inc.
I found a link to a similar question:
https://stackoverflow.com/questions/44494613/embeddable-common-lisp-ecl-load...
I was looking for a more direct way.
-- Stewart Milberger Kavalogic, Inc.