[vala/staging: 3/5] codegen: Respect cname ccode-attribute of lockable fields
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 3/5] codegen: Respect cname ccode-attribute of lockable fields
- Date: Wed, 25 Apr 2018 17:58:10 +0000 (UTC)
commit 4d1923c7170b45d56091bee55050b766384f0c0e
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Apr 24 23:46:39 2018 +0200
codegen: Respect cname ccode-attribute of lockable fields
https://bugzilla.gnome.org/show_bug.cgi?id=795521
codegen/valaccodebasemodule.vala | 16 +++++++-------
codegen/valagtypemodule.vala | 4 +-
tests/Makefile.am | 1 +
tests/objects/bug795521.vala | 42 ++++++++++++++++++++++++++++++++++++++
4 files changed, 53 insertions(+), 10 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 6249205..540a014 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -880,7 +880,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var finalize_context = class_finalize_context;
if (m.is_instance_member ()) {
- l = new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (l, "priv"),
get_symbol_lock_name (m.name));
+ l = new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (l, "priv"),
get_symbol_lock_name (get_ccode_name (m)));
init_context = instance_init_context;
finalize_context = instance_finalize_context;
} else if (m.is_class_member ()) {
@@ -888,9 +888,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var get_class_private_call = new CCodeFunctionCall (new CCodeIdentifier
("%s_GET_CLASS_PRIVATE".printf(get_ccode_upper_case_name (parent))));
get_class_private_call.add_argument (new CCodeIdentifier ("klass"));
- l = new CCodeMemberAccess.pointer (get_class_private_call,
get_symbol_lock_name (m.name));
+ l = new CCodeMemberAccess.pointer (get_class_private_call,
get_symbol_lock_name (get_ccode_name (m)));
} else {
- l = new CCodeIdentifier (get_symbol_lock_name
("%s_%s".printf(get_ccode_lower_case_name (m.parent_symbol), m.name)));
+ l = new CCodeIdentifier (get_symbol_lock_name ("%s_%s".printf
(get_ccode_lower_case_name (m.parent_symbol), get_ccode_name (m))));
}
push_context (init_context);
@@ -1040,7 +1040,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (f.lock_used) {
// Declare mutex for static member
var flock = new CCodeDeclaration (get_ccode_name (mutex_type));
- var flock_decl = new CCodeVariableDeclarator (get_symbol_lock_name (get_ccode_name
(f)), new CCodeConstant ("{0}"));
+ var flock_decl = new CCodeVariableDeclarator (get_symbol_lock_name ("%s_%s".printf
(get_ccode_lower_case_name (f.parent_symbol), get_ccode_name (f))), new CCodeConstant ("{0}"));
flock.add_declarator (flock_decl);
if (f.is_private_symbol ()) {
@@ -3864,13 +3864,13 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (member.is_instance_member ()) {
if (inner_node == null) {
l = new CCodeIdentifier ("self");
- } else if (resource.symbol_reference.parent_symbol != current_type_symbol) {
+ } else if (parent != current_type_symbol) {
l = generate_instance_cast (get_cvalue (inner_node), parent);
} else {
l = get_cvalue (inner_node);
}
- l = new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (l, "priv"),
get_symbol_lock_name (resource.symbol_reference.name));
+ l = new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (l, "priv"),
get_symbol_lock_name (get_ccode_name (member)));
} else if (member.is_class_member ()) {
CCodeExpression klass;
@@ -3884,9 +3884,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var get_class_private_call = new CCodeFunctionCall (new CCodeIdentifier
("%s_GET_CLASS_PRIVATE".printf(get_ccode_upper_case_name (parent))));
get_class_private_call.add_argument (klass);
- l = new CCodeMemberAccess.pointer (get_class_private_call, get_symbol_lock_name
(resource.symbol_reference.name));
+ l = new CCodeMemberAccess.pointer (get_class_private_call, get_symbol_lock_name
(get_ccode_name (member)));
} else {
- string lock_name = "%s_%s".printf(get_ccode_lower_case_name (parent),
resource.symbol_reference.name);
+ string lock_name = "%s_%s".printf (get_ccode_lower_case_name (parent), get_ccode_name
(member));
l = new CCodeIdentifier (get_symbol_lock_name (lock_name));
}
return l;
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 95555d7..6c58d61 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -549,13 +549,13 @@ public class Vala.GTypeModule : GErrorModule {
if (prop.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 (prop.name));
+ instance_priv_struct.add_field (get_ccode_name (mutex_type),
get_symbol_lock_name (get_ccode_name (prop)));
}
} else if (prop.binding == MemberBinding.CLASS) {
if (prop.lock_used) {
has_class_locks = true;
// add field for mutex
- type_priv_struct.add_field (get_ccode_name (mutex_type),
get_symbol_lock_name (prop.name));
+ type_priv_struct.add_field (get_ccode_name (mutex_type),
get_symbol_lock_name (get_ccode_name (prop)));
}
}
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 64ce795..025d0f8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -313,6 +313,7 @@ TESTS = \
objects/bug795225-2.test \
objects/bug795225-3.test \
objects/bug795225-4.test \
+ objects/bug795521.vala \
errors/catch-error-code.vala \
errors/errors.vala \
errors/bug567181.vala \
diff --git a/tests/objects/bug795521.vala b/tests/objects/bug795521.vala
new file mode 100644
index 0000000..f47bd72
--- /dev/null
+++ b/tests/objects/bug795521.vala
@@ -0,0 +1,42 @@
+class Foo {
+ [CCode (cname = "faz")]
+ public int foo;
+ [CCode (cname = "baz")]
+ public class int boo;
+ [CCode (cname = "maz")]
+ public static int moo;
+
+ public int foor;
+ public class int boor;
+ public static int moor;
+
+ public int foop { get; set; }
+
+ public void use () {
+ lock (foo) {
+ }
+
+ lock (boo) {
+ }
+
+ lock (moo) {
+ }
+
+ lock (foor) {
+ }
+
+ lock (boor) {
+ }
+
+ lock (moor) {
+ }
+
+ lock (foop) {
+ }
+ }
+}
+
+void main () {
+ var foo = new Foo ();
+ foo.use ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]