diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2018-05-30 17:02:42 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2018-05-31 13:14:00 +0200 |
commit | 0efcee2892c805d15fe46d4c9197669a0c51ad5f (patch) | |
tree | aceb3f7921d26594c21199216bc41623811f3a5a /tests/delegates | |
parent | 72fab93ba9a5027fbdd30cabfa5cd32482dad07f (diff) | |
download | vala-0efcee2892c805d15fe46d4c9197669a0c51ad5f.tar.gz |
codegen: Handle delegate_target attribute of fields
Delegate fields without a delegate target don't require special handling
on copy/destroy.
Fixes https://gitlab.gnome.org/GNOME/vala/issues/520
Diffstat (limited to 'tests/delegates')
-rw-r--r-- | tests/delegates/fields-no-target.vala | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/delegates/fields-no-target.vala b/tests/delegates/fields-no-target.vala new file mode 100644 index 000000000..ad328deeb --- /dev/null +++ b/tests/delegates/fields-no-target.vala @@ -0,0 +1,39 @@ +public delegate void FooFunc (); + +[CCode (delegate_target = false)] +public FooFunc func; + +public struct Foo { + [CCode (delegate_target = false)] + public FooFunc func; + public int i; +} + +public class Bar { + [CCode (delegate_target = false)] + public FooFunc func; + public int i; +} + +void foo_cb () { +} + +const Foo[] foos = { + { foo_cb, 42 } +}; + +void main() { + func = foo_cb; + + Foo f_stack = { foo_cb, 23 }; + Foo? f_heap = { foo_cb, 4711 }; + + assert (f_stack.i == 23); + assert (f_heap.i == 4711); + assert (foos[0].i == 42); + + Bar b = new Bar (); + b.func = foo_cb; + b.i = 42; +} + |