Commit 0a67ba6c authored by Luca Bruno's avatar Luca Bruno

codegen: Fix definition of fields when array length cname is specified

Fixes bug 588203.
parent 757a097a
......@@ -79,7 +79,13 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
var len_type = int_type.copy ();
for (int dim = 1; dim <= array_type.rank; dim++) {
instance_struct.add_field (len_type.get_cname (), get_array_length_cname (f.name, dim));
string length_cname;
if (f.has_array_length_cname) {
length_cname = f.get_array_length_cname ();
} else {
length_cname = get_array_length_cname (f.name, dim);
}
instance_struct.add_field (len_type.get_cname (), length_cname);
}
if (array_type.rank == 1 && f.is_internal_symbol ()) {
......
......@@ -321,7 +321,13 @@ public class Vala.GTypeModule : GErrorModule {
var len_type = int_type.copy ();
for (int dim = 1; dim <= array_type.rank; dim++) {
instance_struct.add_field (len_type.get_cname (), get_array_length_cname (f.name, dim));
string length_cname;
if (f.has_array_length_cname) {
length_cname = f.get_array_length_cname ();
} else {
length_cname = get_array_length_cname (f.name, dim);
}
instance_struct.add_field (len_type.get_cname (), length_cname);
}
if (array_type.rank == 1 && f.is_internal_symbol ()) {
......@@ -421,7 +427,13 @@ public class Vala.GTypeModule : GErrorModule {
if (!array_type.fixed_length) {
for (int dim = 1; dim <= array_type.rank; dim++) {
instance_priv_struct.add_field (len_type.get_cname (), get_array_length_cname (f.name, dim));
string length_cname;
if (f.has_array_length_cname) {
length_cname = f.get_array_length_cname ();
} else {
length_cname = get_array_length_cname (f.name, dim);
}
instance_priv_struct.add_field (len_type.get_cname (), length_cname);
}
if (array_type.rank == 1 && f.is_internal_symbol ()) {
......
......@@ -74,6 +74,7 @@ TESTS = \
objects/test-029.vala \
objects/test-034.vala \
objects/bug566909.vala \
objects/bug588203.vala \
objects/bug593260.vala \
objects/bug596621.vala \
objects/bug597155.vala \
......
public class Foo {
[CCode (array_length_cname = "length")]
public int[] bar;
}
void main () {
var foo = new Foo ();
foo.bar = new int[10];
}
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