On Sat, Jun 30, 2012 at 6:15 PM, Eric Schulte eric.schulte@gmx.com wrote:
(cffi:defcstruct CXCursor (kind CXCursorKind) (xdata :int) (data :pointer)) ;; ... (cffi:defcfun ("clang_getTranslationUnitCursor" clang_getTranslationUnitCursor) CXCursor (arg0 :pointer))
IIUC, this is the problem: clang_getTranslationUnitCursor() returns a structure by value, but SWIG has erroneously declared it to return a structure by reference. (If you have the chance, please report this bug to the SWIG maintainers, or if there's no one maintaining SWIG's CFFI backend, you can report it at CFFI's bugtracker.)
If you grab CFFI from its git repository, you'll find a new system called "cffi-libffii" which implements the passing of structures by value. (The syntax in this case would be (defcfun ... (:struct CXCursor) ...).) Let us know if you have trouble using it.
HTH,