Hello,
I am using Lisp in a Box, and I try to use a dll with this code:
;; int SetTagValues(char** tagNames , float* tagValues , unsigned int
noTags ) ;
(DEF-CALL-OUT set-tag-values
(:name "SetTagValues")
(:library "robotalk.dll")
(:arguments (tagNames (c-ptr (c-ptr (c-array-max char 32))) :in)
(tagValues (c-array-ptr single-float) :in ) (noTags uint))
(:return-type int)
(:language :stdc))
Executing this is not working:
(set-tag-values '#("Seconds") '#(33.0) 1)
I read the chapter 30.3. Extensions-2.3. The Foreign Function Call
Facility but I am lost.
Could somebody explain me what is wrong or point me to some examples
with array of strings ?
Thanks
Joseph Frippiat
From: Sam Steingold
Subject: Re: looking for FFI examples with CLISP (newbie)
Date:
Message-ID: <u7jifymq1.fsf@gnu.org>
> * Joseph Frippiat <··········@xfg.or> [2005-05-04 14:36:05 +0200]:
>
> ;; int SetTagValues(char** tagNames , float* tagValues , unsigned int
> noTags ) ;
C prototypes do not contain enough information about the arguments.
if this is similar to the standard C main(argc,argv) calling
conventions, then you need something like
(def-call-out set-tag-values
(:name "SetTagValues")
(:library "robotalk.dll")
(:arguments (tagNames (c-array-ptr c-string))
(tagValues (c-array-ptr single-float))
(noTags uint))
(:return-type int)
(:language :stdc))
Jorg Hohle is the preeminent CLISP FFI expert, I hope he will post the
solution when you clearly describe what the arguments are.
in the meantime, take a look at
<http://www.podval.org/~sds/clisp/impnotes/dffi.html#dffi-gethostname>
--
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.honestreporting.com> <http://www.jihadwatch.org/>
<http://www.camera.org> <http://www.iris.org.il> <http://www.dhimmi.com/>
Is there another word for synonym?
robotalk.dll is a library to communicate with the RoboWorks Robotic
Simulator (http://www.newtonium.com/).
Here is the description for the SetTagValues function:
"The folowing function is used to send Tag values to RoboWorks. Tag names
are
user defined names that are assigned to various transformation. By sending
a list
of those names and their associated values, you can control the RoboWorks
model. You can
only call this function after a successful call to the Connect function. "
Pascal Bourguignon already gave me a solution, but I'm interested in any
information / example I can get about FFI for CLISP.
Thanks
"Sam Steingold" <···@gnu.org> wrote in message ··················@gnu.org...
>> * Joseph Frippiat <··········@xfg.or> [2005-05-04 14:36:05 +0200]:
>>
>> ;; int SetTagValues(char** tagNames , float* tagValues , unsigned int
>> noTags ) ;
>
> C prototypes do not contain enough information about the arguments.
> if this is similar to the standard C main(argc,argv) calling
> conventions, then you need something like
>
> (def-call-out set-tag-values
> (:name "SetTagValues")
> (:library "robotalk.dll")
> (:arguments (tagNames (c-array-ptr c-string))
> (tagValues (c-array-ptr single-float))
> (noTags uint))
> (:return-type int)
> (:language :stdc))
>
> Jorg Hohle is the preeminent CLISP FFI expert, I hope he will post the
> solution when you clearly describe what the arguments are.
>
> in the meantime, take a look at
> <http://www.podval.org/~sds/clisp/impnotes/dffi.html#dffi-gethostname>
>
> --
> Sam Steingold (http://www.podval.org/~sds) running w2k
> <http://www.honestreporting.com> <http://www.jihadwatch.org/>
> <http://www.camera.org> <http://www.iris.org.il> <http://www.dhimmi.com/>
> Is there another word for synonym?
From: Sam Steingold
Subject: Re: looking for FFI examples with CLISP (newbie)
Date:
Message-ID: <uwtqewv84.fsf@gnu.org>
> * Joseph Frippiat <···············@fxlarg.or> [2005-05-04 20:29:52 +0200]:
>
> Pascal Bourguignon already gave me a solution,
I think my solution is identical to his
> but I'm interested in any information / example I can get about FFI
> for CLISP.
you specific example is almost identical to this one:
<http://www.podval.org/~sds/clisp/impnotes/dffi.html#ex-dffi-float>
--
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://pmw.org.il/> <http://www.mideasttruth.com/>
<http://www.iris.org.il> <http://www.palestinefacts.org/> <http://ffii.org/>
Sinners can repent, but stupid is forever.
"Joseph Frippiat" <···············@skynet.be> writes:
> "Sam Steingold" <···@gnu.org> wrote in message ··················@gnu.org...
>>> * Joseph Frippiat <··········@xfg.or> [2005-05-04 14:36:05 +0200]:
>>>
>>> ;; int SetTagValues(char** tagNames , float* tagValues , unsigned int
>>> noTags ) ;
>>
>> C prototypes do not contain enough information about the arguments.
>> if this is similar to the standard C main(argc,argv) calling
>> conventions, then you need something like
>>
>> (def-call-out set-tag-values
>> (:name "SetTagValues")
>> (:library "robotalk.dll")
>> (:arguments (tagNames (c-array-ptr c-string))
>> (tagValues (c-array-ptr single-float))
>> (noTags uint))
>> (:return-type int)
>> (:language :stdc))
>>
>> Jorg Hohle is the preeminent CLISP FFI expert, I hope he will post the
>> solution when you clearly describe what the arguments are.
>>
>> in the meantime, take a look at
>> <http://www.podval.org/~sds/clisp/impnotes/dffi.html#dffi-gethostname>
>
> robotalk.dll is a library to communicate with the RoboWorks Robotic
> Simulator (http://www.newtonium.com/).
> Here is the description for the SetTagValues function:
>
> "The folowing function is used to send Tag values to RoboWorks. Tag names
> are
> user defined names that are assigned to various transformation. By sending
> a list
> of those names and their associated values, you can control the RoboWorks
> model. You can
> only call this function after a successful call to the Connect function. "
>
> Pascal Bourguignon already gave me a solution, but I'm interested in any
> information / example I can get about FFI for CLISP.
>
> Thanks
Note that what Sam wrote is correct: in general, the C prototype is
not enough to define precisely the API.
That's why I provided an implementation which I _guess_ matched what
it was, given the sematics *I* attached to the name SetTagValue and
the names of the arguments, with the help of your example.
What if you did not give the example and I had written:
int SetTagValues(char** tagNames,float* tagValues,unsigned int noTags){
if(noTags){
(*tagNames)=0;
(*tagValues)=0;
}else{
(*tagNames)=(char*)malloc(32);
strcpy((*tagNames),"Beeblebrox");
(*tagValues)=0.517693119;
}
return(0);
}
Then for the same C prototype, you'd have to write a different
:argument list. And there are more possibilities.
--
__Pascal Bourguignon__ http://www.informatimago.com/
Small brave carnivores
Kill pine cones and mosquitoes
Fear vacuum cleaner
Joseph Frippiat <··········@kst.be> writes:
> Hello,
>
> I am using Lisp in a Box, and I try to use a dll with this code:
>
> ;; int SetTagValues(char** tagNames , float* tagValues , unsigned
> int noTags ) ;
> (DEF-CALL-OUT set-tag-values
> (:name "SetTagValues")
> (:library "robotalk.dll")
> (:arguments (tagNames (c-ptr (c-ptr (c-array-max char 32))) :in)
> (tagValues (c-array-ptr single-float) :in ) (noTags uint))
> (:return-type int)
> (:language :stdc))
>
> Executing this is not working:
>
> (set-tag-values '#("Seconds") '#(33.0) 1)
>
> I read the chapter 30.3. Extensions-2.3. The Foreign Function Call
> Facility but I am lost.
Yes, me too most of the time ;-)
> Could somebody explain me what is wrong or point me to some examples
> with array of strings ?
[27]> (ffi:DEF-CALL-OUT set-tag-values
(:name "SetTagValues")
(:library "./libppa.so")
(:arguments
(tagNames (ffi:c-array-ptr ffi:c-string) :in)
(tagValues (ffi:c-array-ptr single-float) :in )
(noTags ffi:uint))
(:return-type ffi:int)
(:language :stdc))
SET-TAG-VALUES
[28]> (set-tag-values '#("Seconds" "Minutes" "Hour") '#(33.0 15.0 12.0) 3)
Seconds = 33.000000
Minutes = 15.000000
Hour = 12.000000
0
[29]> (cat "ppa-lib.c")
#include <stdio.h>
int SetTagValues(char** tagNames,float* tagValues,unsigned int noTags)
{
int i;
for(i=0;i<noTags;i++){
printf("%32s = %f\n",tagNames[i],tagValues[i]);}
return(0);}
[30]> (cat "Makefile")
all:libppa.so
ppa-lib.o:ppa-lib.c
$(CC) -shared -fPIC -g -O3 -c -o ·@ $<
libppa.so:ppa-lib.o
$(LD) -shared -fPIC -g -o ·@ $<
--
__Pascal Bourguignon__ http://www.informatimago.com/