Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

multiple inheritance #20

Closed
vtjnash opened this issue Dec 30, 2013 · 9 comments
Closed

multiple inheritance #20

vtjnash opened this issue Dec 30, 2013 · 9 comments

Comments

@vtjnash
Copy link
Contributor

vtjnash commented Dec 30, 2013

we are missing a lot of accessor methods due to the lack of multiple inheritance support in Julia. somehow we need to fake support for it

@tknopp
Copy link
Collaborator

tknopp commented Jan 22, 2014

What about using type unions for this purpose.

For the GtkTreeModel interface I have used a definition

GtkTreeModelI = Union(GtkListStore, GtkTreeStore)

It would be more convenient to somehow extend the @gtktype macro so that it accepts additional arguments (i.e. the implemented interfaces) and @gtktype collects all interfaces and its implementations. At some point it then has to define the type union. But I have no idea how to get the definition order right with this approach.

Alternative: Introduce multiple inheritance in Julia. I am not sure how likely it is that this will ever happen. You have a better feeling about that

@bfredl
Copy link
Contributor

bfredl commented Jan 22, 2014

I have the same problem in GI.jl (gobject-introspection generated bindings). For instance in Clutter, Container is an abstract interface and not a base object like in Gtk. I'm also considering Union(...) but the problem with this is AFAIK there is no convenient way to add new concrete types to it afterwards, which can happen if you import an extension library that defines more widgets/actors. Right now i just prefix interface methods with the interface name, i e container_add_actor but I don't know the best way to then define the more convenient push!(ClutterContainer, ClutterActor) .

Multiple inheritance of abstract types would have been the simplest indeed.

@tknopp
Copy link
Collaborator

tknopp commented Jan 22, 2014

Yes, the Union method is limited and it will not allow to extend the type. It might be possible that extending Unions are easier to implement than MI in Julia. Will ask in the MI issue in the Julia bug tracker.

Although the Union method is limited, it allows to implement against interfaces and, in the case MI comes, one would only need to change the type definitions and the implemementations can stay.

@tknopp
Copy link
Collaborator

tknopp commented Jan 24, 2014

To be able to use the setter of interfaces using the aforementioned Union method, one has to write one conversion method, i.e.

GtkTreeModelI = Union(GtkListStore,GtkTreeStore)
convert(::Type{Ptr{None}},m::GtkTreeModelI) = convert(Ptr{None},m.handle)

But with that I am able to use the GtkTreeModel setter now (have not tested the getter though)

@tknopp
Copy link
Collaborator

tknopp commented Jan 24, 2014

Actually I have not tried to use a setter of TreeModel yet. But the conversion allows to use a setter of TreeView that has a TreeModel as argument

@tknopp
Copy link
Collaborator

tknopp commented Jan 24, 2014

Automatic getter/setter generation works when putting the interface to the code gen script. (yes I have clang+gtk@mac working now)

@vtjnash
Copy link
Contributor Author

vtjnash commented Jan 25, 2014

@tknopp that error actually means that gtk_get_set_gen didn't know GtkTreeModelI is a GtkObject. The proper way to fix that error is to add it to the GtkTypeMap list (esp. now that you can successfully run the code gen script)

@tknopp
Copy link
Collaborator

tknopp commented Jan 25, 2014

I see.

@vtjnash
Copy link
Contributor Author

vtjnash commented Mar 7, 2014

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants