[vala/0.34] codegen: Reference struct fields with their actual cname
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.34] codegen: Reference struct fields with their actual cname
- Date: Wed, 1 Mar 2017 08:56:42 +0000 (UTC)
commit 7d69e2197a80c57010748844288ada3a98ae37e0
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Dec 7 18:54:30 2016 +0100
codegen: Reference struct fields with their actual cname
https://bugzilla.gnome.org/show_bug.cgi?id=775761
codegen/valaccodebasemodule.vala | 4 ++--
codegen/valaccodememberaccessmodule.vala | 4 ++--
codegen/valaccodestructmodule.vala | 6 +++---
codegen/valagtypemodule.vala | 14 +++++++-------
tests/Makefile.am | 1 +
tests/structs/bug775761.vala | 17 +++++++++++++++++
6 files changed, 32 insertions(+), 14 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 0e3a606..ecf39c2 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2783,8 +2783,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
has_instance_fields = true;
CCodeExpression cexp; // if (cexp) return FALSE;
- var s1 = (CCodeExpression) new CCodeMemberAccess.pointer (new CCodeIdentifier ("s1"),
f.name); // s1->f
- var s2 = (CCodeExpression) new CCodeMemberAccess.pointer (new CCodeIdentifier ("s2"),
f.name); // s2->f
+ var s1 = (CCodeExpression) new CCodeMemberAccess.pointer (new CCodeIdentifier ("s1"),
get_ccode_name (f)); // s1->f
+ var s2 = (CCodeExpression) new CCodeMemberAccess.pointer (new CCodeIdentifier ("s2"),
get_ccode_name (f)); // s2->f
var variable_type = f.variable_type.copy ();
make_comparable_cexpression (ref variable_type, ref s1, ref variable_type, ref s2);
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 4f846b6..229b8cf 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -570,7 +570,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
if (get_ccode_array_length_name (field) != null) {
length_cname = get_ccode_array_length_name (field);
} else {
- length_cname = get_array_length_cname (field.name, dim);
+ length_cname = get_array_length_cname (get_ccode_name
(field), dim);
}
if (((TypeSymbol) field.parent_symbol).is_reference_type ()) {
@@ -582,7 +582,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
result.append_array_length_cvalue (length_expr);
}
if (array_type.rank == 1 && field.is_internal_symbol ()) {
- string size_cname = get_array_size_cname (field.name);
+ string size_cname = get_array_size_cname (get_ccode_name (field));
if (((TypeSymbol) field.parent_symbol).is_reference_type ()) {
set_array_size_cvalue (result, new CCodeMemberAccess.pointer
(inst, size_cname));
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index 3f226d5..7d58aeb 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -93,13 +93,13 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
if (get_ccode_array_length_name (f) != null) {
length_cname = get_ccode_array_length_name
(f);
} else {
- length_cname = get_array_length_cname
(f.name, dim);
+ length_cname = get_array_length_cname
(get_ccode_name (f), dim);
}
instance_struct.add_field (get_ccode_name (len_type),
length_cname);
}
if (array_type.rank == 1 && f.is_internal_symbol ()) {
- instance_struct.add_field (get_ccode_name (len_type),
get_array_size_cname (f.name));
+ instance_struct.add_field (get_ccode_name (len_type),
get_array_size_cname (get_ccode_name (f)));
}
}
} else if (f.variable_type is DelegateType) {
@@ -108,7 +108,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
// create field to store delegate target
instance_struct.add_field ("gpointer",
get_ccode_delegate_target_name (f));
if (delegate_type.is_disposable ()) {
- instance_struct.add_field ("GDestroyNotify",
get_delegate_target_destroy_notify_cname (f.name));
+ instance_struct.add_field ("GDestroyNotify",
get_delegate_target_destroy_notify_cname (get_ccode_name (f)));
}
}
}
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index b732886..2e6bb4e 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -344,13 +344,13 @@ public class Vala.GTypeModule : GErrorModule {
if (get_ccode_array_length_name (f) != null) {
length_cname =
get_ccode_array_length_name (f);
} else {
- length_cname = get_array_length_cname
(f.name, dim);
+ length_cname = get_array_length_cname
(get_ccode_name (f), dim);
}
instance_struct.add_field (get_ccode_name
(len_type), length_cname);
}
if (array_type.rank == 1 && f.is_internal_symbol ()) {
- instance_struct.add_field (get_ccode_name
(len_type), get_array_size_cname (f.name));
+ instance_struct.add_field (get_ccode_name
(len_type), get_array_size_cname (get_ccode_name (f)));
}
}
} else if (f.variable_type is DelegateType) {
@@ -359,7 +359,7 @@ public class Vala.GTypeModule : GErrorModule {
// create field to store delegate target
instance_struct.add_field ("gpointer",
get_ccode_delegate_target_name (f));
if (delegate_type.is_disposable ()) {
- instance_struct.add_field ("GDestroyNotify",
get_delegate_target_destroy_notify_cname (f.name));
+ instance_struct.add_field ("GDestroyNotify",
get_delegate_target_destroy_notify_cname (get_ccode_name (f)));
}
}
}
@@ -450,13 +450,13 @@ public class Vala.GTypeModule : GErrorModule {
if (get_ccode_array_length_name (f) != null) {
length_cname =
get_ccode_array_length_name (f);
} else {
- length_cname = get_array_length_cname
(f.name, dim);
+ length_cname = get_array_length_cname
(get_ccode_name (f), dim);
}
instance_priv_struct.add_field
(get_ccode_name (len_type), length_cname);
}
if (array_type.rank == 1 && f.is_internal_symbol ()) {
- instance_priv_struct.add_field
(get_ccode_name (len_type), get_array_size_cname (f.name));
+ instance_priv_struct.add_field
(get_ccode_name (len_type), get_array_size_cname (get_ccode_name (f)));
}
}
} else if (f.variable_type is DelegateType) {
@@ -465,7 +465,7 @@ public class Vala.GTypeModule : GErrorModule {
// create field to store delegate target
instance_priv_struct.add_field ("gpointer",
get_ccode_delegate_target_name (f));
if (delegate_type.is_disposable ()) {
- instance_priv_struct.add_field
("GDestroyNotify", get_delegate_target_destroy_notify_cname (f.name));
+ instance_priv_struct.add_field
("GDestroyNotify", get_delegate_target_destroy_notify_cname (get_ccode_name (f)));
}
}
}
@@ -474,7 +474,7 @@ public class Vala.GTypeModule : GErrorModule {
if (f.get_lock_used ()) {
cl.has_private_fields = true;
// add field for mutex
- instance_priv_struct.add_field (get_ccode_name (mutex_type),
get_symbol_lock_name (f.name));
+ instance_priv_struct.add_field (get_ccode_name (mutex_type),
get_symbol_lock_name (get_ccode_name (f)));
}
} else if (f.binding == MemberBinding.CLASS) {
if (f.access == SymbolAccessibility.PRIVATE) {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4a011d8..023d95e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -119,6 +119,7 @@ TESTS = \
structs/bug686190.vala \
structs/bug690380.vala \
structs/bug749952.vala \
+ structs/bug775761.vala \
delegates/delegates.vala \
delegates/bug539166.vala \
delegates/bug595610.vala \
diff --git a/tests/structs/bug775761.vala b/tests/structs/bug775761.vala
new file mode 100644
index 0000000..3b47a78
--- /dev/null
+++ b/tests/structs/bug775761.vala
@@ -0,0 +1,17 @@
+struct Foo {
+ [CCode (cname = "foo")]
+ public string f1;
+ [CCode (cname = "bar")]
+ public int f2;
+ [CCode (cname = "baz")]
+ public unowned string[] f3;
+}
+
+const string[] FOO_ARRAY = { "manam", "minimi" };
+
+void main () {
+ Foo a = { "42", 42, FOO_ARRAY};
+ Foo b = { "42", 42, FOO_ARRAY};
+ assert (a == b);
+ assert (a.f3.length == 2);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]