diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2018-10-21 10:34:28 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2019-01-08 18:14:04 +0100 |
commit | dd304f4d8ace88491a7c93e6939bc577fd2f7eaf (patch) | |
tree | 38b319213c96182235f2ff7c851b400379b138be /vala | |
parent | afb9ea9687db1ca95ff169016e605f04e650cdfb (diff) | |
download | vala-dd304f4d8ace88491a7c93e6939bc577fd2f7eaf.tar.gz |
vala: Async methods don't allow out-parameters before in-parameters
out-parameters are always handled in the *_finish implementation and
therefore are asynchronous. Report an error for occurances in source
and a warning for GIR sources where convert them to pointer-types to
create a usuable signature for bindings.
Fixes https://gitlab.gnome.org/GNOME/vala/issues/636
Diffstat (limited to 'vala')
-rw-r--r-- | vala/valagirparser.vala | 14 | ||||
-rw-r--r-- | vala/valamethod.vala | 14 |
2 files changed, 28 insertions, 0 deletions
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala index 061eb17c5..e522d3029 100644 --- a/vala/valagirparser.vala +++ b/vala/valagirparser.vala @@ -4073,6 +4073,20 @@ public class Vala.GirParser : CodeVisitor { void process_async_method (Node node) { var m = (Method) node.symbol; + + // TODO: async methods with out-parameters before in-parameters are not supported + bool requires_pointer = false; + foreach (var param in m.get_parameters ()) { + if (param.direction == ParameterDirection.IN) { + requires_pointer = true; + } else if (requires_pointer) { + param.direction = ParameterDirection.IN; + param.variable_type.nullable = false; + param.variable_type = new PointerType (param.variable_type); + Report.warning (param.source_reference, "Synchronous out-parameters are not supported in async methods"); + } + } + string finish_method_base; if (m.name == null) { assert (m is CreationMethod); diff --git a/vala/valamethod.vala b/vala/valamethod.vala index bd203ab36..22980085f 100644 --- a/vala/valamethod.vala +++ b/vala/valamethod.vala @@ -815,6 +815,20 @@ public class Vala.Method : Subroutine, Callable { } } + if (coroutine) { + // TODO: async methods with out-parameters before in-parameters are not supported + bool requires_pointer = false; + for (int i = parameters.size - 1; i >= 0; i--) { + var param = parameters[i]; + if (param.direction == ParameterDirection.IN) { + requires_pointer = true; + } else if (requires_pointer) { + error = true; + Report.error (param.source_reference, "Synchronous out-parameters are not supported in async methods"); + } + } + } + if (error_types != null) { foreach (DataType error_type in error_types) { error_type.check (context); |