[gi-docgen/property-annotations: 2/3] gir: Parse new method attributes




commit 8bd1dab2824f9007d80e8f94582838cdc9584c0f
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sat Sep 25 17:51:11 2021 +0100

    gir: Parse new method attributes
    
    Starting from gobject-introspection 1.70, the introspection data now
    contains new attributes for the method elements:
    
     - glib:set-property="name"
     - glib:get-property="name"

 gidocgen/gir/ast.py    | 5 ++++-
 gidocgen/gir/parser.py | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gidocgen/gir/ast.py b/gidocgen/gir/ast.py
index b53b63e..4382941 100644
--- a/gidocgen/gir/ast.py
+++ b/gidocgen/gir/ast.py
@@ -369,9 +369,12 @@ class Function(Callable):
 
 
 class Method(Callable):
-    def __init__(self, name: str, identifier: str, instance_param: Parameter, throws: bool = False):
+    def __init__(self, name: str, identifier: str, instance_param: Parameter, throws: bool = False,
+                 set_property: T.Optional[str] = None, get_property: T.Optional[str] = None):
         super().__init__(name, None, identifier, throws)
         self.instance_param = instance_param
+        self.set_property = set_property
+        self.get_property = get_property
 
     def __contains__(self, param):
         if isinstance(param, Parameter) and param == self.instance_param:
diff --git a/gidocgen/gir/parser.py b/gidocgen/gir/parser.py
index 82ba73c..1d3b084 100644
--- a/gidocgen/gir/parser.py
+++ b/gidocgen/gir/parser.py
@@ -574,6 +574,8 @@ class GirParser:
         throws = node.attrib.get('throws', '0') == '1'
         shadows = node.attrib.get('shadows')
         shadowed_by = node.attrib.get('shadowed-by')
+        set_property = node.attrib.get(_glibns('set-property'))
+        get_property = node.attrib.get(_glibns('get-property'))
 
         child = node.find('core:return-value', GI_NAMESPACES)
         return_value = self._parse_return_value(child)
@@ -586,7 +588,8 @@ class GirParser:
         for child in children:
             params.append(self._parse_parameter(child))
 
-        res = ast.Method(name=name, identifier=identifier, instance_param=instance_param, throws=throws)
+        res = ast.Method(name=name, identifier=identifier, instance_param=instance_param, throws=throws,
+                         set_property=set_property, get_property=get_property)
         res.set_return_value(return_value)
         res.set_parameters(params)
         res.set_introspectable(node.attrib.get('introspectable', '1') != '0')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]