}
}
- ret = "%s_%s_".printf (prefix, get_ccode_marshaller_type_name (return_type));
+ if (return_type is ValueType && return_type.nullable) {
+ ret = "%s_POINTER_".printf (prefix);
+ } else {
+ ret = "%s_%s_".printf (prefix, get_ccode_marshaller_type_name (return_type));
+ }
if (params == null || params.size == 0) {
ret = ret + "_VOID";
return "const char*";
} else if (t.data_type is Class || t.data_type is Interface) {
return "gpointer";
+ } else if (t is ValueType && t.nullable) {
+ return "gpointer";
} else if (t.data_type is Struct) {
var st = (Struct) t.data_type;
if (st.is_simple_type ()) {
private string get_marshaller_signature (List<Parameter> params, DataType return_type) {
string signature;
- signature = "%s:".printf (get_ccode_marshaller_type_name (return_type));
+ if (return_type is ValueType && return_type.nullable) {
+ signature = "POINTER:";
+ } else {
+ signature = "%s:".printf (get_ccode_marshaller_type_name (return_type));
+ }
if (params == null || params.size == 0) {
signature = signature + "VOID";
} else {
get_value_function = "g_value_get_pointer";
} else if (p.variable_type is ErrorType) {
get_value_function = "g_value_get_pointer";
+ } else if (p.variable_type is ValueType && p.variable_type.nullable) {
+ get_value_function = "g_value_get_pointer";
} else {
get_value_function = get_ccode_get_value_function (p.variable_type.data_type);
}
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_take_string"));
} else if (return_type.data_type is Class || return_type.data_type is Interface) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_take_object"));
+ } else if (return_type is ValueType && return_type.nullable) {
+ set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_set_pointer"));
} else {
set_fc = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_set_value_function (return_type.data_type)));
}
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
} else if (sig.return_type is ErrorType) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
+ } else if (sig.return_type is ValueType && sig.return_type.nullable) {
+ csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
} else if (sig.return_type.data_type == null) {
csignew.add_argument (new CCodeConstant ("G_TYPE_NONE"));
} else {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
} else if (param.variable_type is ErrorType) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
+ } else if (param.variable_type is ValueType && param.variable_type.nullable) {
+ csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
} else {
csignew.add_argument (new CCodeConstant (get_ccode_type_id (param.variable_type.data_type)));
}
--- /dev/null
+enum Bar {
+ FAIL,
+ FOO,
+ BAR,
+ BAZ
+}
+
+public struct Manam {
+ public int i;
+ public int j;
+}
+
+class Foo : Object {
+ public signal Bar? bar ();
+ public signal Bar? bar2 (Bar? bar);
+
+ public signal Manam? manam ();
+ public signal Manam? manam2 (Manam? manam);
+
+ public void emit_bar () {
+ assert (bar () == Bar.FOO);
+ }
+
+ public void emit_bar2 () {
+ assert (bar2 (Bar.BAZ) == Bar.BAZ);
+ }
+
+ public void emit_manam () {
+ Manam? m = {23, 42};
+ assert (manam () == m);
+ }
+
+ public void emit_manam2 () {
+ Manam? m = {23, 42};
+ assert (manam2 ({23, 42}) == m);
+ }
+}
+
+Bar? callback_bar () {
+ return Bar.FOO;
+}
+
+Bar? callback_bar2 (Bar? bar) {
+ assert (bar == Bar.BAZ);
+ return bar;
+}
+
+Manam? callback_manam () {
+ return {23, 42};
+}
+
+Manam? callback_manam2 (Manam? manam) {
+ Manam? m = {23, 42};
+ assert (manam == m);
+ return manam;
+}
+
+void main () {
+ var foo = new Foo ();
+
+ foo.bar.connect (callback_bar);
+ foo.emit_bar ();
+ foo.bar2.connect (callback_bar2);
+ foo.emit_bar2 ();
+
+ foo.manam.connect (callback_manam);
+ foo.emit_manam ();
+ foo.manam2.connect (callback_manam2);
+ foo.emit_manam2 ();
+}