This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

Dynamic Method Invocation With GProxy

GObjects already have dynamic properties and signals. A natural extension would be to add dynamic method invocation.

Dynamic method invocation would allow for some nice modern features such as:

Design Goals

Code

I have started implementing a library called gdx "GLib Dynamic Extensions" that will provide an implementation of this spec. GDX is also slated to include the generic plugin functionality described in my GPlugin idea. The GDX is hosted on launchpad:

You can check out the code with

bzr branch lp:gdx

API

GProxy (interface)

A proxy is created by GProxyTransport.lookup() or manually much like implementing a GInterface (only dynamically, see GLocalProxy below).

GProxyBindingType (GEnum)

GProxyParams (class)

GProxyTransport (interface)

GMethod (class)

GMethodInvocation (class) A method invocation encapsulates data passed by the client to the method. Conventional method arguments are passed via the *_arg() methods. In addition to conventional arguments special invocation hints can be used. Invocation hints can be used to augment the method invocation and request additional information from the invocation. A prime example here being a request to also get the DBus message sender's bus name. To do this one could pass "dbus:sender"" and NULL to append_hint() and the method response would contain the the sender name as a hint value.

GMethodInvocationError (GError)

GMethodResult (GAsyncResult)

GDynamicProxy (GProxy) abstract

GLocalProxy (GDynamicProxy) Generic proxy implementation keeping a dynamic vtable in contrast to the static vtable of GInterfaces.

Problems

Use Cases

Crackpot Idea: Django-like Application Development

A few configuration files, some IDL, a Django-like templating language to output GtkBuilder XML, Some C, Vala, or Genie code (or other languages via bindings), and... Presto. You have a DBus enabled application storing persistent data in a database (or what ever), interacting cleanly with other services on the bus.

Smaller apps (such as capplets) could possibly consist of only a configuration file and a GtkBuilder template file. Larger projects would probably still fare better the conventional way.


2024-10-23 11:23