[vala/0.40] girparser: Move special handling for certain parameters to process_callable()
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] girparser: Move special handling for certain parameters to process_callable()
- Date: Tue, 21 Apr 2020 07:51:15 +0000 (UTC)
commit 4bda82a2e39ee4c66094d30cfee444cad66686d4
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Apr 19 18:20:41 2020 +0200
girparser: Move special handling for certain parameters to process_callable()
- Detect delegate throwing error when GLib.Error out-parameter exists
- Mark method as async based on finding an AsyncReadyCallback parameter
- Apply null-literal default-value for trailing GLib.Cancellable? parameters
vala/valagirparser.vala | 51 +++++++++++++++++++++++++------------------------
1 file changed, 26 insertions(+), 25 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 356bf21e3..cc46a0d00 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -3383,16 +3383,6 @@ public class Vala.GirParser : CodeVisitor {
}
var info = new ParameterInfo (param, array_length_idx, closure_idx,
destroy_idx, scope == "async");
-
- if (s is Method && scope == "async") {
- var unresolved_type = param.variable_type as UnresolvedType;
- if (unresolved_type != null && unresolved_type.unresolved_symbol.name
== "AsyncReadyCallback") {
- // GAsync-style method
- ((Method) s).coroutine = true;
- info.keep = false;
- }
- }
-
parameters.add (info);
pop_metadata ();
}
@@ -3400,18 +3390,6 @@ public class Vala.GirParser : CodeVisitor {
}
current.parameters = parameters;
- for (int param_n = parameters.size - 1 ; param_n >= 0 ; param_n--) {
- ParameterInfo pi = parameters[param_n];
- if (!pi.param.ellipsis && pi.param.initializer == null) {
- string type_string = pi.param.variable_type.to_string ();
- if (type_string == "Gio.Cancellable?") {
- pi.param.initializer = new Vala.NullLiteral ();
- } else {
- break;
- }
- }
- }
-
pop_node ();
end_element (element_name);
}
@@ -3893,10 +3871,11 @@ public class Vala.GirParser : CodeVisitor {
}
}
- // Do not mark out-parameters as nullable if they are simple-types,
- // since it would result in a boxed-type in vala
foreach (ParameterInfo info in parameters) {
- var type = info.param.variable_type;
+ unowned DataType type = info.param.variable_type;
+
+ // Do not mark out-parameters as nullable if they are simple-types,
+ // since it would result in a boxed-type in vala
if (info.param.direction == ParameterDirection.OUT && type.nullable) {
Struct? st = null;
if (type is UnresolvedType) {
@@ -3908,6 +3887,28 @@ public class Vala.GirParser : CodeVisitor {
type.nullable = false;
}
}
+
+ // Check and mark GAsync-style methods
+ if (info.is_async && s is Method) {
+ unowned UnresolvedType? unresolved_type = type as UnresolvedType;
+ if (unresolved_type != null && unresolved_type.unresolved_symbol.name ==
"AsyncReadyCallback") {
+ ((Method) s).coroutine = true;
+ info.keep = false;
+ }
+ }
+ }
+
+ // Add null-literal as default-value for trailing GLib.Cancellable parameters
+ for (int param_n = parameters.size - 1 ; param_n >= 0 ; param_n--) {
+ ParameterInfo info = parameters[param_n];
+ if (!info.param.ellipsis && info.param.initializer == null) {
+ string type_string = info.param.variable_type.to_string ();
+ if (type_string == "GLib.Cancellable?" || type_string == "Gio.Cancellable?") {
+ info.param.initializer = new Vala.NullLiteral ();
+ } else {
+ break;
+ }
+ }
}
if (parameters.size > 1) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]