string s = "hello";
Value v2 = s;
assert (v2.get_string () == s);
+
+ unowned string s2 = "world";
+ Value v3 = s2;
+ assert (v3.get_string () == s2);
}
void test_value_array () {
string s = "hello";
Value? v2 = s;
assert (v2.get_string () == s);
+
+ unowned string s2 = "world";
+ Value? v3 = s2;
+ assert (v3.get_string () == s2);
}
void test_nullable_value_array () {
Value va = sarray;
string[] sarray2 = (string[]) va;
- assert (sarray[1] == "vala");
+ assert (sarray2[1] == "vala");
+
+ unowned string[] sarray3 = (string[]) va;
+ assert (sarray3[2] == "world");
}
void main () {
}
}
+ if (context.profile == Profile.GOBJECT
+ && is_gvalue (context, inner.value_type) && !is_gvalue (context, value_type)) {
+ // GValue unboxing returns unowned value
+ value_type.value_owned = false;
+ }
+
inner.target_type = inner.value_type.copy ();
return !error;
return type.type_symbol != null && type.type_symbol.is_subtype_of (context.analyzer.gvariant_type.type_symbol);
}
+ bool is_gvalue (CodeContext context, DataType type) {
+ return type.type_symbol != null && type.type_symbol.is_subtype_of (context.analyzer.gvalue_type.type_symbol);
+ }
+
public override void emit (CodeGenerator codegen) {
inner.emit (codegen);