On 10 February 2012 15:55, Igor Stasenko <siguctua@gmail.com> wrote:
On 10 February 2012 13:14, Javier Pimás <elpochodelagente@gmail.com> wrote:
I have this wrapper:
chooseVisual: display screen: aScreenNumber attributes: attribList <primitive: #primitiveNativeCall module: #NativeBoostPlugin>
^ self call: #( NBXLibVisualInfo* glXChooseVisual ( NBXLibDisplay display , int aScreenNumber, int *attribList ) )
but when generating native code it ends in:
ExternalStructureType>>coerceReturn: gen
" ... should we support handling return of external structures? " self error: 'returning pointer to structure?'
Changing "NBXLibVisualInfo*" to "NBXLibVisualInfo" didn't help. Is there any workaround??
Yes. Change the return type to void* :) And then do as i showed before: load the struct fields from that pointer in your code.
info := NBXLibVisualInfo fromPointer: (self chooseVisual: display screen: aScreenNumber attributes: attribList)
Because how you would implement it? It maybe a pointer to single structure or pointer to an array of structures.. Because in C a pointer can be a pointer to a single value, or pointer to multiple values and you cannot make a difference.
and of course it is a good excuse for not implementing structs which accessing data indirectly (via pointer to some memory), instead of holding fields data in bytearray :) Though, it is easy to implement. So if you really can't live without it, i can add it. -- Best regards, Igor Stasenko.