[Gambas-devel] Multi-level virtual objects, inheritance and symbol resolution mess

Benoît Minisini gambas at ...1...
Sat Sep 6 17:51:12 CEST 2014


Le 06/09/2014 17:05, Tobias Boege a écrit :
>>
>> I suggest:
>>
>> - Creating a struct of function pointers that represents the graph node
>> interface.
>>
>> - Adding a pointer on that struct in each graph.
>>
>> - Use it everywhere you need.
>>
>> - All classes written in C/C++ inheriting Graph must implement that
>> struct of function pointers and put a pointer on it in its objects.
>>
>> - For classes written in Gambas inheriting Graph, you must create a
>> struct of function pointers that calls the Gambas functions you defined
>> ('_getVertex', '_getEdge', ...). Calls to GB.GetFunction() should be
>> done once and cached, the first time you instanciate an object of that
>> class.
>>
>
> So, I would keep a structure of GB_FUNCTIONs? Can I keep this struct once
> for each class and substitute GB_FUNCTION.object for each call or is this
> not supported (depends on what is in GB_FUNCTION.desc)?
>

Yes. "desc" is the method description, "object" the object pointer.

>> That way, performance should be acceptable. :-)
>>
>> By the way: you should use GB_DECLARE_VIRTUAL() instead of GB_DECLARE()
>> for declaring virtual classes. No need to use GB_VIRTUAL_CLASS() then.
>> And virtual classes name should begin with a dot, not an underscore. I'm
>> not sure at the moment it has no impact in the interpreter...
>>
>
> I wanted to adhere to this rule but the problem is/was that _Graph_Vertex
> was virtual and Gambas classes needed to inherit it but IIRC you cannot
> inherit classes beginning with a dot in Gambas (syntactically).
>

See my previous answer. Inheriting virtual classes does not really work, 
as dynamic symbol dispatching cannot occur with virtual classes.

-- 
Benoît Minisini




More information about the Devel mailing list