[gi-docgen/property-annotations: 1/3] gir: Parse new property attributes
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gi-docgen/property-annotations: 1/3] gir: Parse new property attributes
- Date: Sat, 25 Sep 2021 17:06:37 +0000 (UTC)
commit 1aacb159445ee5c301feccbb9ed01996879d9c3e
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sat Sep 25 17:42:10 2021 +0100
gir: Parse new property attributes
Starting from gobject-introspection 1.70, we're going to get new
introspection annotations for property elements, namely:
- setter="method_name"
- getter="method_name"
We need to parse them and apply them to the ast.Property class.
gidocgen/gir/ast.py | 4 +++-
gidocgen/gir/parser.py | 5 ++++-
2 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gidocgen/gir/ast.py b/gidocgen/gir/ast.py
index 1973f40..b53b63e 100644
--- a/gidocgen/gir/ast.py
+++ b/gidocgen/gir/ast.py
@@ -458,7 +458,7 @@ class ErrorDomain(Enumeration):
class Property(GIRElement):
def __init__(self, name: str, transfer: str, target: Type, writable: bool = True, readable: bool = True,
construct: bool = False,
- construct_only: bool = False):
+ construct_only: bool = False, setter: T.Optional[str] = None, getter: T.Optional[str] =
None):
super().__init__(name)
self.transfer = transfer
self.writable = writable
@@ -466,6 +466,8 @@ class Property(GIRElement):
self.construct = construct
self.construct_only = construct_only
self.target = target
+ self.setter = setter
+ self.getter = getter
class Signal(GIRElement):
diff --git a/gidocgen/gir/parser.py b/gidocgen/gir/parser.py
index 076995d..82ba73c 100644
--- a/gidocgen/gir/parser.py
+++ b/gidocgen/gir/parser.py
@@ -707,12 +707,15 @@ class GirParser:
construct_only = node.attrib.get('construct-only', '0') == '1'
construct = node.attrib.get('construct', '0') == '1'
transfer = node.attrib.get('transfer-ownership')
+ setter = node.attrib.get('setter')
+ getter = node.attrib.get('getter')
ctype = self._parse_ctype(node)
res = ast.Property(name=name, transfer=transfer, target=ctype,
writable=writable, readable=readable,
- construct=construct, construct_only=construct_only)
+ construct=construct, construct_only=construct_only,
+ setter=setter, getter=getter)
res.set_introspectable(node.attrib.get('introspectable', '1') != '0')
res.set_version(node.attrib.get('version'))
self._maybe_parse_docs(node, res)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]