summaryrefslogtreecommitdiff
path: root/girepository/girparser.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/girparser.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/girparser.c')
-rw-r--r--girepository/girparser.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/girepository/girparser.c b/girepository/girparser.c
index b6983d1a..2d30f201 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -807,6 +807,8 @@ start_function (GMarkupParseContext *context,
const gchar *symbol;
const gchar *deprecated;
const gchar *throws;
+ const gchar *set_property;
+ const gchar *get_property;
GIrNodeFunction *function;
gboolean found = FALSE;
ParseState in_embedded_state = STATE_NONE;
@@ -854,6 +856,8 @@ start_function (GMarkupParseContext *context,
symbol = find_attribute ("c:identifier", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
throws = find_attribute ("throws", attribute_names, attribute_values);
+ set_property = find_attribute ("glib:set-property", attribute_names, attribute_values);
+ get_property = find_attribute ("glib:get-property", attribute_names, attribute_values);
if (name == NULL)
{
@@ -889,6 +893,25 @@ start_function (GMarkupParseContext *context,
function->is_constructor = TRUE;
else
function->is_constructor = FALSE;
+
+ if (set_property != NULL)
+ {
+ function->is_setter = TRUE;
+ function->is_getter = FALSE;
+ function->property = g_strdup (set_property);
+ }
+ else if (get_property != NULL)
+ {
+ function->is_setter = FALSE;
+ function->is_getter = TRUE;
+ function->property = g_strdup (get_property);
+ }
+ else
+ {
+ function->is_setter = FALSE;
+ function->is_getter = FALSE;
+ function->property = NULL;
+ }
}
else
{