If anyone is interested in C++ interfaces from CCL, please read on.<br><br>I've finished modernizing (a nice word for hacking the heck out of) the CFFI module SWIG to wrap my large-ish C++ codebase so that I can call it and test it from CCL. I can't submit my changes back to SWIG without writing a bunch of runtime tests for William the maintainer; those tests  have yet to be written.  And I'd rather eat my own dogfood for a while to iron out any latent bugs.  Nonetheless, everything compiles and the resulting plugins load cleanly without manual code changes, which was my goal. So while it isn't publicly available, I would like to have it reviewed for obvious blunders (quite likely since I'm new to CL).<br>

<br>That is, I'd appreciate having a more experienced Lisper's perspective on the design while the metal is still hot and maleable.<br><br>If you are interested in trying the new cffi.cxx or reviewing the auto-generated Lisp interface, please contact me off list.  Even cursory feedback would be appreciated.  I'll paste a micro example below.<br>

<br>Thank you.<br><br>Jason<br clear="all"><br>---<br>A micro example of calling into arity-overloaded C++ methods from lisp:<br><br>;;;;;;;;;;;;;;;; file:  <a href="http://micro_test.cl">micro_test.cl</a>  (adapt the path in the :cd command as appropriate)  ;;;;;;;;;;;;;;;;;;;;;<br>
<br>(eval-when (:execute :load-toplevel :compile-toplevel)<br>(require :cffi))<br><br>(cl:defpackage :micro<br>  (:shadowing-import-from :cffi :defcallback)<br>  (:use :cl :ccl :cffi))<br>(in-package :micro)<br><br><br>(:cd "/home/jaten/dj/micro")<br>
(ccl:open-shared-library "/home/jaten/dj/micro/micro.so")<br><br>(load (compile-file "micro.lisp")); :print nil :verbose nil)<br>(load (compile-file "micro-clos.lisp"))<br><br>(setf m (make-instance 'MicroTestCppClass))<br>
<br>;;<br>;; Demonstrate calls to methods that are overloaded with different arity in C++.<br>;; Since Common Lisp doesn't support method overloading (apparently,<br>;; please correct me if I've misunderstood the comments at the bottom of<br>
;; page 194 of Practical Common Lisp), I had to give<br>;; each of these guys a differnt name/symbol...<br>;;<br>(method_MicroTestCppClass_cpp_overloaded_method0 m)<br>;;; output:<br>; 8<br>; <br>(method_MicroTestCppClass_cpp_overloaded_method1 m 10)<br>
;;; output:<br>; In MicroTestCppClass::cpp_overloaded_method : returning your argument plus 9<br>; 19<br><br>;;;;;;;;;;;;;;;; file:  micro.h   ;;;;;;;;;;;;;;;;;;;;;<br><br>#ifndef MICRO_H<br>#define  MICRO_H<br><br>#include <stdio.h><br>
<br>class MicroTestCppClass {<br><br>public:<br>  int cpp_overloaded_method();<br>  int cpp_overloaded_method(int an_int_argument);<br><br>};<br><br>#endif // MICRO_H<br><br>;;;;;;;;;;;;;;;; file:  micro.i   ;;;;;;;;;;;;;;;;;;;;;<br>
<br>%module micro<br><br>%{<br> #include "micro.h"<br>%}<br><br>%feature("export");<br><br>%include "micro.h"<br><br><br><br>;;;;;;;;;;;;;;;; file:  micro.cpp   ;;;;;;;;;;;;;;;;;;;;;<br><br>#include <stdio.h><br>
#include "micro.h"<br><br>int MicroTestCppClass::cpp_overloaded_method() {<br>  printf("\n In MicroTestCppClass::cpp_overloaded_method : returning 8\n"); <br>  return 8; <br>}<br><br>int MicroTestCppClass::cpp_overloaded_method(int an_int_argument) {<br>
  printf("\n In MicroTestCppClass::cpp_overloaded_method : returning your argument plus 9\n"); <br>  return an_int_argument + 9; <br>}<br><br><br>;;;;;;;;;;;;;;;; file:  Makefile   ;;;;;;;;;;;;;;;;;;;;;<br><br>all: micro<br>
<br>micro:<br>    swig -cffi -c++  micro.i<br>    g++ -c micro_wrap.cxx -fpic -o micro_wrap.o<br>    g++ -c micro.cpp      -fpic -o micro.o<br>    g++ -shared micro.o micro_wrap.o -o micro.so<br><br>test:<br>    ccl < <a href="http://micro_test.cl">micro_test.cl</a><br>
<br><br>clean:<br>    rm -f *.o micro_wrap.cxx micro-clos.lisp micro.lisp micro.so *.lx64fsl *~<br><br><br>