Commit 4a4caa86 authored by Didier 'Ptitjes's avatar Didier 'Ptitjes Committed by Jürg Billeter

GIR writer: Fix missing transfer-ownership attributes

Fix missing transfer-ownership attribute on parameters and return value.
Signed-off-by: default avatarDidier 'Ptitjes <ptitjes@free.fr>
parent f5e09e95
......@@ -398,7 +398,7 @@ public class Vala.GIRWriter : CodeVisitor {
if (instance_type != null) {
write_indent ();
stream.printf ("<parameter name=\"self\">\n");
stream.printf ("<parameter name=\"self\" transfer-ownership=\"none\">\n");
indent++;
write_type (instance_type);
......@@ -416,17 +416,23 @@ public class Vala.GIRWriter : CodeVisitor {
// in/out paramter
if (param.parameter_type.value_owned) {
stream.printf (" transfer-ownership=\"full\"");
} else {
stream.printf (" transfer-ownership=\"none\"");
}
} else if (param.direction == ParameterDirection.OUT) {
// out paramter
stream.printf (" direction=\"out\"");
if (param.parameter_type.value_owned) {
stream.printf (" transfer-ownership=\"full\"");
} else {
stream.printf (" transfer-ownership=\"none\"");
}
} else {
// normal in paramter
if (param.parameter_type.value_owned) {
stream.printf (" transfer-ownership=\"full\"");
} else {
stream.printf (" transfer-ownership=\"none\"");
}
}
stream.printf (">\n");
......@@ -531,7 +537,8 @@ public class Vala.GIRWriter : CodeVisitor {
write_params (m.get_parameters ());
write_return_type (CCodeBaseModule.get_data_type_for_symbol ((TypeSymbol) m.parent_symbol));
var datatype = CCodeBaseModule.get_data_type_for_symbol ((TypeSymbol) m.parent_symbol);
write_return_type (datatype, true);
indent--;
write_indent ();
......@@ -588,11 +595,13 @@ public class Vala.GIRWriter : CodeVisitor {
}
}
private void write_return_type (DataType type) {
private void write_return_type (DataType type, bool constructor = false) {
write_indent ();
stream.printf ("<return-value");
if (type.value_owned) {
if (type.value_owned || constructor) {
stream.printf (" transfer-ownership=\"full\"");
} else {
stream.printf (" transfer-ownership=\"none\"");
}
stream.printf (">\n");
indent++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment