Re: GIRepository questions



Johan Dahlin wrote:
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!

The sources are here: http://websvn.kde.org/trunk/playground/bindings/gobject-consume/

You will also find a samples/gio folder which you can build separately with cmake. Make will automatically run go-consume to autogenerate the bindings (but you have to correct the path of the "go-consume" binary).

This is another case of missing annotations, you need to add a Gio annotation
to get that specific case right.
I was able to fix a number of missing annotations after you showed me how to do it :-)
(attached is a patch for gobject-introspection)

Some problems remain:

1) void g_simple_async_report_gerror_in_idle (GObject            *object,
                      GAsyncReadyCallback callback,
                      gpointer            user_data,
                      GError             *error);

is reported as "throwable", but i think the GError is a simple "IN" arg.


2) Object pointers in the signal args (as i told you on IRC)


3) Object pointers in GList return values which have the element-type annotated:

GITypeInfo * param_type_info = g_type_info_get_param_type(returnType, 0);
bool is_pointer = g_type_info_is_pointer(param_type_info);

reports "false".

Although in Gio-2.0.gir it seems to be a pointer:

   <function name="app_info_get_all" c:identifier="g_app_info_get_all">
     <return-value transfer-ownership="full">
       <type name="GLib.List" c:type="GList*">
         <type name="GAppInfo*"/>
       </type>
     </return-value>
   </function>

In other places - where the element-type is not annotated - void Ptr is reported correctly.

Cheers,
Norbert









diff --git a/gir/Makefile.am b/gir/Makefile.am
index f9b4efc..5d7c48d 100644
--- a/gir/Makefile.am
+++ b/gir/Makefile.am
@@ -72,7 +72,8 @@ GObject-2.0.gir: GLib-2.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) Makefile
 	    -I$(GOBJECT_LIBDIR)/glib-2.0/include \
 	    -DGOBJECT_COMPILATION \
 	    --pkg gobject-2.0 \
-	    $(GLIB_INCLUDEDIR)/gobject/*.h
+	    $(srcdir)/gobject-2.0.c \
+	    $(GLIB_INCLUDEDIR)/gobject/*.h 
 	$(SCANNER) $(SCANNER_ARGS) \
 	    --xpath-assertions=$(srcdir)/GObject-2.0.xpath GObject-2.0.gir
 BUILT_GIRSOURCES += GObject-2.0.gir
diff --git a/gir/gio-2.0.c b/gir/gio-2.0.c
index 58b3c9e..d08da51 100644
--- a/gir/gio-2.0.c
+++ b/gir/gio-2.0.c
@@ -6,7 +6,13 @@
 /**
  * g_app_info_get_all:
  *
- * Returns: (element-type GAppInfo) (transfer full): 
+ * Returns: (element-type GAppInfo) (transfer full):
+ */
+
+/**
+ * g_app_info_get_all_for_type:
+ *
+ * Returns: (element-type GAppInfo) (transfer full):
  */
 
 /**
@@ -22,6 +28,13 @@
  */
 
 /**
+ * g_file_info_get_attribute_data:
+ *
+ * @value_pp: (out)
+ * Returns: (transfer none):
+ */
+
+/**
  * g_file_info_get_icon:
  *
  * Returns: (transfer none):
@@ -418,6 +431,11 @@
  */
 
 /**
+ * g_file_set_attributes_finish:
+ * @info: (out):
+ */
+
+/**
  * g_file_set_attributes_from_info:
  * @cancellable: (allow-none):
  */
@@ -590,3 +608,52 @@
  * Return value: (array zero-terminated=1) (transfer full):
  */
 
+/**
+ * g_themed_icon_get_names:
+ *
+ * Return value: (array zero-terminated=1) (transfer none):
+ */
+
+/**
+ * g_mount_guess_content_type_finish:
+ *
+ * Return value: (array zero-terminated=1) (transfer full):
+ */
+
+/**
+ * g_mount_guess_content_type_sync:
+ *
+ * Return value: (array zero-terminated=1) (transfer full):
+ */
+
+/**
+ * g_vfs_get_supported_uri_schemes:
+ *
+ * Return value: (array zero-terminated=1) (transfer none):
+ */
+
+/**
+ * g_volume_enumerate_identifiers:
+ *
+ * Return value: (array zero-terminated=1) (transfer full):
+ */
+
+/**
+ * g_drive_enumerate_identifiers:
+ *
+ * Return value: (array zero-terminated=1) (transfer full):
+ */
+
+/**
+ * g_mount_guess_content_type_finish:
+ *
+ * Return value: (array zero-terminated=1) (transfer full):
+ */
+
+/**
+ * g_content_type_guess_for_tree:
+ *
+ * Return value: (array zero-terminated=1) (transfer full):
+ */
+
+
diff --git a/gir/glib-2.0.c b/gir/glib-2.0.c
index b5a8eac..a46c535 100644
--- a/gir/glib-2.0.c
+++ b/gir/glib-2.0.c
@@ -1,7 +1,7 @@
 /**
  * g_file_get_contents:
- * @contents: (out): 
- * @length: (out) (allow-none): 
+ * @contents: (out):
+ * @length: (out) (allow-none):
  */
 
 /**
@@ -13,7 +13,7 @@
  * g_thread_init:
  * @vtable: (allow-none):
  */
- 
+
 /**
  * g_main_loop_new:
  * @context: (allow-none):
diff --git a/gir/gobject-2.0.c b/gir/gobject-2.0.c
new file mode 100644
index 0000000..adc9490
--- /dev/null
+++ b/gir/gobject-2.0.c
@@ -0,0 +1,10 @@
+
+/**
+ * g_object_add_weak_pointer:
+ * @weak_pointer_location: (inout)
+ */
+
+/**
+ * g_object_remove_weak_pointer:
+ * @weak_pointer_location: (inout)
+ */
diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py
index 0f5b0c9..7b4a0f0 100644
--- a/giscanner/glibtransformer.py
+++ b/giscanner/glibtransformer.py
@@ -746,12 +746,13 @@ class GLibTransformer(object):
             return_.transfer = PARAM_TRANSFER_FULL
             signal = GLibSignal(signal_info.attrib['name'], return_)
             for i, parameter in enumerate(signal_info.findall('param')):
+                pctype = parameter.attrib['type']
+                ptype = Type(self._transformer.parse_ctype(pctype), pctype)
                 if i == 0:
                     name = 'object'
+                    ptype.ctype += '*'
                 else:
                     name = 'p%s' % (i-1, )
-                pctype = parameter.attrib['type']
-                ptype = Type(self._transformer.parse_ctype(pctype), pctype)
                 param = Parameter(name, ptype)
                 param.transfer = 'none'
                 signal.parameters.append(param)


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