Re: Pidl - an IDL for GObject boilerplate and language bindings



Good to see others working on abstractions like this. We have a closed
system for internal use, but it was developed to do much of the same
by reimplementing/extending the GOB syntax and writing a new
"compiler" for it. Simultaneous code is output in both C/C++ with an
introspection system added for both methods and static methods (in
addition to properties which already exist in GObject) that allows
automatic bindings for JS integration. Standard public/private methods
are still allowed, but just don't get any JS binding. GOB isn't
exactly an IDL, but it accomplishes the same feat when tweaked. The
advantage is that you don't have to maintain a separate IDL file and
implementation. This is still possible, of course, by only exposing
GInterfaces to the binding and declaring everything via an interface.

Example:

interface Foo from G:Interface
{
    public void foo(void);
}

[Design:Time:Attribute(...)]
class My:Object from G:Object
    (interface Foo)
{
    private gint my_variable = 5;
    private GList *my_list = NULL destroywith g_list_free;

    static_method My:Object marshal_as OBJECT (NONE) Self *
    new(void)
    {
        return GET_NEW;
    }

    [Design:Time:Attribute(...)]
    method BOOL (INT, G:Error:Ref marshal_as POINTER) gboolean
    my_class_method(self, gint foo, GError **error)
    {
        g_debug(__GOB_FUNCTION__": value: %d", selfp->my_variable);
        g_set_error(error, ...);
        return FALSE;
    }

    public void
    method_only_to_c_cpp_callers(void)
    {
    }

    interface Foo
    private void
    foo(void)
    {
    }
}

Automatically becomes (in JS):

var foo = new MyObject();
foo.foo();
foo.my_class_method(5));
... throws an exception here

-Andrew

On Feb 12, 2008 10:18 AM, Christian Berentsen
<christian berentsen tandberg com> wrote:
> https://launchpad.net/pidl
>
> Pidl is an Interface Description Language for GObject C-code with
> automatic language bindings.
>
> The programmer mainly writes '.pidl' files and implementation in C. Much
> GObject boilerplate is hidden.
>
> Language bindings are automatically generated.
> (Currently for Python, C++ and C#)
>
> As we are developing a product relying heavily on GObject, we came to
> the conclusion that the risk of having every developer handling
> boilerplate code could become a big maintenance headache.
>
> Pidl is still in its infancy and is being evolved on a day to day basis.
> The system is developed in TDD fashion, with test coverage in Python.
>
> Could this be interesting for anybody else writing GObject based
> software?
>
> Current feature summary:
> Emits C++, Python and C# (and GObject front stubs in C)
> Supports classes, interfaces, properties, methods, and signals.
> Supports implementing interfaces in C++ and C# (not yet Python)
> Enums
> Errors/Exceptions on methods marked as throwing. (GError marshalled to
> language exceptions, modelled after dbus-glib)
> Weak references (Properties only)
> Inheritance
> and more.
>
> --
> Jarl Christian Berentsen
> Ole Andre Vadla Ravnaas
> (Pidl core monkeys)
>
>
>
>
>
>
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
>
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]