[FFI] Passing a null in argument

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

[FFI] Passing a null in argument

MerwanOuddane
Hi,

I wanted to call a function using null as argument but did not managed
to do so.

I tried to use an integer, but the FFI forbids it.

I tried to use FFIExternalObject null, but the FFI vould not coerce the
arguments.

To make it work I had to duplicate the method and set 0 instead of an
argument.

void foo (0);

Is it possible to do it the first way ?

Regards,

Merwan


Reply | Threaded
Open this post in threaded view
|

Re: [FFI] Passing a null in argument

EstebanLM
which function?
declared how?
used how?

Esteban

> On 23 Jun 2016, at 18:07, Merwan Ouddane <[hidden email]> wrote:
>
> Hi,
>
> I wanted to call a function using null as argument but did not managed to do so.
>
> I tried to use an integer, but the FFI forbids it.
>
> I tried to use FFIExternalObject null, but the FFI vould not coerce the arguments.
>
> To make it work I had to duplicate the method and set 0 instead of an argument.
>
> void foo (0);
>
> Is it possible to do it the first way ?
>
> Regards,
>
> Merwan
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [FFI] Passing a null in argument

MerwanOuddane
On 23/06/2016 18:39, Esteban Lorenzano wrote:
> which function?
A function within a DLL file.
> declared how?

Something like: void foo( void *bar)

> used how?

MyClass foo: bar
     ^ self ffiCall: #(void foo( void *bar))

MyClass foo: 0
MyClass foo: FFIExternalObject null

>
> Esteban
>
>> On 23 Jun 2016, at 18:07, Merwan Ouddane <[hidden email]> wrote:
>>
>> Hi,
>>
>> I wanted to call a function using null as argument but did not managed to do so.
>>
>> I tried to use an integer, but the FFI forbids it.
>>
>> I tried to use FFIExternalObject null, but the FFI vould not coerce the arguments.
>>
>> To make it work I had to duplicate the method and set 0 instead of an argument.
>>
>> void foo (0);
>>
>> Is it possible to do it the first way ?
>>
>> Regards,
>>
>> Merwan
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: [FFI] Passing a null in argument

EstebanLM

> On 23 Jun 2016, at 18:54, Merwan Ouddane <[hidden email]> wrote:
>
> On 23/06/2016 18:39, Esteban Lorenzano wrote:
>> which function?
> A function within a DLL file.
>> declared how?
>
> Something like: void foo( void *bar)
>
>> used how?
>
> MyClass foo: bar
>    ^ self ffiCall: #(void foo( void *bar))
>
> MyClass foo: 0
> MyClass foo: FFIExternalObject null

is "ExternalAddress null” what you want.

>
>>
>> Esteban
>>
>>> On 23 Jun 2016, at 18:07, Merwan Ouddane <[hidden email]> wrote:
>>>
>>> Hi,
>>>
>>> I wanted to call a function using null as argument but did not managed to do so.
>>>
>>> I tried to use an integer, but the FFI forbids it.
>>>
>>> I tried to use FFIExternalObject null, but the FFI vould not coerce the arguments.
>>>
>>> To make it work I had to duplicate the method and set 0 instead of an argument.
>>>
>>> void foo (0);
>>>
>>> Is it possible to do it the first way ?
>>>
>>> Regards,
>>>
>>> Merwan
>>>
>>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [FFI] Passing a null in argument

MerwanOuddane
Yes it works, thank you Esteban

On Thu, Jun 23, 2016 at 7:00 PM, Esteban Lorenzano <[hidden email]> wrote:

> On 23 Jun 2016, at 18:54, Merwan Ouddane <[hidden email]> wrote:
>
> On 23/06/2016 18:39, Esteban Lorenzano wrote:
>> which function?
> A function within a DLL file.
>> declared how?
>
> Something like: void foo( void *bar)
>
>> used how?
>
> MyClass foo: bar
>    ^ self ffiCall: #(void foo( void *bar))
>
> MyClass foo: 0
> MyClass foo: FFIExternalObject null

is "ExternalAddress null” what you want.

>
>>
>> Esteban
>>
>>> On 23 Jun 2016, at 18:07, Merwan Ouddane <[hidden email]> wrote:
>>>
>>> Hi,
>>>
>>> I wanted to call a function using null as argument but did not managed to do so.
>>>
>>> I tried to use an integer, but the FFI forbids it.
>>>
>>> I tried to use FFIExternalObject null, but the FFI vould not coerce the arguments.
>>>
>>> To make it work I had to duplicate the method and set 0 instead of an argument.
>>>
>>> void foo (0);
>>>
>>> Is it possible to do it the first way ?
>>>
>>> Regards,
>>>
>>> Merwan
>>>
>>>
>>
>
>