Passing nil with FFI

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

Passing nil with FFI

Thibault Raffaillac
Hi,

I am having trouble passing nil to a function with FFI (i.e. NULL, i.e. 0).
For example: SDL2 glCreateContext: nil.
The function expects a subclass of FFIExternalObject, so calls instVarAt: 1 but nil has no such field!
Am I missing something? (like a special nil instance of FFIExternalObject)
Note however that putting nil works when FFI expects a String.

Cheers,
Thibault Raffaillac

Reply | Threaded
Open this post in threaded view
|

Re: Passing nil with FFI

EstebanLM
Hi,

marshalling in UFFI is complex and sometimes not worthy, so we do not do auto-conversion between nil in smalltalk o zero to NULL (yes, I know NULL=0, but not for UFFI who is waiting a object type).
In this case (since it expects a kind of external object) you have to do:

SDL2 glCreateContext: FFIExternalObject null.

Esteban


> On 07 Apr 2016, at 12:06, Thibault Raffaillac <[hidden email]> wrote:
>
> Hi,
>
> I am having trouble passing nil to a function with FFI (i.e. NULL, i.e. 0).
> For example: SDL2 glCreateContext: nil.
> The function expects a subclass of FFIExternalObject, so calls instVarAt: 1 but nil has no such field!
> Am I missing something? (like a special nil instance of FFIExternalObject)
> Note however that putting nil works when FFI expects a String.
>
> Cheers,
> Thibault Raffaillac
>


Reply | Threaded
Open this post in threaded view
|

Re: Passing nil with FFI

Thibault Raffaillac
In reply to this post by Thibault Raffaillac
Great, that worked, thanks!

> Hi,
>
> marshalling in UFFI is complex and sometimes not worthy, so we do not do
> auto-conversion between nil in smalltalk o zero to NULL (yes, I know NULL=0,
> but not for UFFI who is waiting a object type).
> In this case (since it expects a kind of external object) you have to do:
>
> SDL2 glCreateContext: FFIExternalObject null.
>
> Esteban
>
>
> > On 07 Apr 2016, at 12:06, Thibault Raffaillac
> > <[hidden email]> wrote:
> >
> > Hi,
> >
> > I am having trouble passing nil to a function with FFI (i.e. NULL, i.e. 0).
> > For example: SDL2 glCreateContext: nil.
> > The function expects a subclass of FFIExternalObject, so calls instVarAt: 1
> > but nil has no such field!
> > Am I missing something? (like a special nil instance of FFIExternalObject)
> > Note however that putting nil works when FFI expects a String.
> >
> > Cheers,
> > Thibault Raffaillac
> >