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

Tobias Boege taboege at ...176...
Thu Sep 11 05:07:38 CEST 2014


On Wed, 10 Sep 2014, Beno?t Minisini wrote:
> Le 10/09/2014 23:07, Tobias Boege a ?crit :
> > On Wed, 10 Sep 2014, Beno?t Minisini wrote:
> >> Le 06/09/2014 17:50, Beno?t Minisini a ?crit :
> >>>
> >>> OK. As I thought, the "_" prefix was the problem. I fixed the
> >>> interpreter so that it decides that a native class is virtual by taking
> >>> into account the "GB_VIRTUAL_CLASS()" declaration, not just the initial
> >>> dot in the name.
> >>>
> >>> 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...
> >>>
> >>
> >> Hi Tobias,
> >>
> >> Did you succeed in dealing with that tricky stuff?
> >>
> >
> > Oh, I just remembered the one thing which made me give up the last night I
> > tried to make progress on this:
> >
> > With the former implementation I had a Graph and a _Graph_Vertex class which
> > both contained methods on their own and this separation was a good thing.
> > Now, to get the function pointers together, I would need all special
> > functions be implemented in the graph class alone, like _nextAdjacent which
> > enumerates vertices adjacent to the currently selected virtual .Graph.Vertex
> > object... Not so pretty. It would make the .Graph.Vertex and .Graph.Edge
> > classes useless because all the information needs to be in the graph class
> > anyway in order to implement those special methods.
> >
> > I could require the user to name their descendent of .Graph.Vertex -- if
> > their main graph class is called MyGraph --, as .MyGraph.Vertex and then
> > search this class explicitely.
> >
> > What do you say?
> >
> 
> I say that I'm not shocked if the entire interface is in the Graph 
> class. But I don't see why you can't keep .Graph.Vertex and .Graph.Edge. 
> The user just won't have to inherit them anymore.
> 

I have the things from my test projects working now (with my ImageGraph in
Gambas and the native GraphMatrix class). Except the problem you mentioned
in the upmost citation above.

There is .Graph.Vertex which is virtual. I can't access properties of
.Matrix.Vertex which is virtual and inherits from .Graph.Vertex, which
you said above. Also, I can't inherit this dot-containing class (name)
from within Gambas code.

Inheriting it may be needed when the user wants to add custom properties
and methods to their vertices and edges... The sole purpose of the
.Graph.Vertex and .Graph.Edge classes is to dictate an interface but I want
to keep them and also to keep them virtual (if only for native classes) if
at all possible.

I have, in turn, eliminated all virtual properties from *them*, so maybe I
can find a solution to this tomorrow, but now I need some sleep.

But except for that, everything seems to work, and there is already a full
native graph class implemented and a working graph in Gambas which has an
implementation just comprehensive enough to allow a BFS on it.

Regards,
Tobi

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




More information about the Devel mailing list