After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 620484 - Support the (transfer) annotation for properties.
Support the (transfer) annotation for properties.
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2010-06-03 14:47 UTC by Tomeu Vizoso
Modified: 2015-02-07 16:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Support the (transfer) annotation for properties. (18.43 KB, patch)
2010-06-03 14:47 UTC, Tomeu Vizoso
none Details | Review
Support the (transfer) annotation for properties. (22.97 KB, patch)
2010-06-07 10:24 UTC, Tomeu Vizoso
none Details | Review
Support the (transfer) annotation for properties. (22.79 KB, patch)
2010-06-07 13:38 UTC, Tomeu Vizoso
reviewed Details | Review
Support the (transfer) annotation for properties. (23.69 KB, patch)
2010-06-07 17:24 UTC, Tomeu Vizoso
accepted-commit_now Details | Review
Support the (transfer) annotation for properties. (25.09 KB, patch)
2010-06-08 14:42 UTC, Tomeu Vizoso
committed Details | Review

Description Tomeu Vizoso 2010-06-03 14:47:05 UTC
* girepository/*: Add g_property_info_get_ownership_transfer() and write
  the transfer attribute of properties into the typelib.

* giscanner/*: Parse the (transfer) annotation and write it into the .gir.

* tools/generate.c: Read the transfer annotation for properties and write
  to the .tgir.
Comment 1 Tomeu Vizoso 2010-06-03 14:47:07 UTC
Created attachment 162659 [details] [review]
Support the (transfer) annotation for properties.
Comment 2 Johan (not receiving bugmail) Dahlin 2010-06-05 00:33:47 UTC
Review of attachment 162659 [details] [review]:

Looks quite good. Maybe Colin should take a look at the typelib changes.

::: girepository/ginfo.c
@@ +1973,3 @@
+ *
+ * Obtain the ownership transfer for this property.
+ * #GITransfer contains a list of possible values.

See #GITransfer for more information about transfer values

::: girepository/girepository.h
@@ +535,3 @@
 GParamFlags             g_property_info_get_flags                (GIPropertyInfo         *info);
 GITypeInfo *            g_property_info_get_type                 (GIPropertyInfo         *info);
+GITransfer              g_property_info_get_ownership_transfer   (GIPropertyInfo         *info);

Should be added to docs/reference/gi-sections.txt as well.

::: tools/generate.c
@@ +971,3 @@
     xml_printf (file, " construct-only=\"1\"");
 
+  switch (g_property_info_get_ownership_transfer (info))

This could be refactored and shared with the other GITransfer function
Comment 3 Tomeu Vizoso 2010-06-07 10:24:45 UTC
Created attachment 162917 [details] [review]
Support the (transfer) annotation for properties.

* girepository/*: Add g_property_info_get_ownership_transfer() and write
  the transfer attribute of properties into the typelib.

* giscanner/*: Parse the (transfer) annotation and write it into the .gir.

* tools/generate.c: Read the transfer annotation for properties and write
  to the .tgir.
Comment 4 Tomeu Vizoso 2010-06-07 13:38:55 UTC
Created attachment 162933 [details] [review]
Support the (transfer) annotation for properties.

* girepository/*: Add g_property_info_get_ownership_transfer() and write
  the transfer attribute of properties into the typelib.

* giscanner/*: Parse the (transfer) annotation and write it into the .gir.

* tools/generate.c: Read the transfer annotation for properties and write
  to the .tgir.
Comment 5 Johan (not receiving bugmail) Dahlin 2010-06-07 14:06:05 UTC
Review of attachment 162933 [details] [review]:

::: gir/everything.c
@@ +1676,3 @@
+
+  /**
+   * TestObj:hash-table:

Makes sense to test a list here too I think

::: girepository/gipropertyinfo.h
@@ +36,3 @@
 GParamFlags  g_property_info_get_flags (GIPropertyInfo *info);
 GITypeInfo * g_property_info_get_type  (GIPropertyInfo *info);
+GITransfer g_property_info_get_ownership_transfer (GIPropertyInfo *info);

Should be aligned.

::: girepository/girparser.c
@@ +848,3 @@
+      g_warning ("required attribute 'transfer-ownership' missing");
+    else
+      g_warning ("required attribute 'transfer-ownership' for function '%s'", name);

You need to update this to show the class/interface and the property name instead of the 'function' you copied this code from ;-)

@@ +867,3 @@
+  else
+    {
+      g_warning ("Unknown transfer-ownership value: %s", transfer);

Should show class/interface & prop name as well

::: girepository/gitypelib-internal.h
@@ +816,3 @@
  * @construct:
  * @construct_only: The ParamFlags used when registering the property.
+ * @transfer_ownership: For writes, indicates that the object to whom belongs

Can't really parse this documentation string

::: giscanner/annotationparser.py
@@ +423,3 @@
+        transfer_tag = self._get_tag(block, TAG_TRANSFER)
+        if transfer_tag is not None:
+            options = {OPT_TRANSFER: Option(transfer_tag.value)}

Missing spaces. eg: { OPT_TRANSFER: Option(Transfer_tag.value) }

::: tests/scanner/annotation.c
@@ +154,3 @@
+   * AnnotationObject:hashtable-property:
+   *
+   * Type: GLib.HashTable<utf8,int8>

This seems to be tested by the added everything api already.

::: tools/generate.c
@@ +192,2 @@
 static void
+write_ownership_transfer (GITransfer transfer,

Sorry, this will conflict I broke this again :/
Comment 6 Tomeu Vizoso 2010-06-07 17:24:50 UTC
Created attachment 162954 [details] [review]
Support the (transfer) annotation for properties.

* girepository/*: Add g_property_info_get_ownership_transfer() and write
  the transfer attribute of properties into the typelib.

* giscanner/*: Parse the (transfer) annotation and write it into the .gir.

* tools/generate.c: Read the transfer annotation for properties and write
  to the .tgir.
Comment 7 Johan (not receiving bugmail) Dahlin 2010-06-07 17:39:54 UTC
Review of attachment 162954 [details] [review]:

Looking good to me, a few details left to be sorted out. The GITransfer needs to be extended quite a bit
to explain how a transfer works, I added a set of proposed changes for that.

::: girepository/girparser.c
@@ +1309,3 @@
 	  iface = (GIrNodeInterface *)CURRENT_NODE (ctx);
+
+          parse_property_transfer (property, transfer, name, iface->gtype_name);

Would be preferable to send in the name of the interface or class, which is not necessarily the gtype name.

::: girepository/gitypes.h
@@ +243,3 @@
  * GITransfer:
+ * @GI_TRANSFER_NOTHING: transfer nothing to the callee, caller or the type
+ * to which belongs the property.

transfer nothing from the callee (function or the type instance the property belongs to) to the caller. The callee retains the ownership of the transfer and the caller, doesn't need to do anything to free up the resources of this transfer.

@@ +246,1 @@
  * @GI_TRANSFER_CONTAINER: transfer the container (eg list, array,

transfer the container (list, array, hash table) from the callee to the caller. The callee retains
the ownership of the individual items in the container and the caller has to free up the container resources (g_list_free()/g_hash_table_destroy() etc) of this transfer.

@@ +246,3 @@
  * @GI_TRANSFER_CONTAINER: transfer the container (eg list, array,
  * hashtable), but no the contents to the caller.
+ * @GI_TRANSFER_EVERYTHING: transfer everything to the callee, caller or the

transfer everything, eg the container and its contents from the callee to the caller. This is the case when the callee creates a copy of all the data it returns. The caller is responsible for cleaning up the container and item resources of this transfer.

@@ +250,3 @@
  *
+ * Represent the transfer ownership information of a #GICallableInfo, a
+ * #GIArgInfo or a #GIPropertyInfo.

The transfer is the exchange of data between two parts, from the callee to the caller. The callee is either a function/method/signal or an object/interface where a property is defined. The caller is the side accessing a property or calling a function.

#GITransfer specifies who's responsible for freeing the resources after the ownership transfer is complete. In case of a containing type such as a list, an array or a hash table the container itself is specified differently from the items within the container itself. Each container is freed differently, check the documentation for the types themselves for information on how to free them.
Comment 8 Tomeu Vizoso 2010-06-08 14:42:10 UTC
Created attachment 163067 [details] [review]
Support the (transfer) annotation for properties.

* girepository/*: Add g_property_info_get_ownership_transfer() and write
  the transfer attribute of properties into the typelib.

* giscanner/*: Parse the (transfer) annotation and write it into the .gir.

* tools/generate.c: Read the transfer annotation for properties and write
  to the .tgir.
Comment 9 Johan (not receiving bugmail) Dahlin 2010-06-08 15:34:01 UTC
Review of attachment 163067 [details] [review]:

Looks great, ship it! Thanks for doing the work on this.
Comment 10 Tomeu Vizoso 2010-06-08 15:35:47 UTC
Attachment 163067 [details] pushed as 22ae017 - Support the (transfer) annotation for properties.
Comment 11 André Klapper 2015-02-07 16:58:16 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]