[Gambas-devel] C component declaration

Tobias Boege taboege at ...176...
Thu Dec 31 13:43:30 CET 2015


On Wed, 30 Dec 2015, Martin Cristia wrote:
> How to declare arrays when making a component, ie :(C declaration in library)void glVertexPointer(GLint size, GLenum type, GLsize stride, const GLvoid*array)
> C gb component:
> GB_STATIC_METHOD( ......??
> 
> DECLARE_METHOD(.....?

This is the response I gave you at gambas-user:

On Wed, 30 Dec 2015, Tobias Boege wrote:
> I'll tell you how I answer such questions for myself when I forgot the
> details: think hard if any Gambas component has any class with a method
> that returns an array object. If you're lucky there is such a component
> which is written in C. Then look into its source code how it's done.
> 
> In this case I remembered that gb.net.curl's HttpClient can return a
> String[] of headers. You go to gb.net.curl/src/CHttpClient.c and find:
> 
>   GB_PROPERTY_READ("Headers", "String[]", HttpClient_Headers),
> 
> that is you treat array types like every other class by writing the full
> class name into the signature. Only the primitive data types have
> abbreviations.

I may add the following to specifically address your question:

  GB_METHOD("VertexPointer", NULL, your_function, "(Size)i(Type)i(Stride)i(Array)Object[];")

The actual types ("i" for Integer, "Object[]" for an array of generic
objects) may vary -- I don't know how OpenGL types translate to Gambas ones
and guessed the values above. Your method may or may not need to be static.

You may also want to read the article linked here[0] on native component
development for Gambas.

Regards,
Tobi

[0] http://www-e.uni-magdeburg.de/tboege/gambas/

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the Devel mailing list