GNOME Bugzilla – Bug 620484
Support the (transfer) annotation for properties.
Last modified: 2015-02-07 16:58:16 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.
Created attachment 162659 [details] [review] Support the (transfer) annotation for properties.
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
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.
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.
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 :/
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.
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.
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.
Review of attachment 163067 [details] [review]: Looks great, ship it! Thanks for doing the work on this.
Attachment 163067 [details] pushed as 22ae017 - Support the (transfer) annotation for properties.
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]