[vala/staging] vala: Transform Lockable.*_lock_used() methods into "lock_used" property



commit 512d8dd05f4318360570fef9d44240001fea0013
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Apr 25 18:21:45 2018 +0200

    vala: Transform Lockable.*_lock_used() methods into "lock_used" property

 codegen/valaccodebasemodule.vala |    4 ++--
 codegen/valagtypemodule.vala     |    8 ++++----
 vala/valafield.vala              |   10 +---------
 vala/valalockable.vala           |    7 +------
 vala/valalockstatement.vala      |    2 +-
 vala/valaproperty.vala           |   12 ++----------
 vala/valaunlockstatement.vala    |    2 +-
 7 files changed, 12 insertions(+), 33 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 6f775e0..6249205 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -874,7 +874,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
        public void visit_member (Symbol m) {
                /* stuff meant for all lockable members */
-               if (m is Lockable && ((Lockable) m).get_lock_used ()) {
+               if (m is Lockable && ((Lockable) m).lock_used) {
                        CCodeExpression l = new CCodeIdentifier ("self");
                        var init_context = class_init_context;
                        var finalize_context = class_finalize_context;
@@ -1037,7 +1037,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                }
                decl_space.add_type_member_declaration (cdecl);
 
-               if (f.get_lock_used ()) {
+               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}"));
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index daad49c..95555d7 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -526,7 +526,7 @@ public class Vala.GTypeModule : GErrorModule {
                                        }
                                }
 
-                               if (f.get_lock_used ()) {
+                               if (f.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 (get_ccode_name (f)));
@@ -536,7 +536,7 @@ public class Vala.GTypeModule : GErrorModule {
                                        type_priv_struct.add_field (get_ccode_name (f.variable_type), 
get_ccode_name (f), modifiers);
                                }
 
-                               if (f.get_lock_used ()) {
+                               if (f.lock_used) {
                                        has_class_locks = true;
                                        // add field for mutex
                                        type_priv_struct.add_field (get_ccode_name (mutex_type), 
get_symbol_lock_name (get_ccode_name (f)));
@@ -546,13 +546,13 @@ public class Vala.GTypeModule : GErrorModule {
 
                foreach (Property prop in cl.get_properties ()) {
                        if (prop.binding == MemberBinding.INSTANCE) {
-                               if (prop.get_lock_used ()) {
+                               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));
                                }
                        } else if (prop.binding == MemberBinding.CLASS) {
-                               if (prop.get_lock_used ()) {
+                               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));
diff --git a/vala/valafield.vala b/vala/valafield.vala
index f060554..0227e8a 100644
--- a/vala/valafield.vala
+++ b/vala/valafield.vala
@@ -38,7 +38,7 @@ public class Vala.Field : Variable, Lockable {
         */
        public bool is_volatile { get; set; }
 
-       private bool lock_used = false;
+       public bool lock_used { get; set; }
 
        /**
         * Creates a new field.
@@ -65,14 +65,6 @@ public class Vala.Field : Variable, Lockable {
                }
        }
 
-       public bool get_lock_used () {
-               return lock_used;
-       }
-
-       public void set_lock_used (bool used) {
-               lock_used = used;
-       }
-
        public override void replace_expression (Expression old_node, Expression new_node) {
                if (initializer == old_node) {
                        initializer = new_node;
diff --git a/vala/valalockable.vala b/vala/valalockable.vala
index 0cbf063..bb0fda2 100644
--- a/vala/valalockable.vala
+++ b/vala/valalockable.vala
@@ -30,10 +30,5 @@ public interface Vala.Lockable {
        /**
         * Indicates a specific lockable object beeing actually locked somewhere.
         */
-       public abstract bool get_lock_used ();
-
-       /**
-        * Set this lockable object as beeing locked somewhere.
-        */
-       public abstract void set_lock_used (bool used);
+       public abstract bool lock_used { get; set; }
 }
diff --git a/vala/valalockstatement.vala b/vala/valalockstatement.vala
index ad15d06..38fac07 100644
--- a/vala/valalockstatement.vala
+++ b/vala/valalockstatement.vala
@@ -97,7 +97,7 @@ public class Vala.LockStatement : CodeNode, Statement {
                        Report.error (resource.source_reference, "Only members of the current class are 
lockable");
                }
 
-               ((Lockable) resource.symbol_reference).set_lock_used (true);
+               ((Lockable) resource.symbol_reference).lock_used = true;
 
                return !error;
        }
diff --git a/vala/valaproperty.vala b/vala/valaproperty.vala
index 1bc54a5..6e5ae69 100644
--- a/vala/valaproperty.vala
+++ b/vala/valaproperty.vala
@@ -214,9 +214,9 @@ public class Vala.Property : Symbol, Lockable {
                }
        }
 
-       private Expression _initializer;
+       public bool lock_used { get; set; }
 
-       private bool lock_used = false;
+       private Expression _initializer;
 
        private DataType _data_type;
 
@@ -267,14 +267,6 @@ public class Vala.Property : Symbol, Lockable {
                }
        }
 
-       public bool get_lock_used () {
-               return lock_used;
-       }
-
-       public void set_lock_used (bool used) {
-               lock_used = used;
-       }
-
        /**
         * Checks whether the accessors of this property are compatible
         * with the specified base property.
diff --git a/vala/valaunlockstatement.vala b/vala/valaunlockstatement.vala
index ff2f401..283b782 100644
--- a/vala/valaunlockstatement.vala
+++ b/vala/valaunlockstatement.vala
@@ -64,7 +64,7 @@ public class Vala.UnlockStatement : CodeNode, Statement {
                        Report.error (resource.source_reference, "Only members of the current class are 
lockable");
                }
 
-               ((Lockable) resource.symbol_reference).set_lock_used (true);
+               ((Lockable) resource.symbol_reference).lock_used = true;
 
                return !error;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]