[vala/staging] codegen: Apply G_PARAM_EXPLICIT_NOTIFY on properties with "notify = false"
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Apply G_PARAM_EXPLICIT_NOTIFY on properties with "notify = false"
- Date: Mon, 2 Apr 2018 19:21:14 +0000 (UTC)
commit 02e91469f06c5497240f92cf6f9eb5b6c20aa0a9
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Mar 31 21:45:03 2018 +0200
codegen: Apply G_PARAM_EXPLICIT_NOTIFY on properties with "notify = false"
This requires --target-glib=2.42 to be passed.
codegen/valagtypemodule.vala | 3 +++
tests/Makefile.am | 1 +
tests/objects/property-notify.vala | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 3e553ec..93f11da 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -2016,6 +2016,9 @@ public class Vala.GTypeModule : GErrorModule {
}
}
}
+ if (context.require_glib_version (2, 42) && !prop.notify) {
+ pflags = "%s%s".printf (pflags, " | G_PARAM_EXPLICIT_NOTIFY");
+ }
if (prop.version.deprecated) {
pflags = "%s%s".printf (pflags, " | G_PARAM_DEPRECATED");
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d4e4906..0645f2f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -235,6 +235,7 @@ TESTS = \
objects/methods.vala \
objects/paramspec.vala \
objects/properties.vala \
+ objects/property-notify.vala \
objects/regex.vala \
objects/signals.vala \
objects/signals-delegate.vala \
diff --git a/tests/objects/property-notify.vala b/tests/objects/property-notify.vala
new file mode 100644
index 0000000..d2e02b2
--- /dev/null
+++ b/tests/objects/property-notify.vala
@@ -0,0 +1,36 @@
+class Foo : Object {
+ [CCode (notify = false)]
+ public string foo { get; set; }
+
+ public string bar { get; set; }
+
+ public string manam { get; set; }
+}
+
+void fail () {
+ assert_not_reached ();
+}
+
+int counter;
+void count () {
+ counter++;
+}
+
+void main () {
+ var foo = new Foo ();
+
+ foo.notify["foo"].connect (fail);
+ //FIXME Requires --target-glib=2.42 for G_PARAM_EXPLICIT_NOTIFY to be actually added
+ //foo.set_property ("foo", "foo");
+ foo.foo = "foo";
+
+ counter = 0;
+ foo.notify["bar"].connect (count);
+ foo.bar = "bar";
+ assert (counter == 1);
+
+ counter = 0;
+ foo.notify["manam"].connect (count);
+ foo.set_property ("manam", "manam");
+ assert (counter == 1);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]