gir/delegate-error-pos.test \
gir/enum.test \
gir/errordomain.test \
+ gir/instance-parameter-owned.test \
gir/method-array-length-type.test \
gir/parameter-array-length-type.test \
gir/parameter-nullable-out-simple-type.test \
--- /dev/null
+GIR
+
+Input:
+
+<record name="Foo"
+ c:type="TestFoo"
+ glib:type-name="TestFoo"
+ glib:get-type="test_foo_get_type"
+ c:symbol-prefix="foo">
+ <constructor name="new" c:identifier="test_foo_new">
+ <return-value transfer-ownership="full">
+ <type name="Transform" c:type="TestFoo*"/>
+ </return-value>
+ </constructor>
+ <method name="bar" c:identifier="test_foo_bar">
+ <return-value transfer-ownership="full">
+ <type name="Foo" c:type="TestFoo*"/>
+ </return-value>
+ <parameters>
+ <instance-parameter name="self"
+ transfer-ownership="full">
+ <type name="Foo" c:type="TestFoo*"/>
+ </instance-parameter>
+ </parameters>
+ </method>
+ <method name="baz" c:identifier="test_foo_baz">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <instance-parameter name="self"
+ transfer-ownership="full">
+ <type name="Foo" c:type="TestFoo*"/>
+ </instance-parameter>
+ </parameters>
+ </method>
+</record>
+
+Output:
+
+[CCode (cheader_filename = "test.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "test_foo_get_type ()")]
+[Compact]
+public class Foo {
+ [CCode (has_construct_function = false)]
+ public Foo ();
+ [DestroysInstance]
+ public Test.Foo bar ();
+ [DestroysInstance]
+ public void baz ();
+}
while (current_token == MarkupTokenType.START_ELEMENT) {
current_parameter_idx++;
- if (reader.name == "instance-parameter" &&
- !(symbol_type == "function" || symbol_type == "constructor")) {
- skip_element ();
- continue;
- }
+ var is_instance_parameter = (reader.name == "instance-parameter"
+ && !(symbol_type == "function" || symbol_type == "constructor"));
if (instance_idx > -2 && instance_idx == current_parameter_idx) {
skip_element ();
Comment? param_comment;
default_param_name = "arg%d".printf (parameters.size);
var param = parse_parameter (out array_length_idx, out closure_idx, out destroy_idx, out scope, out param_comment, default_param_name);
+
+ if (is_instance_parameter) {
+ unowned Method? m = s as Method;
+ if (m != null) {
+ if (param.direction == ParameterDirection.IN) {
+ if (param.variable_type.value_owned) {
+ m.set_attribute ("DestroysInstance", true);
+ }
+ pop_metadata ();
+ continue;
+ } else {
+ //TODO can more be done here?
+ m.binding = MemberBinding.STATIC;
+ }
+ }
+ }
+
if (array_length_idx != -1) {
if (instance_idx > -2 && instance_idx < array_length_idx) {
array_length_idx--;