[Gambas-devel] need a bit of explanation - please

Kari Laine klaine8 at ...176...
Fri Aug 15 17:26:11 CEST 2008


Thanks I have to try to figure it out.

Best Regards
Kari Laine


On Fri, Aug 15, 2008 at 2:31 PM, Benoit Minisini <
gambas at ...1...> wrote:

> On vendredi 15 août 2008, Kari Laine wrote:
> > On Fri, Aug 15, 2008 at 1:38 PM, Benoit Minisini <
> >
> > gambas at ...1...> wrote:
> > > On vendredi 15 août 2008, Kari Laine wrote:
> > > > Hi,
> > > >
> > > > I try to figure out Gambas and because I am not C-guru I have used
> two
> > > > hours now to understand possibly a basic thing...
> > > > Could someone help?
> > > >
> > > > In function
> > > >
> > > > CLASS *CLASS_register_class(GB_DESC *ptr, CLASS *class)
> > > >
> > > > There is a loop
> > > >
> > > >   desc = (CLASS_DESC *)&gambas[1];
> > > >
> > > >   for (start = NULL; start == NULL; desc++)
> > > >
> > > > The problem I have is to understand this bit
> > > >     switch ((intptr_t)desc->gambas.name)
> > > > Where gambas.name is initialized to have the values tested in the
> case
> > > > clauses? Somehow name's pointer is usefull to give out information.
> > > >
> > > > Also in the same switch there is following
> > > >       case (intptr_t)GB_INHERITS_ID:
> > > >         CLASS_inheritance(class, CLASS_find((const char
> > > > *)desc->gambas.type));
> > > >         break;
> > > > Why is CLASS_find called with a generall name like Control ?
> > > >
> > > > Hopefully someone understands my question.
> > > >
> > > > Best Regards
> > > > Kari Laine
> > >
> > > Sorry, I don't understand what you are asking for... Can you formulate
> > > your question differently?
> >
> > I am not sure if I can ask this in a right way.
> >
> > Could you explain this line.
> > switch ((intptr_t)desc->gambas.name)
> >
> > How gambas.name pointer can be cast to intptr_t?
> >
> > And how it takes one of following values
> > GB_INHERITS_ID
> > GB_AUTO_CREATABLE_ID:
> > GB_NOT_CREATABLE_ID:
> > GB_VIRTUAL_CLASS_ID:
> > GB_HOOK_CHECK_ID
> >
> > Best Regards
> > Kari Laine
>
> 'desc' is a pointer to a 'GB_DESC' structure declared in 'gambas.h'.
>
> This structure describes one symbol of a native class. You can see these
> structures used in each class file of the interpreter ('gbx_c_*.c' files)
> or
> any component.
>
> It is accessed in 'CLASS_register_class' via the 'GB_CLASS_DESC' union and
> its 'gambas' field.
>
> 'desc->gambas.name' is the name of the symbol, with one letter added to
> its
> beginning. It describes the type of the symbol, and if it is static: for
> example, "MLoad" is a dynamic method named 'Load', or "rLength" is a
> dynamic
> read-only property named 'Length'.
>
> But this symbol can takes special values to specify some class global
> parameters: GB_INHERITS_ID for the parent class, GB_VIRTUAL_CLASS_ID for a
> virtual class, and so on.
>
> These special values are false pointers, whose value should never be taken
> by
> real pointers: 1, 2, 3, and so on.
>
> So the 'intptr_t' cast is just to make the compiler understand that we are
> dealing with integer values that are stored inside pointers.
>
> This is sort of dirty programming. Do not do that in your own code. :-)
> The 'GB_DESC' structure should have been declared as an union of different
> structures.
>
> I hope it is clearer now.
>
> Regards,
>
> --
> Benoit Minisini
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Gambas-devel mailing list
> Gambas-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20080815/9adcbb44/attachment.html>


More information about the Devel mailing list