[Gambas-devel] component

Benoit Minisini gambas at ...20...
Sun Jun 8 11:18:30 CEST 2003


Le Samedi 7 Juin 2003 21:18, Ken Schrock a écrit :
> Let's see if I have this right
> Would this yield a component called 2Example
> With a single read-only property called width, type integer?

Yes.

> (which would always return 0 at this point : -)
> HACK Hack hack Minimalist version
>
> /********************* short_c2example.h **********************/
>
> #ifndef __C2EXAMPLE_H
> #define __C2EXAMPLE_H
>
> #include "gambas.h"
>
> #ifndef __C2EXAMPLE_C
>
> extern GB_DESC CExampleDesc[];
>
> #else
>
> #define THIS ((C2EXAMPLE *)_object)
>
> #endif
>
> typedef
>   struct {
>     GB_BASE ob;
>     long width;
>     }
>   C2EXAMPLE;
>
> #endif
>
> /****************** short_c2example.c ****************/
>
> #define __C2EXAMPLE_C
>
> #include "short_main.h"
> #include "Short_C2Example.h"
>
>
> BEGIN_PROPERTY(C2EXAMPLE_width)
>
>   GB.ReturnInteger(THIS->width);
>
> END_PROPERTY
>
>
> GB_DESC C2ExampleDesc[] =
>
>   GB_DECLARE("2Example", sizeof(C2EXAMPLE)),
>
>   GB_PROPERTY_READ("Width", "i", C2EXAMPLE_width),
>
>   GB_END_DECLARE
> };
>
> /************* short_main.h *****************/
>
> #ifndef __MAIN_H
> #define __MAIN_H
>
> #include "gambas.h"
>
> #ifndef __MAIN_C
>
> extern GB_INTERFACE GB;
>
> #else
>
> static void hook_main(int *argc, char **argv);
>
> #endif /* __MAIN_C */
>
> #endif /* __MAIN_H */
>
> /****************** short_main.c *********************/
>
> #define __MAIN_C
>
> #include "Short_C2Example.h"
> #include "short_main.h"
>
> GB_INTERFACE GB;
>
> GB_DESC *GB_CLASSES[] =
> {
>   C2ExampleDesc,
>   NULL
> };
>
> int GB_INIT(void)
> {
>   GB.Hook(GB_HOOK_MAIN, (void *)hook_main);
>   return 0;
> }
>
> void GB_EXIT()
> {
> }
>
> void GB_INFO(int info, void **result)
> {
>   switch (info)
>   {
>     case GB_INFO_CONTROL:
>       *result = (void *)NULL;
>       break;
>
>     case GB_INFO_REQUIRE:
>       *result = (void *)NULL;
>       break;
>   }
> }

It is not necessary to manage the cases where GB_INFO returns NULL, because 
this is the default value.

>
> static void hook_main(int *argc, char **argv)
> {
> /* main stuff */
> }
>
> Also, Gambas (IDE etc) work well here with this binary package
> I therefore want to leave it alone and do this level dev elsewhere
> I also have Mandrake version 8.2 on this machine
> Will the 0.57 source compile ok there?

You need at least Mandrake 9.0, Mandrake 9.1 being better.

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the Devel mailing list