> On 07 Apr 2016, at 14:15, Damien Pollet <damien.pollet+ph...@gmail.com> wrote:
> 
> I think in that case you need to pass an instance of FFIExternalValueHolder.

yes.
you can take the test FFIExternalValueHolderTests>>testCall as an example. 

But since it uses anonymous classes it might require a better explanation, 
there is the class comment, but basically, you do this: 

1) Declare a class variable 

MyClass class>>initialize
        INT_PTR := FFIExternalValueHolder ofType: ‘int’.

2) Replace "int *” in your function calls with your new type:

 glGetAttribute: attr into: value
        ^ self ffiCall: #( int SDL_GL_GetAttribute(SDL_GLattr attr, INT_PTR 
value) )

3) pass an instance of INT_PTR to get the value: 

| ptr value |

ptr := INT_PTR new.
self  glGetAttribute: anAttributeIDontKnow into: ptr.

value := ptr value.

Esteban


> 
> On 7 April 2016 at 17:42, Thibault Raffaillac <thibault.raffail...@inria.fr 
> <mailto:thibault.raffail...@inria.fr>> wrote:
> Hi again,
> 
> Does anyone know what is the state of return by reference in FFI?
> Example:
> glGetAttribute: attr into: value
>         <primitive: #primitiveNativeCall module: #NativeBoostPlugin error: 
> errorCode>
>         ^ self nbCall: #( int SDL_GL_GetAttribute(SDL_GLattr attr, int 
> *value) )
> 
> On my image (50666) it does nothing on value yet (if nil, remains nil, if 
> SmallInteger 0, remains 0).
> (SDL2 glGetAttribute: 6 into: value) should return 16.
> I've seen NBOpenGL put "out" before value in method header, should it matter? 
> (does not make it work though)
> Last but not least, should we attach '*' to the type or variable for FFI to 
> understand it is a pointer?
> 
> Cheers,
> Thibault Raffaillac
> 
> 

Reply via email to