[Cffi-devel] How to convert a c++ vector to lisp vector
Joeish W
joeish80829 at yahoo.com
Fri Apr 25 11:25:35 UTC 2014
I have these C bindings for the C++ vector which I have wrapped in CFFI. I know how to create vectors with std_carrayTovector and convert the data back to a int pointer with std_vectorToCArray so that I can retrieve data from it in Lisp using the CFFI function
MEM-AREF. I have correct defcfuns written for the below . My question
is how to I convert the output of my defcfun for std_vectorToCArray at the bottom of the page, into a Lisp vector eg #(1 2 3) and make it a 0(1) operation/all data copied at the same time.
vector_int*std_carrayTovector(int*a,size_tlen){vector<int>*v =newvector<int>;for(size_ti =0;i <len;i++)v->push_back(a[i]);returnv;}int*std_vectorToCArray(vector_int*s){returns->data();}(defcfun ("std_vectori_to_carray"%vector-int-to-c-array):pointer (s (:pointer vector-int)))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20140425/fc432a9c/attachment.html>
More information about the cffi-devel
mailing list