Using FFI

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Using FFI

Annick Fron-3

Hi,


I am trying to use FFI on linux with pharo 3 using version 31 of FFI.

I have written the following method :

 <apicall: int 'gst_init_check' (int* char** int*) module: 'libgstreamer1.0-0.so'>

^self externalCallFailed


====

but when accepting it I get a syntax error « matching number of arguments »
Annick Fron
Reply | Threaded
Open this post in threaded view
|

Re: Using FFI

Clément Béra
Hello,

This bug happen both with the old and new compiler.

The error tells you that the number of arguments of your smalltalk method does not match the number of argument of the C method you want to call (but it seemsthe number of arguments is correct).

This works fine:

 <apicall: int 'gst_init_check' (int char* int) module: 'libgstreamer1.0-0.so'>
^self externalCallFailed   

This works fine too:

<apicall: int 'gst_init_check' (int* char* int*) module: 'libgstreamer1.0-0.so'>
^self externalCallFailed   

So it seems the bug comes from the parser missparsing ** . I am not familiar with C enough to help, I don't know what means ** (Is it a pointer pointing to a pointer pointing to the actual data ?). 

Perhaps someone who knows how to use FFI can give a better answer.

Esteban ? Guille ?


2014-07-09 16:39 GMT+02:00 Annick Fron <[hidden email]>:

Hi,


I am trying to use FFI on linux with pharo 3 using version 31 of FFI.

I have written the following method :

 <apicall: int 'gst_init_check' (int* char** int*) module: 'libgstreamer1.0-0.so'>

^self externalCallFailed


====

but when accepting it I get a syntax error « matching number of arguments »
Annick Fron

Reply | Threaded
Open this post in threaded view
|

Re: Using FFI

EstebanLM
yes, FFI does not handle ** arguments. 
I always replace it by ulong instead (it is the same, after all) 

Esteban

On 09 Jul 2014, at 17:17, Clément Bera <[hidden email]> wrote:

Hello,

This bug happen both with the old and new compiler.

The error tells you that the number of arguments of your smalltalk method does not match the number of argument of the C method you want to call (but it seemsthe number of arguments is correct).

This works fine:

 <apicall: int 'gst_init_check' (int char* int) module: 'libgstreamer1.0-0.so'>
^self externalCallFailed   

This works fine too:

<apicall: int 'gst_init_check' (int* char* int*) module: 'libgstreamer1.0-0.so'>
^self externalCallFailed   

So it seems the bug comes from the parser missparsing ** . I am not familiar with C enough to help, I don't know what means ** (Is it a pointer pointing to a pointer pointing to the actual data ?). 

Perhaps someone who knows how to use FFI can give a better answer.

Esteban ? Guille ?


2014-07-09 16:39 GMT+02:00 Annick Fron <[hidden email]>:

Hi,


I am trying to use FFI on linux with pharo 3 using version 31 of FFI.

I have written the following method :

 <apicall: int 'gst_init_check' (int* char** int*) module: 'libgstreamer1.0-0.so'>

^self externalCallFailed


====

but when accepting it I get a syntax error « matching number of arguments »
Annick Fron


Reply | Threaded
Open this post in threaded view
|

Re: Using FFI

Andres Valloud-4
On 64 bit Windows a long is 32 bits and pointers are 64 bits, so that
type of replacement is not going to work in the long run...

On 7/9/14 8:20 , Esteban Lorenzano wrote:

> yes, FFI does not handle ** arguments.
> I always replace it by ulong instead (it is the same, after all)
>
> Esteban
>
> On 09 Jul 2014, at 17:17, Clément Bera <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>> Hello,
>>
>> This bug happen both with the old and new compiler.
>>
>> The error tells you that the number of arguments of your smalltalk
>> method does not match the number of argument of the C method you want
>> to call (but it seemsthe number of arguments is correct).
>>
>> This works fine:
>>
>>  <apicall: int 'gst_init_check' (int char* int) module:
>> 'libgstreamer1.0-0.so <http://libgstreamer1.0-0.so/>'>
>> ^self externalCallFailed
>>
>> This works fine too:
>>
>> <apicall: int 'gst_init_check' (int* char* int*) module:
>> 'libgstreamer1.0-0.so <http://libgstreamer1.0-0.so/>'>
>> ^self externalCallFailed
>>
>> So it seems the bug comes from the parser missparsing ** . I am not
>> familiar with C enough to help, I don't know what means ** (Is it a
>> pointer pointing to a pointer pointing to the actual data ?).
>>
>> Perhaps someone who knows how to use FFI can give a better answer.
>>
>> Esteban ? Guille ?
>>
>>
>> 2014-07-09 16:39 GMT+02:00 Annick Fron <[hidden email]
>> <mailto:[hidden email]>>:
>>
>>
>>           Hi,
>>
>>
>>
>>           I am trying to use FFI on linux with pharo 3 using version
>>           31 of FFI.
>>
>>     I have written the following method :
>>
>>
>>            <apicall: int 'gst_init_check' (int* char** int*) module:
>>           'libgstreamer1.0-0.so <http://libgstreamer1.0-0.so/>'>
>>
>>     ^self externalCallFailed
>>
>>
>>     ====
>>
>>     but when accepting it I get a syntax error « matching number of
>>     arguments »
>>     Annick Fron
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Using FFI

EstebanLM

On 10 Jul 2014, at 02:32, Andres Valloud <[hidden email]> wrote:

> On 64 bit Windows a long is 32 bits and pointers are 64 bits, so that type of replacement is not going to work in the long run…

Of course, but let’s take care about that problem when actually become a problem :)
Hopefully, for when we finally have a 64bits with FFI, we will have a proper ** interpretation, but the workaround is the fastest solution you can have for now.

Esteban

>
> On 7/9/14 8:20 , Esteban Lorenzano wrote:
>> yes, FFI does not handle ** arguments.
>> I always replace it by ulong instead (it is the same, after all)
>>
>> Esteban
>>
>> On 09 Jul 2014, at 17:17, Clément Bera <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>> Hello,
>>>
>>> This bug happen both with the old and new compiler.
>>>
>>> The error tells you that the number of arguments of your smalltalk
>>> method does not match the number of argument of the C method you want
>>> to call (but it seemsthe number of arguments is correct).
>>>
>>> This works fine:
>>>
>>> <apicall: int 'gst_init_check' (int char* int) module:
>>> 'libgstreamer1.0-0.so <http://libgstreamer1.0-0.so/>'>
>>> ^self externalCallFailed
>>>
>>> This works fine too:
>>>
>>> <apicall: int 'gst_init_check' (int* char* int*) module:
>>> 'libgstreamer1.0-0.so <http://libgstreamer1.0-0.so/>'>
>>> ^self externalCallFailed
>>>
>>> So it seems the bug comes from the parser missparsing ** . I am not
>>> familiar with C enough to help, I don't know what means ** (Is it a
>>> pointer pointing to a pointer pointing to the actual data ?).
>>>
>>> Perhaps someone who knows how to use FFI can give a better answer.
>>>
>>> Esteban ? Guille ?
>>>
>>>
>>> 2014-07-09 16:39 GMT+02:00 Annick Fron <[hidden email]
>>> <mailto:[hidden email]>>:
>>>
>>>
>>>          Hi,
>>>
>>>
>>>
>>>          I am trying to use FFI on linux with pharo 3 using version
>>>          31 of FFI.
>>>
>>>    I have written the following method :
>>>
>>>
>>>           <apicall: int 'gst_init_check' (int* char** int*) module:
>>>          'libgstreamer1.0-0.so <http://libgstreamer1.0-0.so/>'>
>>>
>>>    ^self externalCallFailed
>>>
>>>
>>>    ====
>>>
>>>    but when accepting it I get a syntax error « matching number of
>>>    arguments »
>>>    Annick Fron
>>>
>>>
>>
>


Reply | Threaded
Open this post in threaded view
|

MNU: RBParser>>ExternalFunctionDeclaration

Annick Fron-3
In reply to this post by EstebanLM
Hi,

I have made simple trials using the StandardLib.
I get this error :
RBParser does not understand externalFunctionDeclaration.
I might be missing something …

Annick

Le 9 juil. 2014 à 17:20, Esteban Lorenzano <[hidden email]> a écrit :

yes, FFI does not handle ** arguments. 
I always replace it by ulong instead (it is the same, after all) 

Esteban

On 09 Jul 2014, at 17:17, Clément Bera <[hidden email]> wrote:

Hello,

This bug happen both with the old and new compiler.

The error tells you that the number of arguments of your smalltalk method does not match the number of argument of the C method you want to call (but it seemsthe number of arguments is correct).

This works fine:

 <apicall: int 'gst_init_check' (int char* int) module: 'libgstreamer1.0-0.so'>
^self externalCallFailed   

This works fine too:

<apicall: int 'gst_init_check' (int* char* int*) module: 'libgstreamer1.0-0.so'>
^self externalCallFailed   

So it seems the bug comes from the parser missparsing ** . I am not familiar with C enough to help, I don't know what means ** (Is it a pointer pointing to a pointer pointing to the actual data ?). 

Perhaps someone who knows how to use FFI can give a better answer.

Esteban ? Guille ?


2014-07-09 16:39 GMT+02:00 Annick Fron <[hidden email]>:

Hi,


I am trying to use FFI on linux with pharo 3 using version 31 of FFI.

I have written the following method :

 <apicall: int 'gst_init_check' (int* char** int*) module: 'libgstreamer1.0-0.so'>

^self externalCallFailed


====

but when accepting it I get a syntax error « matching number of arguments »
Annick Fron



Reply | Threaded
Open this post in threaded view
|

Re: MNU: RBParser>>ExternalFunctionDeclaration

Clément Béra



2014-07-10 17:58 GMT+02:00 Annick Fron <[hidden email]>:
Hi,

I have made simple trials using the StandardLib.
I get this error :
RBParser does not understand externalFunctionDeclaration.
I might be missing something …

Yes, you are missing a package named "AST FFI Pharo 3 compatibility".
externalFunctionDeclaration is implemented in RBExplicitVariableParser (subclass of RBParser) as a method extension of this package.

The simplest solution is when you open a fresh pharo 3 image, you open the configuration browser (world menu >> tools >> configuration browser) then you click on FFI then install stable version. It loads automatically all what's needed to have FFI working.
 

Annick

Le 9 juil. 2014 à 17:20, Esteban Lorenzano <[hidden email]> a écrit :

yes, FFI does not handle ** arguments. 
I always replace it by ulong instead (it is the same, after all) 

Esteban

On 09 Jul 2014, at 17:17, Clément Bera <[hidden email]> wrote:

Hello,

This bug happen both with the old and new compiler.

The error tells you that the number of arguments of your smalltalk method does not match the number of argument of the C method you want to call (but it seemsthe number of arguments is correct).

This works fine:

 <apicall: int 'gst_init_check' (int char* int) module: 'libgstreamer1.0-0.so'>
^self externalCallFailed   

This works fine too:

<apicall: int 'gst_init_check' (int* char* int*) module: 'libgstreamer1.0-0.so'>
^self externalCallFailed   

So it seems the bug comes from the parser missparsing ** . I am not familiar with C enough to help, I don't know what means ** (Is it a pointer pointing to a pointer pointing to the actual data ?). 

Perhaps someone who knows how to use FFI can give a better answer.

Esteban ? Guille ?


2014-07-09 16:39 GMT+02:00 Annick Fron <[hidden email]>:

Hi,


I am trying to use FFI on linux with pharo 3 using version 31 of FFI.

I have written the following method :

 <apicall: int 'gst_init_check' (int* char** int*) module: 'libgstreamer1.0-0.so'>

^self externalCallFailed


====

but when accepting it I get a syntax error « matching number of arguments »
Annick Fron




Reply | Threaded
Open this post in threaded view
|

Re: Using FFI

Annick Fron-3
In reply to this post by EstebanLM
Actually the problem was I had forgotten to put the right number of arguments in the Smalltalk method … Too bad …

Le 10 juil. 2014 à 11:54, Esteban Lorenzano <[hidden email]> a écrit :

>
> On 10 Jul 2014, at 02:32, Andres Valloud <[hidden email]> wrote:
>
>> On 64 bit Windows a long is 32 bits and pointers are 64 bits, so that type of replacement is not going to work in the long run…
>
> Of course, but let’s take care about that problem when actually become a problem :)
> Hopefully, for when we finally have a 64bits with FFI, we will have a proper ** interpretation, but the workaround is the fastest solution you can have for now.
>
> Esteban
>
>>
>> On 7/9/14 8:20 , Esteban Lorenzano wrote:
>>> yes, FFI does not handle ** arguments.
>>> I always replace it by ulong instead (it is the same, after all)
>>>
>>> Esteban
>>>
>>> On 09 Jul 2014, at 17:17, Clément Bera <[hidden email]
>>> <mailto:[hidden email]>> wrote:
>>>
>>>> Hello,
>>>>
>>>> This bug happen both with the old and new compiler.
>>>>
>>>> The error tells you that the number of arguments of your smalltalk
>>>> method does not match the number of argument of the C method you want
>>>> to call (but it seemsthe number of arguments is correct).
>>>>
>>>> This works fine:
>>>>
>>>> <apicall: int 'gst_init_check' (int char* int) module:
>>>> 'libgstreamer1.0-0.so <http://libgstreamer1.0-0.so/>'>
>>>> ^self externalCallFailed
>>>>
>>>> This works fine too:
>>>>
>>>> <apicall: int 'gst_init_check' (int* char* int*) module:
>>>> 'libgstreamer1.0-0.so <http://libgstreamer1.0-0.so/>'>
>>>> ^self externalCallFailed
>>>>
>>>> So it seems the bug comes from the parser missparsing ** . I am not
>>>> familiar with C enough to help, I don't know what means ** (Is it a
>>>> pointer pointing to a pointer pointing to the actual data ?).
>>>>
>>>> Perhaps someone who knows how to use FFI can give a better answer.
>>>>
>>>> Esteban ? Guille ?
>>>>
>>>>
>>>> 2014-07-09 16:39 GMT+02:00 Annick Fron <[hidden email]
>>>> <mailto:[hidden email]>>:
>>>>
>>>>
>>>>         Hi,
>>>>
>>>>
>>>>
>>>>         I am trying to use FFI on linux with pharo 3 using version
>>>>         31 of FFI.
>>>>
>>>>   I have written the following method :
>>>>
>>>>
>>>>          <apicall: int 'gst_init_check' (int* char** int*) module:
>>>>         'libgstreamer1.0-0.so <http://libgstreamer1.0-0.so/>'>
>>>>
>>>>   ^self externalCallFailed
>>>>
>>>>
>>>>   ====
>>>>
>>>>   but when accepting it I get a syntax error « matching number of
>>>>   arguments »
>>>>   Annick Fron
>>>>
>>>>
>>>
>>
>
>