Re: GIRepository questions



Hey,


On Wed, Mar 25, 2009 at 7:34 PM, nf2 <nf2 scheinwelt at> wrote:
> Hi,
>
> Inspired by Richard Dales blog about "Creating QMetaObjects from GObject
> Introspection data" i started working on a code-generator which
> automatically generates Qt/C++ bindings using GIRepository. The basic idea
> is that bindings are generated "on demand" and compiled together with the
> code which uses them.

Interesting!

Is there an opportunity for you and Richard to co-operate and write one
project supporting both kinds of usages?

> Now i got some problems/questions regarding GIRepository:

There are two categories of language bindings written using
gobject-introspection:

* compile time (vala)
* run time (gjs, seed, sbank, pybank etc)

Since the compile time bindings doesn't necessarily require an API, they
have the option of using the GIR XML files instead of the typelib via an API.
This is what vala currently does to mitigate the lack of some information,
for instance, the name *itself* of C struct/enum is not really part of the ABI,
but rather the C API.

> 1) gpointer* arguments:
>
> shouldn't they be reported as void Ptr with direction OUT or INOUT?
>
> (at the moment GIRepository just tells me they are "void Ptr's", which is
> wrong i guess)
>
> examples:
>
> g_object_add_weak_pointer()
> g_object_remove_weak_pointer()
> g_file_info_get_attribute_data()

There are two possibilities, an array of gpointer or a pointer to a gpointer.

The scanner is currently defaulting to the former, to express the second
intention you'd need to add annotation to say that it's a actually an
out/inout parameter. Annotations for these should go into
gir/GObject-2.0.c and gir/Gio-2.0.c inside gobject-introspection.

> 2) How do i get the original C type of STRUCTS?
>
> I need this information for casting them appropriately when calling the
> C-functions (cause i'm not using ffi)
>
> Sometimes it works with g_object_info_get_type_name(), but not always - it
> seems...

The name of the C type structure is not explicitly saved in the
typelib, we would
have to extend it to make it easier for a code generator to be written.

> 3) How do i get the original C type of ENUMS?
>
> Same as above.

Ditto.

> 4) How can i find out whether a function returns a char* or a char**?
>
> for instance g_filename_completer_get_completions() returns a char** array
> of strings, but GIRepository tells me its an UTF8 pointer.
>
> But perhaps that's just a matter of missing annotations. I could send you a
> complete list of such problems, because i have to "blacklist" those
> C-function calls to make my bindings compile...

This is another case of missing annotations, you need to add a Gio annotation
to get that specific case right.

Hope this helps

-- 
Johan Dahlin


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