From: Kenny Tilton
Subject: Calling all binders
Date: 
Message-ID: <mIETe.1$Ap4.3980@twister.nyc.rr.com>
The cracking sound you hear is half of common-lisp.net breaking off and 
falling into the sea. The half being those projects dedicated to 
providing bindings to C/C++ libraries -- I just converted my cl-openal 
package to use CFFI bindings generated automatically by Verrazano (VZN).

CFFI: http://common-lisp.net/project/cffi/

But you have to get the cffi-luis branch (and you have to use darcs). As 
for VZN:

      http://common-lisp.net/project/fetter/

In my cl-openal package I replaced the bindings with:

(defbinding "openal-library"
     (nicknames "al")
   (flags "")
   (include
    "AL/al.h"
    "AL/alc.h"
    "AL/alut.h")
   (export
    "aluint" "alenum" "albyte" "alsizei" "alboolean"
    "alint" "alfloat" "alshort" "alcenum" "alcdevice" "alcubyte"
    "alcvoid" "alcboolean" "alccontext" "alcint" "alcsizei" "alcdouble"
    "alcfloat" "alcuint" "alcushort" "alcshort"
    "alcbyte" "aluint" "alubyte" "aldouble" "alushort"
    "aldisable" "alenable" "alfloat" "alsourcef" "alsourcei"
    "alsourcestop" "alutunloadwav" "al-source-gen" "al-source-free" 
"albufferdata"
    "alutloadwavfile" "algenbuffers" "alsourceplay" "algetsourcei"
    "aldeletesources" "algensources" "alcclosedevice" "alcdestroycontext"
    "alcgetcontextsdevice" "alcgetcurrentcontext" "allistenerfv"
    "algeterror" "alcmakecontextcurrent" "alcopendevice"
    "+al-position+" "+al-velocity+" "+al-orientation+"
    "+al-source-state+" "+al-playing+" "+al-buffer+" "+al-gain+"
    "+al-no-error+"
    "alccreatecontext")
   (override ""))

Sorry about that long export list. I have suggested VZN just export 
everything so we do not have to code that. Anyway, then in my cl-openal 
source I have:

(in-package :verrazano)

(create-binding
  (setup-build "gccxml"
     (make-pathname :device "C"
                    :directory '(:absolute "program files" "acl70")))
  ;;"C:\\0devtools\\verrazano\\testsuite\\openal-win\\openal.binding"
  "C:\\0dev\\cl-openal\\openal-binding.lisp"
  "C:\\0dev\\cl-openal\\openal-library.lisp"
  :cffi-backend
  nil)

The next entry in my project file or a defsystem file pulls in 
openal-library.lisp, which gets re-genned every time the above gets run 
(I think I need an eval-when (compile) or something in there to avoid 
needless regens, though they only take a split second (on OpenAL, a 
small API)

Anyway, it's hellasweet. But I found a bunch of stuff along the way 
which the maintainers of VZN and CFFI promptly addressed, so it would be 
nice if more folks tried porting their projects to CFFI using VZN to 
grease the skids. Warning: the CFFI UFFI-compatibility layer is there 
but not there. You might want to beat up Luis until he cures that. Me, I 
just went with CFFI, but there was not much code to translate.

Eventually I think we should try to standardize on CFFI just to make the 
Lisp world a simpler place. If it needs work, let's do it.

Note that both VZN (Rayiner Hashem) and CFFI-Luis (Luis Oliveira) are 
successful Google Summer of Code projects mentored by Lisp-NYC, so 
thanks, Google, and congrats to Rayiner and Luis. Thanks also to James 
Bielman, author of CFFI who worked closely with Luis, and maintainers of 
various Lisp implementations who pitched in as well.


-- 
Kenny

Why Lisp? http://lisp.tech.coop/RtL%20Highlight%20Film

"I've wrestled with reality for 35 years, Doctor, and I'm happy to state 
I finally won out over it."
     Elwood P. Dowd, "Harvey", 1950

From: Paolo Amoroso
Subject: Re: Calling all binders
Date: 
Message-ID: <87acin2052.fsf@plato.moon.paoloamoroso.it>
Kenny Tilton <·······@nyc.rr.com> writes:

> The cracking sound you hear is half of common-lisp.net breaking off
> and falling into the sea. The half being those projects dedicated to
> providing bindings to C/C++ libraries -- I just converted my cl-openal

Darn, another chop at line count...


> Eventually I think we should try to standardize on CFFI just to make
> the Lisp world a simpler place. If it needs work, let's do it.

See my signature.


Paolo
-- 
Why Lisp? http://wiki.alu.org/RtL%20Highlight%20Film
Recommended Common Lisp libraries/tools:
- ASDF/ASDF-INSTALL: system building/installation
- CL-PPCRE: regular expressions
- CFFI: Foreign Function Interface
From: Luis Oliveira
Subject: Re: Calling all binders
Date: 
Message-ID: <m2fysfvyy0.fsf@pomajxego.local>
Kenny Tilton <·······@nyc.rr.com> writes:
> But you have to get the cffi-luis branch (and you have to use
> darcs).

I have added a link in the webpage to a directory where I'll upload
snapshots to. No need to use darcs (or wget, etc..).


> [...] Warning: the CFFI UFFI-compatibility layer is
> there but not there. You might want to beat up Luis until he cures
> that.

Hold your horses! :-) I've just fixed what I had broken in
uffi-compat. I also implemented most of the operators that were missing
and added support for UFFI's array type.

I haven't tested uffi-compat much but it passes all tests from UFFI's
test suite under SBCL.

Btw, uffi-compat is faster than the real UFFI on CMUCL/SBCL because CFFI
doesn't use (sb-)alien, which is nice. Ah, and it works with CLISP.

-- 
Luis Oliveira
luismbo (@) gmail (.) com
Equipa Portuguesa do Translation Project
http://www2.iro.umontreal.ca/~pinard/po/registry.cgi?team=pt
From: Andras Simon
Subject: Re: Calling all binders
Date: 
Message-ID: <vcdy866pq6f.fsf@csusza.math.bme.hu>
Luis Oliveira <·············@deadspam.com> writes:

[...] 
> I haven't tested uffi-compat much but it passes all tests from UFFI's
> test suite under SBCL.
> 
> Btw, uffi-compat is faster than the real UFFI on CMUCL/SBCL because CFFI
> doesn't use (sb-)alien, which is nice. Ah, and it works with CLISP.

Awesome!

Do callbacks also work on all supported implementations? If so, then
the hello-c (uffi + callbacks) version of cells-gtk could perhaps be
made to work with clisp without too much pain. (Right now there's a
separate clisp version of cells-gtk.)

Andras
From: Luis Oliveira
Subject: Re: Calling all binders
Date: 
Message-ID: <m27jdqw4ee.fsf@pomajxego.local>
Andras Simon <······@math.bme.hu> writes:
> Do callbacks also work on all supported implementations? If so, then
> the hello-c (uffi + callbacks) version of cells-gtk could perhaps be
> made to work with clisp without too much pain. (Right now there's a
> separate clisp version of cells-gtk.)

Callbacks work under Allegro, Lispworks, Corman Lisp (well, there's some
other issues with this port though), CMUCL, SBCL/x86, CLISP and OpenMCL.
 
In order to get cells-gtk unchanged working with CFFI you'd need a
hello-c-compat. I haven't played with Verrazano yet, but cells-gtk
should probably and use it.

-- 
Luis Oliveira
luismbo (@) gmail (.) com
Equipa Portuguesa do Translation Project
http://www2.iro.umontreal.ca/~pinard/po/registry.cgi?team=pt
From: Kenny Tilton
Subject: Re: Calling all binders
Date: 
Message-ID: <92kUe.30343$%w.982@twister.nyc.rr.com>
Luis Oliveira wrote:
> Andras Simon <······@math.bme.hu> writes:
> 
>>Do callbacks also work on all supported implementations? If so, then
>>the hello-c (uffi + callbacks) version of cells-gtk could perhaps be
>>made to work with clisp without too much pain. (Right now there's a
>>separate clisp version of cells-gtk.)
> 
> 
> Callbacks work under Allegro, Lispworks, Corman Lisp (well, there's some
> other issues with this port though), CMUCL, SBCL/x86, CLISP and OpenMCL.
>  
> In order to get cells-gtk unchanged working with CFFI you'd need a
> hello-c-compat.

Right, but I am converting everything I have to CFFI + the goodies I had 
  added to UFFI (but not the callbacks). That is a package I call 
Hello-CFFI. :) Anyway, I say open up cells-gtk and Just Switch to CFFI.

  I haven't played with Verrazano yet, but cells-gtk
> should probably and use it.
> 

Yep. What I am doing with all my projects is run Verrazano to see if I 
can get a nice set of bindings, then swap those in where mine used to 
be. But I am not going thru cffi-UFFI-compat. May as well move on.

-- 
Kenny

Why Lisp? http://wiki.alu.org/RtL_Highlight_Film

"I've wrestled with reality for 35 years, Doctor, and I'm happy to state 
I finally won out over it."
     Elwood P. Dowd, "Harvey", 1950