ccode.add_assignment (new CCodeIdentifier ("boxed"), cgetcall);
ccall.add_argument (new CCodeIdentifier ("boxed"));
+ var cisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeIdentifier ("boxed"), new CCodeConstant ("NULL"));
var cstrvlen = new CCodeFunctionCall (new CCodeIdentifier ("g_strv_length"));
cstrvlen.add_argument (new CCodeIdentifier ("boxed"));
- ccall.add_argument (cstrvlen);
+ var ccond = new CCodeConditionalExpression (cisnull, new CCodeConstant ("0"), cstrvlen);
+
+ ccall.add_argument (ccond);
ccode.add_expression (ccall);
ccode.close ();
} else {
--- /dev/null
+public class Foo : Object {
+ public string[]? strings {
+ get { return this._strings; }
+ set { this._strings = value; }
+ }
+
+ private string[]? _strings;
+}
+
+void main() {
+ string[]? strings;
+ var f = new Foo();
+
+ f.set("strings", new string[]{ "foo", "bar" });
+ f.get("strings", out strings);
+ assert (strings[0] == "foo");
+ assert (strings[1] == "bar");
+
+ f.set("strings", null);
+ f.get("strings", out strings);
+ assert(strings == null);
+
+ f.set("strings", new string[]{ "foo", "bar" });
+ f.get("strings", out strings);
+ assert (strings[0] == "foo");
+ assert (strings[1] == "bar");
+}