-
Notifications
You must be signed in to change notification settings - Fork 80
WIP: generate types and methods using GObject introspection #27
Conversation
Interesting work. I was about to propose using the GI some time ago, but the documentation left me wondering (even their java script example is not really readable). For the naming, i'd also tend to Gtk.Window, Gtk.Frame. |
I was looking mostly into pygobject, but they "cheat" a bit and use g_function_info_invoke, which does the glib-side marshalling and pointer-handling. I think it's better to try generating native bindings directly; in principle all information necessary exist in the type database, but for instance the memory-management flags and bi-directional arguments seem a bit tricky. |
I haven't gotten a chance to look through this, but on the subject of naming, I originally decided to export the 'official' Gtk names when you do Isn't GObject-Introspection an optional component? I initially ignored it because I expected that users would not have it installed (I don't have it). |
@vtjnash |
It is source-distributed inside gobject, but I guess many distributions split the binary packages. (I haven't thought about it, since gnome pulls in all libraries in the gobject family) It makes sense for Gtk which is a short prefix, but code could be general for all GObject namespaces, which may have much longer names. The reason I ask is because
doesn't work, i e, each type must have a single name for adding constructors. |
Not true. Just need to declare |
What's the status of this on Windows/OSX? I would be concerned about introducing anything that jeopardizes cross-platform potential. |
|
we probably want a better syntax for type/method requests
Thanks, forgot to add const. Code generation is quite slow anyway, so one might ship pre-generated bindings like already done for properties using cindex. |
Ah. In theory, cindex could be replaced by this, which should yield more precise methods. |
Probably we should split this out into it's own repo, to retain compability with gtk2 and systems without gintrospection. but then maybe the basic glib/gobject code should be split out too, so it could be shared. What do you think? (I just put everything inside Gtk.jl for now so I simply could reuse the already good gtypes/gobject bindings) |
I would have no problem with that. In fact, it may solidify my idea that methods should be written against a parameterized abstract type, e.g. |
Ok, but I think libgobject exposes enough runtime data alone (without needing libgintrospection) to generate the tree of Abstract types and also the handle wrapper types. So imho GObject.jl should generate these (if I'm correct), on first request by Gtk.jl / GI.jl / etc , and ensure that each gobject instance has exactly one julia wrapper object. I will look into it later. I will probably rename the auto-generated gtk_*_new constructors by GI.jl, so they don't conflict with those already present in Gtk.jl (there are a few clashes right now) |
Conflicts: src/gtktypes.jl src/gvalues.jl
@@ -144,7 +144,13 @@ convert{P<:Ptr}(::Type{P}, a::MatrixStrided) = convert(P, a.p) | |||
bstride(a::MatrixStrided,i) = (i == 1 ? sizeof(eltype(a)) : (i == 2 ? a.rowstride : 0)) | |||
bstride(a,i) = stride(a,i)*sizeof(eltype(a)) | |||
|
|||
@GType GdkPixbuf | |||
#not a gobject, when whe get support for glib structs this can be automated too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for this states that it is a GObject.
What is the performance & memory impact of computing the supertypes at runtime? |
just a quick check using tests.jl : supertypes at runtime: So module loading is slightly slower (this is consistent on repeated runs. It could be because I generate a few unnecessary wrappers right now). If you want I could rebase just the relevant changes (not including gi-introspection code) on master, that might make the changes easier to review and test. |
That timing impact seems acceptable. Extracting just the changes that do not require GI would be good. Note that Gtk does not guarantee that GTypes are stable identifiers. Since they are references to a hash function, they will mutate if the hash is updated. As such, they cannot be be stored or used as keys. The stable identifiers are either the name, or a call to a I think the macro will need to take the following form, which specifies (a) the expected name (b) the library containing it's functions (c) the associated and should key the type dictionary using a symbol based on the name of the widget: This form would also allow you to remove the call to |
Ok, I thought GTypes were runtime stable, but then your suggestion seems the way to go. By the way, do you approve of splitting out the glib code into it's own namespace? Right now I do
It much faster just [re]loading this than all of Gtk.jl. |
yes they are stable until the value of helpful note: |
There's still a bit of clean-up and testing to do before I'll do a new PR, but the new implementation of @gtype can be seen here: |
I've been experimenting a bit with auto-generating types and method wrapping using GObject-Introspection. This should fix many of the ccalls for us so that we can focus on create Julian wrappers. (is that the adjective for idiomatic julia?)
It is far from ready to merge yet (I have patched it in among the existing wrappers in quite an ugly way IMHO, and it currently leaks refs and strings like it's no tomorrow) but I'd like to discuss and settle on a consistent naming schemes. Should we have Gtk.Window or Gtk.GtkWindow, Clutter.Actor or ClutterActor? I tend to prefer the former as the primary names. Same questing with constants/Enums (not implemented yet) as Gobject-Introspection allows constants starting with numbers.