[cffi-devel] What do i do with a c "bool" return type

Joeish W joeish80829 at yahoo.com
Mon Nov 18 15:56:27 UTC 2013


Here is the function im wrapping a c wrapper for a c++ opencv function and below it my wrapper


bool cv_VideoCapture_isOpened0(VideoCapture* self) {
    return self->isOpened();
}

(cffi:defcfun ("cv_VideoCapture_isOpened0" %vid-cap-cam-is-open) :pointer
  (self (:pointer video-capture)))

not sure how to call the bool return type, the below defun didnt work using pointer for return type or int on defcfun  and casting from boolean inside the defun below with (convert-from-foreign ,var :boolean).  when i used a pointer return type, as swig wraps it i mem-refed or mem-arefed the defcun as :int in my defun below


(defun video-cap-cam-is-open (self)
(convert-from-foreign (%video-cap-cam-is-open self) :boolean))

in c++ the cout output of the functions im wrapping are 1 for the first one and 0 for the one after cap.release(); is called

  cout << "a =" << cap.isOpened(); = 1
    cap.release();
    cout << "b = " << cap.isOpened(); = 0

function documentation for function im wrapping is here

http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=videoca#void%20VideoCapture::release()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20131118/3b81774e/attachment.html>


More information about the cffi-devel mailing list