[gobject-introspection/ebassi/property-annotation: 13/19] scanner: Add an heuristic for property getters
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/ebassi/property-annotation: 13/19] scanner: Add an heuristic for property getters
- Date: Wed, 28 Jul 2021 15:32:02 +0000 (UTC)
commit b4590c33d5bd891bdd282906d2c47366f66a4d7d
Author: Emmanuele Bassi <ebassi gnome org>
Date: Thu Jun 17 18:10:51 2021 +0100
scanner: Add an heuristic for property getters
If a property is boolean and read-only, the getter method can be the
same as the property name, for instance:
- gtk_widget_has_focus()
- gtk_media_stream_has_audio()
giscanner/maintransformer.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index dc8bd3c2..bca69697 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -1472,7 +1472,12 @@ method or constructor of some type."""
else:
setter = None
if prop.readable:
- getter = 'get_' + normalized_name
+ # Heuristic: read-only properties can have getters that are
+ # just the property name, like: gtk_widget_has_focus()
+ if not prop.writable and prop.type.is_equiv(ast.TYPE_BOOLEAN):
+ getter = normalized_name
+ else:
+ getter = 'get_' + normalized_name
else:
getter = None
for method in node.methods:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]