[Openmcl-devel] CCL <-> C++ interface generator in alpha, reviewers wanted

Jason E. Aten j.e.aten at gmail.com
Thu Apr 14 22:14:36 PDT 2011


On Wed, Apr 13, 2011 at 11:29 AM, <dherring at tentpost.com> wrote:

> P.S.  We have veered far from CCL-specific issues.  A better list may be
> cffi-devel.
> http://common-lisp.net/mailman/listinfo/cffi-devel
>


Daniel - thanks for the pointer to the CFFI list.

All - I put the code for the new CFFI swig module, developed with/for CCL,
on github. If you would like to try it and provide feedback, that would be
welcome. Installation and testing would be as simple as (assuming you have
CFFI and ccl already installed) the following three lines. I'll attach a
brief sample of the generated code, which follows Ron and Daniel's
suggestions (thanks again!).

$ git clone
https://github.com/glycerine/swig-cpp-to-cffi-for-common-lisp-enhancements
      # (Then make sure ccl is on your path so configure can detect it;
and...)
$ cd swig-cpp-to-cffi-for-common-lisp-enhancements/swig; ./autogen.sh;
configure; make install
$ cd Example/cffi/overctor; make; make test

Best,
Jason

// sample C++ class (in overctor.h)

class Vlad {
public:
  Vlad(int intref, char* charstar, double dub);
  Vlad(int intref, char* charstar, char* string2);
  Vlad(int intref, char* charstar);
  Vlad(int intval);
  Vlad();

  int equals(int intval);
  int equals();
  static int equals(int intval, double dub);
  static int equals(double dub);
};


;;; sample generated dispatcher: (see overctor-clos.lisp file for full set
of declarations)

(cl:defmethod initialize-instance
     :after ((obj Vlad)
             &key
             (charstar)
             (dub)
             (intref)
             (intval)
             (string2)
             )
    (cond ((and             ;; <- no arg ctor -- zero *required*  keyword
param
           (and (not (or   charstar dub intref intval string2 ;; <-
*forbidden* keyword param
                                                ))))
           (setf (slot-value obj 'ff-pointer)  (new_Vlad__SWIG_4 )))

          ((and            intval ;; <- *required*  keyword param
           (and (not (or   charstar dub intref string2 ;; <- *forbidden*
keyword param
                                                ))))
           (setf (slot-value obj 'ff-pointer)  (new_Vlad__SWIG_3  intval)))

          ((and            charstar intref ;; <- *required*  keyword param
           (and (not (or   dub intval string2 ;; <- *forbidden* keyword
param
                                                ))))
           (setf (slot-value obj 'ff-pointer)  (new_Vlad__SWIG_2  intref
charstar)))

          ((and            charstar dub intref ;; <- *required*  keyword
param
           (and (not (or   intval string2 ;; <- *forbidden* keyword param
                                                ))))
           (setf (slot-value obj 'ff-pointer)  (new_Vlad__SWIG_0  intref
charstar dub)))

          ((and            charstar intref string2 ;; <- *required*  keyword
param
           (and (not (or   dub intval ;; <- *forbidden* keyword param
                                                ))))
           (setf (slot-value obj 'ff-pointer)  (new_Vlad__SWIG_1  intref
charstar string2)))

          (t (error "no C++ constructor for class 'Vlad' matched your
combination of keyword parameters"))))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20110415/8da4b3a3/attachment.htm>


More information about the Openmcl-devel mailing list