summaryrefslogtreecommitdiff
path: root/girepository/girnode.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2021-06-16 19:17:27 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2021-08-05 17:47:29 +0100
commit3ec400b09fb15c9f7392b77b0c3fb324ee08beed (patch)
tree39776e85364d56a1b13c1a8773af6b771b6c14b3 /girepository/girnode.c
parent700e8776b7942b204b86748d266c895b08d59823 (diff)
downloadgobject-introspection-3ec400b09fb15c9f7392b77b0c3fb324ee08beed.tar.gz
Add new annotations for property accessors
We introduce two new annotations: - (set-property PROPERTY_NAME) - (get-property PROPERTY_NAME) These annotations are valid inside function blocks for methods on objects and interfaces, and define whether a function is a property accessor, e.g.: /** * gtk_widget_set_name: (set-property name) * @self: ... * @name: ... * * ... */ /** * gtk_widget_get_name: (get-property name) * @self: ... * * ... * * Returns: ... */ The annotations are transformed into the GIR data as attributes: - glib:set-property="PROPERTY_NAME" - glib:get-property="PROPERTY_NAME" The underlying typelib data has had flags for setter and getter functions for a while, but they have never been plugged into the GIR data or the introspection scanner. Now they are; you can retrieve the GIPropertyInfo from a GIFunctionInfo that has the GI_FUNCTION_IS_SETTER or GI_FUNCTION_IS_GETTER flags set. Fixes: #13
Diffstat (limited to 'girepository/girnode.c')
-rw-r--r--girepository/girnode.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/girepository/girnode.c b/girepository/girnode.c
index 796f2001..5e74b0b0 100644
--- a/girepository/girnode.c
+++ b/girepository/girnode.c
@@ -218,6 +218,7 @@ _g_ir_node_free (GIrNode *node)
g_free (node->name);
g_free (function->symbol);
+ g_free (function->property);
_g_ir_node_free ((GIrNode *)function->result);
for (l = function->parameters; l; l = l->next)
_g_ir_node_free ((GIrNode *)l->data);
@@ -1648,8 +1649,8 @@ _g_ir_node_build_typelib (GIrNode *node,
blob->blob_type = BLOB_TYPE_FUNCTION;
blob->deprecated = function->deprecated;
blob->is_static = !function->is_method;
- blob->setter = function->is_setter;
- blob->getter = function->is_getter;
+ blob->setter = FALSE;
+ blob->getter = FALSE;
blob->constructor = function->is_constructor;
blob->wraps_vfunc = function->wraps_vfunc;
blob->throws = function->throws; /* Deprecated. Also stored in SignatureBlob. */
@@ -1658,6 +1659,21 @@ _g_ir_node_build_typelib (GIrNode *node,
blob->symbol = _g_ir_write_string (function->symbol, strings, data, offset2);
blob->signature = signature;
+ if (function->is_setter || function->is_getter)
+ {
+ int index = get_index_of_member_type ((GIrNodeInterface*)parent,
+ G_IR_NODE_PROPERTY,
+ function->property);
+ if (index == -1)
+ {
+ g_error ("Unknown property %s for accessor %s", function->property, node->name);
+ }
+
+ blob->setter = function->is_setter;
+ blob->getter = function->is_getter;
+ blob->index = (guint) index;
+ }
+
/* function->result is special since it doesn't appear in the serialized format but
* we do want the attributes for it to appear
*/