[Gambas-devel] Multi-level virtual objects, inheritance and symbol resolution mess
Tobias Boege
taboege at ...176...
Sat Sep 13 05:05:33 CEST 2014
On Sat, 06 Sep 2014, Beno?t Minisini wrote:
> But there is another problem:
>
> hGraphMatrix.Vertices[] calls GraphVertices_get, which calls the
> "_getVertex" method. As "_getVertex" returns a "virtual object", no
> dynamic calling can occur, and the InDegree property of _Graph_Vertex is
> called, never the InDegree property of _Matrix_Vertex.
>
> I have no solution at the moment...
>
In #6468, for native classes, I circumvented it by overriding the "Vertices"
symbol in the graph class:
GB_PROPERTY_SELF("Vertices", ".Matrix.Vertices")
where it was previously inherited from the common Graph class as a
".Graph.Vertices". This way I can say in the description of .Matrix.Vertices
that the _get() method returns a .Matrix.Vertex instead of the .Graph.Vertex.
Then the right methods are called.
For Gambas classes, this won't work at all because it involved inheriting
virtual classes (impossible) and staying a virtual class in this course
(also impossible). So I thought I would just give .Graph.Vertex _property
and _unknown methods and mirror them, again, to _vertexProperty and
_vertexUnknown in the graph class.
It is yet another indirection but it's for Gambas graphs only and there
shouldn't be too many things a person wants to add to a vertex or edge
class.
Seems like the way it is now, everything is working and it doesn't seem too
hard to implement a graph in Gambas. I'll write a tutorial on how to do it,
if you're as content as you can be with the system.
I'll send three test projects to gambas-user in a minute.
Regards,
Tobi
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the Devel
mailing list