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_t len) {
vector<int>* v = new vector<int>;
for(size_t i = 0; i < len; i++)
v->push_back(a[i]);
return v;
}
int* std_vectorToCArray(vector_int* s) {
return s->data();
}
(defcfun ("std_vectori_to_carray" %vector-int-to-c-array) :pointer
(s (:pointer vector-int)))