Commit c7ecbdf2 authored by Luca Bruno's avatar Luca Bruno

Fix gir and gidl bindings due to (unowned type)[] arrays

parent d755a231
...@@ -1594,6 +1594,7 @@ public class Vala.GirParser : CodeVisitor { ...@@ -1594,6 +1594,7 @@ public class Vala.GirParser : CodeVisitor {
} }
if (array_data != null && array_data.length != 0) { if (array_data != null && array_data.length != 0) {
type.value_owned = true;
type = new ArrayType (type, (int) array_data.length - 1, source_reference); type = new ArrayType (type, (int) array_data.length - 1, source_reference);
} }
...@@ -1627,6 +1628,7 @@ public class Vala.GirParser : CodeVisitor { ...@@ -1627,6 +1628,7 @@ public class Vala.GirParser : CodeVisitor {
} }
if (!(type is ArrayType) && metadata.get_bool (ArgumentType.ARRAY)) { if (!(type is ArrayType) && metadata.get_bool (ArgumentType.ARRAY)) {
type.value_owned = true;
type = new ArrayType (type, 1, type.source_reference); type = new ArrayType (type, 1, type.source_reference);
changed = true; changed = true;
} }
...@@ -2371,6 +2373,7 @@ public class Vala.GirParser : CodeVisitor { ...@@ -2371,6 +2373,7 @@ public class Vala.GirParser : CodeVisitor {
} }
next (); next ();
var element_type = parse_type (); var element_type = parse_type ();
element_type.value_owned = true;
end_element ("array"); end_element ("array");
return new ArrayType (element_type, 1, src); return new ArrayType (element_type, 1, src);
} }
...@@ -2418,7 +2421,9 @@ public class Vala.GirParser : CodeVisitor { ...@@ -2418,7 +2421,9 @@ public class Vala.GirParser : CodeVisitor {
} else if (type_name == "gpointer") { } else if (type_name == "gpointer") {
type = new PointerType (new VoidType (get_current_src ()), get_current_src ()); type = new PointerType (new VoidType (get_current_src ()), get_current_src ());
} else if (type_name == "GObject.Strv") { } else if (type_name == "GObject.Strv") {
type = new ArrayType (new UnresolvedType.from_symbol (new UnresolvedSymbol (null, "string")), 1, get_current_src ()); var element_type = new UnresolvedType.from_symbol (new UnresolvedSymbol (null, "string"));
element_type.value_owned = true;
type = new ArrayType (element_type, 1, get_current_src ());
no_array_length = true; no_array_length = true;
array_null_terminated = true; array_null_terminated = true;
} else { } else {
......
...@@ -602,6 +602,7 @@ public class Vala.GIdlParser : CodeVisitor { ...@@ -602,6 +602,7 @@ public class Vala.GIdlParser : CodeVisitor {
} }
} else if (nv[0] == "is_array") { } else if (nv[0] == "is_array") {
if (eval (nv[1]) == "1") { if (eval (nv[1]) == "1") {
return_type.value_owned = true;
return_type = new ArrayType (return_type, 1, return_type.source_reference); return_type = new ArrayType (return_type, 1, return_type.source_reference);
cb.return_type = return_type; cb.return_type = return_type;
} }
...@@ -685,6 +686,7 @@ public class Vala.GIdlParser : CodeVisitor { ...@@ -685,6 +686,7 @@ public class Vala.GIdlParser : CodeVisitor {
} }
} else if (nv[0] == "is_array") { } else if (nv[0] == "is_array") {
if (eval (nv[1]) == "1") { if (eval (nv[1]) == "1") {
param_type.value_owned = true;
param_type = new ArrayType (param_type, 1, param_type.source_reference); param_type = new ArrayType (param_type, 1, param_type.source_reference);
p.variable_type = param_type; p.variable_type = param_type;
if (!out_requested) { if (!out_requested) {
...@@ -1882,6 +1884,7 @@ public class Vala.GIdlParser : CodeVisitor { ...@@ -1882,6 +1884,7 @@ public class Vala.GIdlParser : CodeVisitor {
if (type == null) { if (type == null) {
return element_type; return element_type;
} }
element_type.value_owned = true;
return new ArrayType (element_type, 1, element_type.source_reference); return new ArrayType (element_type, 1, element_type.source_reference);
} else if (type_node.tag == TypeTag.LIST) { } else if (type_node.tag == TypeTag.LIST) {
type.unresolved_symbol = new UnresolvedSymbol (new UnresolvedSymbol (null, "GLib"), "List"); type.unresolved_symbol = new UnresolvedSymbol (new UnresolvedSymbol (null, "GLib"), "List");
...@@ -1915,6 +1918,7 @@ public class Vala.GIdlParser : CodeVisitor { ...@@ -1915,6 +1918,7 @@ public class Vala.GIdlParser : CodeVisitor {
} else if (n == "guchar" || n == "guint8") { } else if (n == "guchar" || n == "guint8") {
type.unresolved_symbol = new UnresolvedSymbol (null, "uchar"); type.unresolved_symbol = new UnresolvedSymbol (null, "uchar");
if (type_node.is_pointer) { if (type_node.is_pointer) {
type.value_owned = true;
return new ArrayType (type, 1, type.source_reference); return new ArrayType (type, 1, type.source_reference);
} }
} else if (n == "gushort") { } else if (n == "gushort") {
...@@ -1946,10 +1950,12 @@ public class Vala.GIdlParser : CodeVisitor { ...@@ -1946,10 +1950,12 @@ public class Vala.GIdlParser : CodeVisitor {
} else if (n == "GType") { } else if (n == "GType") {
type.unresolved_symbol = new UnresolvedSymbol (new UnresolvedSymbol (null, "GLib"), "Type"); type.unresolved_symbol = new UnresolvedSymbol (new UnresolvedSymbol (null, "GLib"), "Type");
if (type_node.is_pointer) { if (type_node.is_pointer) {
type.value_owned = true;
return new ArrayType (type, 1, type.source_reference); return new ArrayType (type, 1, type.source_reference);
} }
} else if (n == "GStrv") { } else if (n == "GStrv") {
type.unresolved_symbol = new UnresolvedSymbol (null, "string"); type.unresolved_symbol = new UnresolvedSymbol (null, "string");
type.value_owned = true;
return new ArrayType (type, 1, type.source_reference); return new ArrayType (type, 1, type.source_reference);
} else { } else {
var named_type = parse_type_string (n); var named_type = parse_type_string (n);
...@@ -2172,6 +2178,7 @@ public class Vala.GIdlParser : CodeVisitor { ...@@ -2172,6 +2178,7 @@ public class Vala.GIdlParser : CodeVisitor {
} }
if (array_data != null && array_data.length > 0) { if (array_data != null && array_data.length > 0) {
type.value_owned = true;
type = new ArrayType (type, array_dimension_data.length + 1, source_reference); type = new ArrayType (type, array_dimension_data.length + 1, source_reference);
} }
...@@ -2264,6 +2271,7 @@ public class Vala.GIdlParser : CodeVisitor { ...@@ -2264,6 +2271,7 @@ public class Vala.GIdlParser : CodeVisitor {
m.set_attribute_string ("CCode", "sentinel", eval (nv[1])); m.set_attribute_string ("CCode", "sentinel", eval (nv[1]));
} else if (nv[0] == "is_array") { } else if (nv[0] == "is_array") {
if (eval (nv[1]) == "1") { if (eval (nv[1]) == "1") {
return_type.value_owned = true;
return_type = new ArrayType (return_type, 1, return_type.source_reference); return_type = new ArrayType (return_type, 1, return_type.source_reference);
m.return_type = return_type; m.return_type = return_type;
} }
...@@ -2412,6 +2420,7 @@ public class Vala.GIdlParser : CodeVisitor { ...@@ -2412,6 +2420,7 @@ public class Vala.GIdlParser : CodeVisitor {
var nv = attr.split ("=", 2); var nv = attr.split ("=", 2);
if (nv[0] == "is_array") { if (nv[0] == "is_array") {
if (eval (nv[1]) == "1") { if (eval (nv[1]) == "1") {
param_type.value_owned = true;
param_type = new ArrayType (param_type, 1, param_type.source_reference); param_type = new ArrayType (param_type, 1, param_type.source_reference);
p.variable_type = param_type; p.variable_type = param_type;
if (!out_requested) { if (!out_requested) {
...@@ -2527,6 +2536,7 @@ public class Vala.GIdlParser : CodeVisitor { ...@@ -2527,6 +2536,7 @@ public class Vala.GIdlParser : CodeVisitor {
if (last_param != null && p.name == "n_" + last_param.name) { if (last_param != null && p.name == "n_" + last_param.name) {
if (!(last_param_type is ArrayType)) { if (!(last_param_type is ArrayType)) {
// last_param is array, p is array length // last_param is array, p is array length
last_param_type.value_owned = true;
last_param_type = new ArrayType (last_param_type, 1, last_param_type.source_reference); last_param_type = new ArrayType (last_param_type, 1, last_param_type.source_reference);
last_param.variable_type = last_param_type; last_param.variable_type = last_param_type;
last_param.direction = ParameterDirection.IN; last_param.direction = ParameterDirection.IN;
...@@ -2824,6 +2834,7 @@ public class Vala.GIdlParser : CodeVisitor { ...@@ -2824,6 +2834,7 @@ public class Vala.GIdlParser : CodeVisitor {
} }
} else if (nv[0] == "is_array") { } else if (nv[0] == "is_array") {
if (eval (nv[1]) == "1") { if (eval (nv[1]) == "1") {
type.value_owned = true;
type = new ArrayType (type, 1, type.source_reference); type = new ArrayType (type, 1, type.source_reference);
} }
} else if (nv[0] == "weak") { } else if (nv[0] == "weak") {
...@@ -3096,6 +3107,7 @@ public class Vala.GIdlParser : CodeVisitor { ...@@ -3096,6 +3107,7 @@ public class Vala.GIdlParser : CodeVisitor {
} }
} else if (nv[0] == "is_array") { } else if (nv[0] == "is_array") {
if (eval (nv[1]) == "1") { if (eval (nv[1]) == "1") {
param_type.value_owned = true;
param_type = new ArrayType (param_type, 1, param_type.source_reference); param_type = new ArrayType (param_type, 1, param_type.source_reference);
p.variable_type = param_type; p.variable_type = param_type;
p.direction = ParameterDirection.IN; p.direction = ParameterDirection.IN;
......
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