if (has_array_length) {
length_param_index = tag == "parameter" ? index + 1 : index;
}
- write_type (type, length_param_index, direction);
+
+ bool additional_indirection = direction != ParameterDirection.IN;
+ if (!additional_indirection && tag == "parameter" && !type.nullable) {
+ // pass non-simple structs always by reference
+ unowned Struct? st = type.type_symbol as Struct;
+ if (st != null && !st.is_simple_type ()) {
+ additional_indirection = true;
+ }
+ }
+
+ write_type (type, length_param_index, additional_indirection);
}
indent--;
buffer.append_printf (" glib:get-type=\"%sget_type\"", get_ccode_lower_case_prefix (symbol));
}
- private void write_type (DataType type, int index = -1, ParameterDirection direction = ParameterDirection.IN) {
+ private void write_type (DataType type, int index = -1, bool additional_indirection = false) {
if (type is ArrayType) {
var array_type = (ArrayType) type;
} else if (index != -1) {
buffer.append_printf (" length=\"%i\"", index);
}
- buffer.append_printf (" c:type=\"%s%s\"", get_ccode_name (array_type.element_type), direction == ParameterDirection.IN ? "*" : "**");
+ buffer.append_printf (" c:type=\"%s%s\"", get_ccode_name (array_type.element_type), !additional_indirection ? "*" : "**");
buffer.append_printf (">\n");
indent++;
buffer.append_printf ("<type name=\"none\" c:type=\"void\"/>\n");
} else if (type is PointerType) {
write_indent ();
- buffer.append_printf ("<type name=\"gpointer\" c:type=\"%s%s\"/>\n", get_ccode_name (type), direction == ParameterDirection.IN ? "" : "*");
+ buffer.append_printf ("<type name=\"gpointer\" c:type=\"%s%s\"/>\n", get_ccode_name (type), !additional_indirection ? "" : "*");
} else if (type is GenericType) {
// generic type parameters not supported in GIR
write_indent ();
} else if (type is DelegateType) {
var deleg_type = (DelegateType) type;
write_indent ();
- buffer.append_printf ("<type name=\"%s\" c:type=\"%s%s\"/>\n", gi_type_name (deleg_type.delegate_symbol), get_ccode_name (type), direction == ParameterDirection.IN ? "" : "*");
+ buffer.append_printf ("<type name=\"%s\" c:type=\"%s%s\"/>\n", gi_type_name (deleg_type.delegate_symbol), get_ccode_name (type), !additional_indirection ? "" : "*");
} else if (type.type_symbol != null) {
write_indent ();
string type_name = gi_type_name (type.type_symbol);
if ((type_name == "GLib.Array") || (type_name == "GLib.PtrArray")) {
is_array = true;
}
- buffer.append_printf ("<%s name=\"%s\" c:type=\"%s%s\"", is_array ? "array" : "type", gi_type_name (type.type_symbol), get_ccode_name (type), direction == ParameterDirection.IN ? "" : "*");
+ buffer.append_printf ("<%s name=\"%s\" c:type=\"%s%s\"", is_array ? "array" : "type", gi_type_name (type.type_symbol), get_ccode_name (type), !additional_indirection ? "" : "*");
List<DataType> type_arguments = type.get_type_arguments ();
if (type_arguments.size == 0) {
<field name="field" writable="1">
<type name="gint" c:type="gint"/>
</field>
+ <field name="struct_field" writable="1">
+ <type name="GirTest.Struct" c:type="GirTestStruct"/>
+ </field>
<field name="internal_field" writable="1">
<type name="gint" c:type="gint"/>
</field>
</parameter>
</parameters>
</method>
+ <method name="set" c:identifier="gir_test_boxed_struct_set">
+ <return-value transfer-ownership="full">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <instance-parameter name="self" transfer-ownership="none" nullable="1">
+ <type name="GirTest.BoxedStruct" c:type="GirTestBoxedStruct*"/>
+ </instance-parameter>
+ <parameter name="param1" transfer-ownership="none">
+ <type name="GirTest.BoxedStruct" c:type="GirTestBoxedStruct*"/>
+ </parameter>
+ </parameters>
+ </method>
</record>
<record name="Struct" c:type="GirTestStruct" c:symbol-prefix="struct">
<field name="field_name" writable="1">
</parameter>
</parameters>
</method>
+ <method name="set" c:identifier="gir_test_struct_set">
+ <return-value transfer-ownership="full">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <instance-parameter name="self" transfer-ownership="none" nullable="1">
+ <type name="GirTest.Struct" c:type="GirTestStruct*"/>
+ </instance-parameter>
+ <parameter name="param1" transfer-ownership="none">
+ <type name="GirTest.Struct" c:type="GirTestStruct*"/>
+ </parameter>
+ </parameters>
+ </method>
</record>
<record name="SkippedStruct" c:type="GirTestSkippedStruct" c:symbol-prefix="skipped_struct" glib:type-name="GirTestSkippedStruct" glib:get-type="gir_test_skipped_struct_get_type" introspectable="0">
<field name="field_name" writable="1">
</return-value>
<parameters>
<parameter name="param" transfer-ownership="none">
- <type name="GirTest.RenamedStruct" c:type="GirTestNamedStruct"/>
+ <type name="GirTest.RenamedStruct" c:type="GirTestNamedStruct*"/>
</parameter>
</parameters>
</function>
public BoxedStruct ret () {
return this;
}
+
+ public void @set (BoxedStruct param1) {
+ }
}
[CCode (has_type_id = false)]
public Struct ret () {
return this;
}
+
+ public void @set (Struct param1) {
+ }
}
[GIR (visible = false)]
public int field = 42;
+ public Struct struct_field;
+
internal int internal_field = 23;
public int fixed_array_field[23];
public int field;
public int fixed_array_field[23];
public string? nullable_field;
+ public GirTest.Struct struct_field;
public ObjectTest ();
public void array_in (int[] array);
public void array_inout (ref int[] array);
public BoxedStruct.foo (int param1, int param2);
public void inv ();
public GirTest.BoxedStruct ret ();
+ public void @set (GirTest.BoxedStruct param1);
}
[CCode (cheader_filename = "girtest.h")]
[GIR (name = "RenamedStruct")]
public Struct.foo (int param1, int param2);
public void inv ();
public GirTest.Struct ret ();
+ public void @set (GirTest.Struct param1);
}
[CCode (cheader_filename = "girtest.h")]
public enum EnumTest {
public int fixed_array_field[23];
public int internal_field;
public string? nullable_field;
+ public GirTest.Struct struct_field;
[CCode (has_construct_function = false)]
public ObjectTest ();
public void array_in ([CCode (array_length_cname = "array_length1", array_length_pos = 1.1)] int[] array);
public BoxedStruct.foo (int param1, int param2);
public void inv ();
public GirTest.BoxedStruct ret ();
+ public void @set (GirTest.BoxedStruct param1);
}
[CCode (cheader_filename = "girtest.h", cname = "GirTestNamedCompactClass", has_type_id = false)]
public struct RenamedCompactClass {
public Struct.foo (int param1, int param2);
public void inv ();
public GirTest.Struct ret ();
+ public void @set (GirTest.Struct param1);
}
[CCode (cheader_filename = "girtest.h", cprefix = "GIR_TEST_ENUM_TEST_", type_id = "gir_test_enum_test_get_type ()")]
public enum EnumTest {