summaryrefslogtreecommitdiff
path: root/giscanner/annotationparser.py
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2021-06-17 14:14:09 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2021-08-05 17:47:29 +0100
commitf83e75ddb971561503dd3afb58edbaa2aaf6dc0e (patch)
treec64f069437b9e77798229a31d6b6f303637e016f /giscanner/annotationparser.py
parentb058ccaedad3c4d353abf3c1d0b490579e246fd0 (diff)
downloadgobject-introspection-f83e75ddb971561503dd3afb58edbaa2aaf6dc0e.tar.gz
Add annotations for property setters and getters
We need new annotations to allow library developers to associate a setter and a getter functions to a property definition.
Diffstat (limited to 'giscanner/annotationparser.py')
-rw-r--r--giscanner/annotationparser.py52
1 files changed, 48 insertions, 4 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index bf475d4c..3307327e 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -198,6 +198,7 @@ ANN_ELEMENT_TYPE = 'element-type'
ANN_FOREIGN = 'foreign'
ANN_GET_PROPERTY = 'get-property'
ANN_GET_VALUE_FUNC = 'get-value-func'
+ANN_GETTER = 'getter'
ANN_IN = 'in'
ANN_INOUT = 'inout'
ANN_METHOD = 'method'
@@ -210,6 +211,7 @@ ANN_RENAME_TO = 'rename-to'
ANN_SCOPE = 'scope'
ANN_SET_PROPERTY = 'set-property'
ANN_SET_VALUE_FUNC = 'set-value-func'
+ANN_SETTER = 'setter'
ANN_SKIP = 'skip'
ANN_TRANSFER = 'transfer'
ANN_TYPE = 'type'
@@ -230,6 +232,7 @@ GI_ANNS = [ANN_ALLOW_NONE,
ANN_FOREIGN,
ANN_GET_PROPERTY,
ANN_GET_VALUE_FUNC,
+ ANN_GETTER,
ANN_IN,
ANN_INOUT,
ANN_METHOD,
@@ -239,6 +242,7 @@ GI_ANNS = [ANN_ALLOW_NONE,
ANN_SCOPE,
ANN_SET_PROPERTY,
ANN_SET_VALUE_FUNC,
+ ANN_SETTER,
ANN_SKIP,
ANN_TRANSFER,
ANN_TYPE,
@@ -840,6 +844,18 @@ class GtkDocAnnotatable(object):
self._validate_annotation(position, ann_name, options, exact_n_options=1)
+ def _do_validate_getter(self, position, ann_name, options):
+ '''
+ Validate the ``(getter)`` annotation.
+
+ :param position: :class:`giscanner.message.Position` of the line in the source file
+ containing the annotation to be validated
+ :param ann_name: name of the annotation holding the options to validate
+ :param options: annotation options to validate
+ '''
+
+ self._validate_annotation(position, ann_name, options, exact_n_options=1)
+
def _do_validate_in(self, position, ann_name, options):
'''
Validate the ``(in)`` annotation.
@@ -987,6 +1003,18 @@ class GtkDocAnnotatable(object):
self._validate_annotation(position, ann_name, options, exact_n_options=1)
+ def _do_validate_setter(self, position, ann_name, options):
+ '''
+ Validate the ``(setter)`` annotation.
+
+ :param position: :class:`giscanner.message.Position` of the line in the source file
+ containing the annotation to be validated
+ :param ann_name: name of the annotation holding the options to validate
+ :param options: annotation options to validate
+ '''
+
+ self._validate_annotation(position, ann_name, options, exact_n_options=1)
+
def _do_validate_skip(self, position, ann_name, options):
'''
Validate the ``(skip)`` annotation.
@@ -1120,10 +1148,26 @@ class GtkDocCommentBlock(GtkDocAnnotatable):
'name', 'params', 'description', 'tags')
#: Valid annotation names for the GTK-Doc comment block identifier part.
- valid_annotations = (ANN_ATTRIBUTES, ANN_CONSTRUCTOR, ANN_FOREIGN, ANN_GET_PROPERTY,
- ANN_GET_VALUE_FUNC, ANN_METHOD, ANN_REF_FUNC, ANN_RENAME_TO,
- ANN_SET_PROPERTY, ANN_SET_VALUE_FUNC, ANN_SKIP, ANN_TRANSFER,
- ANN_TYPE, ANN_UNREF_FUNC, ANN_VALUE, ANN_VFUNC)
+ valid_annotations = (
+ ANN_ATTRIBUTES,
+ ANN_CONSTRUCTOR,
+ ANN_FOREIGN,
+ ANN_GET_PROPERTY,
+ ANN_GET_VALUE_FUNC,
+ ANN_GETTER,
+ ANN_METHOD,
+ ANN_REF_FUNC,
+ ANN_RENAME_TO,
+ ANN_SET_PROPERTY,
+ ANN_SET_VALUE_FUNC,
+ ANN_SETTER,
+ ANN_SKIP,
+ ANN_TRANSFER,
+ ANN_TYPE,
+ ANN_UNREF_FUNC,
+ ANN_VALUE,
+ ANN_VFUNC,
+ )
def __init__(self, name, position=None):
GtkDocAnnotatable.__init__(self, position)