Quantcast

Re: SWIG and CFFI

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SWIG and CFFI

Christoph Egger-4
Christoph Egger schrieb:

> Hi!
>
>   I'm trying to get SWIG running for my lisp environment (currently only
> testing if it works). I created some very basic .[chi] files and rand
> swig -cffi in the .i file. However loading the generated .lisp file
> (load "example.lisp") failed with an hint that there is no siuch thing
> as CFFI.
>
>   I'm running this on Debian testing/unstable/experimental, SWIG is in
> Version 1.3.36 and CFFI is an snapshot from february 2008.
>
>   Is there anything I do wrong? Anyone had swig+cffi running and could
> point me to some basic example?
>
> Thanks
>
>   Christoph
>
Hi!

  Sorry for the noise but I could get this part working with
    (asdf:oos 'asdf:load-op :cffi)
however loading the swig file still warns me about the function being an
«Undefined alien» and I can not call the function from within lisp.

Regards

  Christoph

--
/"\  ASCII Ribbon : GPG-Key ID: 0x0372275D
\ /    Campaign   :
 X   against HTML : Working for Debian
/ \   in eMails   : http://www.debian.org/

http://www.christoph-egger.org/


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user

signature.asc (268 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SWIG and CFFI

Kalyanov Dmitry
On Monday 02 February 2009 00:35:45 Christoph Egger wrote:

> Christoph Egger schrieb:
> > Hi!
> >
> >   I'm trying to get SWIG running for my lisp environment (currently only
> > testing if it works). I created some very basic .[chi] files and rand
> > swig -cffi in the .i file. However loading the generated .lisp file
> > (load "example.lisp") failed with an hint that there is no siuch thing
> > as CFFI.
> >
> >   I'm running this on Debian testing/unstable/experimental, SWIG is in
> > Version 1.3.36 and CFFI is an snapshot from february 2008.
> >
> >   Is there anything I do wrong? Anyone had swig+cffi running and could
> > point me to some basic example?
> >
> > Thanks
> >
> >   Christoph
>
> Hi!
>
>   Sorry for the noise but I could get this part working with
>     (asdf:oos 'asdf:load-op :cffi)
> however loading the swig file still warns me about the function being an
> «Undefined alien» and I can not call the function from within lisp.
>
> Regards
>
>   Christoph
You need to manually add calls to cffi:load-foreign-library (preferably at the
beginning of the file). E.g., add this to .i file:

%insert("lisphead") %{
(defpackage :bare-gtk (:use :cl))
  (in-package :bare-gtk)

(unless (cffi:use-foreign-library "libgtk-x11-2.0.so")
        (error "Library libgtk-x11-2.0.so not loaded"))
%}

If the wrapped library needs some initialization, you should add call to it
after the functions are defined by swig:

%insert("swiglisp") %{
(gtk-init (cffi:foreign-alloc :int :initiial-element 0)
          (cffi:foreign-alloc :string :initial-contents '("/usr/bin/sbcl")))
#+sbcl(sb-ext::set-floating-point-modes :traps nil)
%}

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user

signature.asc (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SWIG and CFFI

Christoph Egger-4
Kalyanov Dmitry schrieb:

> On Monday 02 February 2009 00:35:45 Christoph Egger wrote:
>> Christoph Egger schrieb:
>>> Hi!
>>>
>>>   I'm trying to get SWIG running for my lisp environment (currently only
>>> testing if it works). I created some very basic .[chi] files and rand
>>> swig -cffi in the .i file. However loading the generated .lisp file
>>> (load "example.lisp") failed with an hint that there is no siuch thing
>>> as CFFI.
>>>
>>>   I'm running this on Debian testing/unstable/experimental, SWIG is in
>>> Version 1.3.36 and CFFI is an snapshot from february 2008.
>>>
>>>   Is there anything I do wrong? Anyone had swig+cffi running and could
>>> point me to some basic example?
>>>
>>> Thanks
>>>
>>>   Christoph
>> Hi!
>>
>>   Sorry for the noise but I could get this part working with
>>     (asdf:oos 'asdf:load-op :cffi)
>> however loading the swig file still warns me about the function being an
>> «Undefined alien» and I can not call the function from within lisp.
>>
>> Regards
>>
>>   Christoph
>
> You need to manually add calls to cffi:load-foreign-library (preferably at the
> beginning of the file). E.g., add this to .i file:
>
> %insert("lisphead") %{
> (defpackage :bare-gtk (:use :cl))
>   (in-package :bare-gtk)
>
> (unless (cffi:use-foreign-library "libgtk-x11-2.0.so")
>         (error "Library libgtk-x11-2.0.so not loaded"))
> %}
>
> If the wrapped library needs some initialization, you should add call to it
> after the functions are defined by swig:
>
> %insert("swiglisp") %{
> (gtk-init (cffi:foreign-alloc :int :initiial-element 0)
>           (cffi:foreign-alloc :string :initial-contents '("/usr/bin/sbcl")))
> #+sbcl(sb-ext::set-floating-point-modes :traps nil)
> %}
>
Hi!

  Thank you for this pointer, the basic example does now work. I'll see
if I can use it for something more complex now.

Regards

  Christoph

--
/"\  ASCII Ribbon : GPG-Key ID: 0x0372275D
\ /    Campaign   :
 X   against HTML : Working for Debian
/ \   in eMails   : http://www.debian.org/

http://www.christoph-egger.org/


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user

signature.asc (268 bytes) Download Attachment
Loading...