[vala/0.36: 114/212] girparser: Don't mark simple-type out-parameters with '?' as nullable
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.36: 114/212] girparser: Don't mark simple-type out-parameters with '?' as nullable
- Date: Sat, 14 Apr 2018 07:52:56 +0000 (UTC)
commit 990a5aadc42ef8bcfa87e9f1b355fe2e5d81c831
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Dec 11 09:08:25 2017 +0100
girparser: Don't mark simple-type out-parameters with '?' as nullable
Using '?' on simple-types has a different meaning in vala and would create
a boxed-type which is not compatible with the original type.
vala/valagirparser.vala | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index f06a61b..22c3dd4 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -3750,6 +3750,24 @@ 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;
+ if (info.param.direction == ParameterDirection.OUT && type.nullable) {
+ Struct? st = null;
+ if (type is UnresolvedType) {
+ st = resolve_symbol (node.parent, ((UnresolvedType)
type).unresolved_symbol) as Struct;
+ } else if (type is ValueType) {
+ st = type.data_type as Struct;
+ }
+ if (st != null && st.is_simple_type ()) {
+ type.nullable = false;
+ }
+ }
+ }
+
if (parameters.size > 1) {
ParameterInfo last_param = parameters[parameters.size-1];
if (last_param.param.ellipsis) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]