diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2019-10-02 19:07:17 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2019-10-03 15:15:46 +0200 |
commit | c054da918a40f8ef93c1a006034fb6ab4717c135 (patch) | |
tree | 8d507d7d5924696de01edc0c8b4a5cb452c577b6 /tests/delegates | |
parent | ca7ab54681593a25b51c118e9aba40f44adf3f3d (diff) | |
download | vala-c054da918a40f8ef93c1a006034fb6ab4717c135.tar.gz |
vala: Add DelegateType.target/destroy fields to access its user-data
Fixes https://gitlab.gnome.org/GNOME/vala/issues/857
Diffstat (limited to 'tests/delegates')
-rw-r--r-- | tests/delegates/member-target-destroy.vala | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/delegates/member-target-destroy.vala b/tests/delegates/member-target-destroy.vala new file mode 100644 index 000000000..468bff95f --- /dev/null +++ b/tests/delegates/member-target-destroy.vala @@ -0,0 +1,23 @@ +delegate string Foo (); + +string bar (string s) { + return s; +} + +void foo_free (void* data) { + GLib.free (data); +} + +void main () { + Foo foo = (Foo) bar; + assert (foo.target == null); + assert (foo.destroy == null); + + string* foo_data = "foo".dup (); + foo.target = foo_data; + foo.destroy = (GLib.DestroyNotify) foo_free; + + assert (foo () == "foo"); + assert (foo.target == foo_data); + assert (foo.destroy == (GLib.DestroyNotify) foo_free); +} |