[vala/wip/transform: 83/124] Fix some code-style issues



commit 70bed8e8e6c1eea2d448b133edbe9aea994317e4
Author: Rico Tzschichholz <ricotz t-online de>
Date:   Mon Oct 22 13:15:13 2012 +0200

    Fix some code-style issues

 codegen/valagdbusclienttransformer.vala | 18 +++++-----
 codegen/valagdbusservertransformer.vala | 18 +++++-----
 codegen/valagvarianttransformer.vala    | 62 ++++++++++++++++-----------------
 vala/valacodetransformer.vala           |  4 +--
 4 files changed, 50 insertions(+), 52 deletions(-)
---
diff --git a/codegen/valagdbusclienttransformer.vala b/codegen/valagdbusclienttransformer.vala
index 539b252ed..92db25858 100644
--- a/codegen/valagdbusclienttransformer.vala
+++ b/codegen/valagdbusclienttransformer.vala
@@ -62,9 +62,9 @@ public class Vala.GDBusClientTransformer : GVariantTransformer {
                                return expression (@"new GLib.Socket.from_fd ($fd_list.get ($fd_index))");
                        }
                } else if (type_name == "GLib.Variant") {
-                       return expression (@"$iter.next_value().get_variant ()");
+                       return expression (@"$iter.next_value ().get_variant ()");
                } else {
-                       return expression (@"($(type)) ($iter.next_value ())");
+                       return expression (@"($type) ($iter.next_value ())");
                }
        }
 
@@ -93,7 +93,7 @@ public class Vala.GDBusClientTransformer : GVariantTransformer {
 
                // create the message
                var reply = b.add_temp_declaration (data_type ("GLib.DBusMessage"));
-               var message = b.add_temp_declaration (null, expression (@"new GLib.DBusMessage.method_call 
(this.get_name(), this.get_object_path (), $interface_name, \"$method_name\")"));
+               var message = b.add_temp_declaration (null, expression (@"new GLib.DBusMessage.method_call 
(this.get_name (), this.get_object_path (), $interface_name, \"$method_name\")"));
                var builder = b.add_temp_declaration (null, expression (@"new GLib.VariantBuilder 
(GLib.VariantType.TUPLE)"));
 
                // fill the message
@@ -117,12 +117,12 @@ public class Vala.GDBusClientTransformer : GVariantTransformer {
 
                // send the message
                if (is_dbus_no_reply (m)) {
-                       b.add_expression (expression (@"this.get_connection().send_message ($message, 
GLib.DBusSendMessageFlags.NO_REPLY_EXPECTED, null)"));
+                       b.add_expression (expression (@"this.get_connection ().send_message ($message, 
GLib.DBusSendMessageFlags.NO_REPLY_EXPECTED, null)"));
                } else {
                        var yield_str = m.coroutine ? "yield " : "";
                        var method_str = m.coroutine ? "send_message_with_reply" : 
"send_message_with_reply_sync";
                        var timeout_str = method_timeout > 0 ? @"$method_timeout" : "this.get_default_timeout 
()";
-                       b.add_expression (expression (@"$reply = $yield_str this.get_connection().$method_str 
($message, GLib.DBusSendMessageFlags.NONE, $timeout_str, null, $cancellable)"));
+                       b.add_expression (expression (@"$reply = $yield_str this.get_connection 
().$method_str ($message, GLib.DBusSendMessageFlags.NONE, $timeout_str, null, $cancellable)"));
 
                        b.add_expression (expression (@"$reply.to_gerror ()"));
                }
@@ -132,7 +132,7 @@ public class Vala.GDBusClientTransformer : GVariantTransformer {
                string fd_index = null;
                if (has_result) {
                        var iter = b.add_temp_declaration (data_type ("GLib.VariantIter"));
-                       b.add_expression (expression (@"$iter = $reply.get_body().iterator ()"));
+                       b.add_expression (expression (@"$iter = $reply.get_body ().iterator ()"));
                        foreach (var param in m.get_parameters ()) {
                                if (param.direction == ParameterDirection.OUT) {
                                        b.add_assignment (expression (param.name), read_dbus_value 
(param.variable_type, iter, reply, ref fd_list, ref fd_index));
@@ -194,7 +194,7 @@ public class Vala.GDBusClientTransformer : GVariantTransformer {
                foreach (var param in sig.get_parameters ()) {
                        var temp = b.add_temp_declaration (copy_type (param.variable_type, true));
                        if (is_gvariant_type (param.variable_type)) {
-                               b.add_expression (expression (@"$temp = $iter.next_value().get_variant ()"));
+                               b.add_expression (expression (@"$temp = $iter.next_value ().get_variant ()"));
                        } else {
                                b.add_expression (expression (@"$temp = ($(param.variable_type)) 
($iter.next_value ())"));
                        }
@@ -326,7 +326,7 @@ public class Vala.GDBusClientTransformer : GVariantTransformer {
                }
 
                // create proxy class
-               var proxy = new Class (iface.name+"Proxy", iface.source_reference, null);
+               var proxy = new Class (iface.name + "Proxy", iface.source_reference, null);
                proxy.add_base_type (data_type ("GLib.DBusProxy"));
                proxy.add_base_type (SemanticAnalyzer.get_data_type_for_symbol (iface));
                proxy.access = iface.access;
@@ -350,7 +350,7 @@ public class Vala.GDBusClientTransformer : GVariantTransformer {
                push_builder (new CodeBuilder (context, expr.parent_statement, expr.source_reference));
 
                Method wrapper;
-               var cache_key = "gdbus_client_dynamic_method_call "+m.return_type.to_string ();
+               var cache_key = "gdbus_client_dynamic_method_call " + m.return_type.to_string ();
                foreach (var param in m.get_parameters ()) {
                        cache_key = "%s %s".printf (cache_key, param.variable_type.to_string ());
                }
diff --git a/codegen/valagdbusservertransformer.vala b/codegen/valagdbusservertransformer.vala
index 723ca3980..3dccdbfe3 100644
--- a/codegen/valagdbusservertransformer.vala
+++ b/codegen/valagdbusservertransformer.vala
@@ -38,7 +38,7 @@ public class Vala.GDBusServerTransformer : GDBusClientTransformer {
 
        string generate_dbus_method_wrapper (Method m, ObjectTypeSymbol sym) {
                Method wrapper;
-               wrapper_method (new VoidType (), "gdbus_server "+m.get_full_name (), out wrapper);
+               wrapper_method (new VoidType (), "gdbus_server " + m.get_full_name (), out wrapper);
                var object_type = SemanticAnalyzer.get_data_type_for_symbol (sym);
                wrapper.add_parameter (new Parameter ("object", object_type));
                wrapper.add_parameter (new Parameter ("arguments", data_type ("GLib.Variant", false)));
@@ -52,13 +52,13 @@ public class Vala.GDBusServerTransformer : GDBusClientTransformer {
                Method ready = null;
                CodeBuilder ready_builder = null;
                if (m.coroutine) {
-                       wrapper_method (new VoidType (), "gdbus_server_async_ready "+m.get_full_name (), out 
ready);
+                       wrapper_method (new VoidType (), "gdbus_server_async_ready " + m.get_full_name (), 
out ready);
                        ready.add_parameter (new Parameter ("source_object", data_type ("GLib.Object", 
false)));
                        ready.add_parameter (new Parameter ("res", data_type ("GLib.AsyncResult", false)));
                        ready.add_parameter (new Parameter ("invocation", data_type 
("GLib.DBusMethodInvocation", false)));
                        ready_builder = new CodeBuilder.for_subroutine (ready);
 
-                       finish_call = (MethodCall) expression 
(@"(($object_type)(source_object)).$(m.name).end (res)");
+                       finish_call = (MethodCall) expression (@"(($object_type) source_object).$(m.name).end 
(res)");
                }
 
                var out_args = new string[0];
@@ -98,7 +98,7 @@ public class Vala.GDBusServerTransformer : GDBusClientTransformer {
                }
 
                if (m.coroutine) {
-                       call.add_argument (expression (@"(s,r) => $(ready.name) (s, r, invocation)"));
+                       call.add_argument (expression (@"(s, r) => $(ready.name) (s, r, invocation)"));
                        b.add_expression (call);
                        push_builder (ready_builder);
                }
@@ -119,7 +119,7 @@ public class Vala.GDBusServerTransformer : GDBusClientTransformer {
                fd_list = null;
                var reply = b.add_temp_declaration (null, expression ("new GLib.DBusMessage.method_reply 
(invocation.get_message ())"));
                var builder = b.add_temp_declaration (null, expression ("new GLib.VariantBuilder 
(GLib.VariantType.TUPLE)"));
-               for (int i=0; i < out_args.length; i++) {
+               for (int i = 0; i < out_args.length; i++) {
                        write_dbus_value (out_types[i], builder, out_args[i], ref fd_list);
                }
                if (result != null) {
@@ -129,7 +129,7 @@ public class Vala.GDBusServerTransformer : GDBusClientTransformer {
                if (fd_list != null) {
                        b.add_expression (expression (@"$reply.set_unix_fd_list ($fd_list)"));
                }
-               b.add_expression (expression (@"invocation.get_connection().send_message ($reply, 
GLib.DBusSendMessageFlags.NONE, null)"));
+               b.add_expression (expression (@"invocation.get_connection ().send_message ($reply, 
GLib.DBusSendMessageFlags.NONE, null)"));
 
                if (m.coroutine) {
                        pop_builder ();
@@ -172,7 +172,7 @@ public class Vala.GDBusServerTransformer : GDBusClientTransformer {
 
                push_builder (new CodeBuilder.for_subroutine (im));
                var object_type = SemanticAnalyzer.get_data_type_for_symbol (sym);
-               var object = b.add_temp_declaration (null, expression (@"($object_type) 
(((Object[])user_data)[0])"));
+               var object = b.add_temp_declaration (null, expression (@"($object_type) (((Object[]) 
user_data)[0])"));
                b.open_switch (expression ("method_name"), null);
                b.add_return ();
                foreach (var m in sym.get_methods ()) {
@@ -210,7 +210,7 @@ public class Vala.GDBusServerTransformer : GDBusClientTransformer {
 
                push_builder (new CodeBuilder.for_subroutine (m));
                var object_type = SemanticAnalyzer.get_data_type_for_symbol (sym);
-               var object = b.add_temp_declaration (null, expression (@"($object_type) 
(((Object[])user_data)[0])"));
+               var object = b.add_temp_declaration (null, expression (@"($object_type) (((Object[]) 
user_data)[0])"));
                b.open_switch (expression ("property_name"), null);
                b.add_return (expression ("null"));
                foreach (var prop in sym.get_properties ()) {
@@ -247,7 +247,7 @@ public class Vala.GDBusServerTransformer : GDBusClientTransformer {
 
                push_builder (new CodeBuilder.for_subroutine (m));
                var object_type = SemanticAnalyzer.get_data_type_for_symbol (sym);
-               var object = b.add_temp_declaration (null, expression (@"($object_type) 
(((Object[])user_data)[0])"));
+               var object = b.add_temp_declaration (null, expression (@"($object_type) (((Object[]) 
user_data)[0])"));
                b.open_switch (expression ("property_name"), null);
                b.add_return (expression ("false"));
                foreach (var prop in sym.get_properties ()) {
diff --git a/codegen/valagvarianttransformer.vala b/codegen/valagvarianttransformer.vala
index cbce4584b..2114e67ca 100644
--- a/codegen/valagvarianttransformer.vala
+++ b/codegen/valagvarianttransformer.vala
@@ -70,7 +70,7 @@ public class Vala.GVariantTransformer : CCodeTransformer {
        }
 
        Expression serialize_basic (BasicTypeInfo basic_type, Expression expr) {
-               var new_call = (ObjectCreationExpression) expression (@"new 
GLib.Variant.$(basic_type.type_name)()");
+               var new_call = (ObjectCreationExpression) expression (@"new 
GLib.Variant.$(basic_type.type_name) ()");
                new_call.add_argument (expr);
                return new_call;
        }
@@ -151,20 +151,20 @@ public class Vala.GVariantTransformer : CCodeTransformer {
 
        Expression serialize_array (ArrayType array_type, Expression array_expr) {
                Method m;
-               if (!wrapper_method (data_type ("GLib.Variant"), "gvariant_serialize_array 
"+array_type.to_string(), out m)) {
+               if (!wrapper_method (data_type ("GLib.Variant"), "gvariant_serialize_array " + 
array_type.to_string (), out m)) {
                        m.add_parameter (new Parameter ("array", copy_type (array_type, false), 
b.source_reference));
                        push_builder (new CodeBuilder.for_subroutine (m));
 
                        string[] indices = new string[array_type.rank];
-                       for (int dim=1; dim <= array_type.rank; dim++) {
-                               indices[dim-1] = b.add_temp_declaration (null, new IntegerLiteral ("0"));
+                       for (int dim = 1; dim <= array_type.rank; dim++) {
+                               indices[dim - 1] = b.add_temp_declaration (null, new IntegerLiteral ("0"));
                        }
                        b.add_return (serialize_array_dim (array_type, 1, indices, "array"));
 
                        pop_builder ();
                        check (m);
                }
-               var call = (MethodCall) expression (m.name+"()");
+               var call = (MethodCall) expression (m.name + " ()");
                call.add_argument (array_expr);
                return call;
        }
@@ -174,14 +174,14 @@ public class Vala.GVariantTransformer : CCodeTransformer {
 
                var builder = b.add_temp_declaration (null, builderinit);
 
-               Expression length = expression (array_var+".length");
+               Expression length = expression (array_var + ".length");
                if (array_type.rank > 1) {
                        ElementAccess ea = new ElementAccess (length, b.source_reference);
-                       ea.append_index (new IntegerLiteral ((dim-1).to_string (), b.source_reference));
+                       ea.append_index (new IntegerLiteral ((dim - 1).to_string (), b.source_reference));
                        length = ea;
                }
 
-               var index = indices[dim-1];
+               var index = indices[dim - 1];
                var forcond = new BinaryExpression (BinaryOperator.LESS_THAN, expression (index), length, 
b.source_reference);
                var foriter = new PostfixExpression (expression (index), true, b.source_reference);
                b.open_for (null, forcond, foriter);
@@ -191,7 +191,7 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                        element_variant = serialize_array_dim (array_type, dim + 1, indices, array_var);
                } else {
                        var element_expr = new ElementAccess (expression (array_var), b.source_reference);
-                       for (int i=0; i < dim; i++) {
+                       for (int i = 0; i < dim; i++) {
                                element_expr.append_index (expression (indices[i]));
                        }
                        if (is_gvariant_type (array_type.element_type)) {
@@ -203,12 +203,12 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                        }
                }
 
-               var builder_add = (MethodCall) expression (builder+".add_value ()");
+               var builder_add = (MethodCall) expression (builder + ".add_value ()");
                builder_add.add_argument (element_variant);
                b.add_expression (builder_add);
                b.close ();
 
-               return (MethodCall) expression (builder+".end ()");
+               return (MethodCall) expression (builder + ".end ()");
        }
 
        Expression? serialize_struct (Struct st, Expression expr) {
@@ -225,7 +225,7 @@ public class Vala.GVariantTransformer : CCodeTransformer {
 
                Method m;
                var type = SemanticAnalyzer.get_data_type_for_symbol (st);
-               if (!wrapper_method (data_type ("GLib.Variant"), "gvariant_serialize_struct 
"+type.to_string(), out m)) {
+               if (!wrapper_method (data_type ("GLib.Variant"), "gvariant_serialize_struct " + 
type.to_string (), out m)) {
                        m.add_parameter (new Parameter ("st", type, b.source_reference));
                        push_builder (new CodeBuilder.for_subroutine (m));
 
@@ -237,7 +237,7 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                                        continue;
                                }
 
-                               var serialized_field = "st."+f.name;
+                               var serialized_field = "st." + f.name;
                                if (is_gvariant_type (f.variable_type)) {
                                        serialized_field = @"new GLib.Variant.variant ($serialized_field)";
                                }
@@ -249,14 +249,14 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                        check (m);
                }
 
-               var call = (MethodCall) expression (m.name+"()");
+               var call = (MethodCall) expression (m.name + " ()");
                call.add_argument (expr);
                return call;
        }
 
        Expression? serialize_hash_table (ObjectType type, Expression expr) {
                Method m;
-               if (!wrapper_method (data_type ("GLib.Variant"), "gvariant_serialize_hash_table 
"+type.to_string(), out m)) {
+               if (!wrapper_method (data_type ("GLib.Variant"), "gvariant_serialize_hash_table " + 
type.to_string (), out m)) {
                        m.add_parameter (new Parameter ("ht", copy_type (type, false), b.source_reference));
                        push_builder (new CodeBuilder.for_subroutine (m));
 
@@ -270,14 +270,14 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                        string serialized_key = is_gvariant_type (key_type) ? "new GLib.Variant.variant (k1)" 
: "k1";
                        string serialized_value = is_gvariant_type (value_type) ? "new GLib.Variant.variant 
(v1)" : "v1";
 
-                       var for_each = expression (@"ht.for_each ((k,v) => { GLib.Variant k1 = k; 
GLib.Variant v1 = v; $builder.add (\"{?*}\", $serialized_key, $serialized_value); })");
+                       var for_each = expression (@"ht.for_each ((k, v) => { GLib.Variant k1 = k; 
GLib.Variant v1 = v; $builder.add (\"{?*}\", $serialized_key, $serialized_value); })");
                        b.add_expression (for_each);
                        b.add_return (expression (@"$builder.end ()"));
 
                        pop_builder ();
                        check (m);
                }
-               var call = (MethodCall) expression (m.name+"()");
+               var call = (MethodCall) expression (m.name + " ()");
                call.add_argument (expr);
                return call;
        }
@@ -294,7 +294,7 @@ public class Vala.GVariantTransformer : CCodeTransformer {
 
        Expression deserialize_array (ArrayType array_type, Expression expr) {
                Method m;
-               if (!wrapper_method (copy_type (array_type, true), "gvariant_deserialize_array 
"+array_type.to_string(), out m)) {
+               if (!wrapper_method (copy_type (array_type, true), "gvariant_deserialize_array " + 
array_type.to_string (), out m)) {
                        m.add_parameter (new Parameter ("variant", data_type ("GLib.Variant", false), 
b.source_reference));
                        push_builder (new CodeBuilder.for_subroutine (m));
 
@@ -304,11 +304,11 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                        var array = b.add_temp_declaration (copy_type (array_type, true));
 
                        string[] indices = new string[array_type.rank];
-                       for (int dim=1; dim <= array_type.rank; dim++) {
+                       for (int dim = 1; dim <= array_type.rank; dim++) {
                                string length = b.add_temp_declaration (data_type ("size_t"));
                                b.add_assignment (expression (length), expression (@"$iterator.n_children 
()"));
                                array_new.append_size (expression (length));
-                               indices[dim-1] = b.add_temp_declaration (null, expression ("0"));
+                               indices[dim - 1] = b.add_temp_declaration (null, expression ("0"));
                                if (dim < array_type.rank) {
                                        b.add_expression (expression (@"$iterator.next_value ()"));
                                }
@@ -320,7 +320,7 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                        pop_builder ();
                        check (m);
                }
-               var call = (MethodCall) expression (m.name+"()");
+               var call = (MethodCall) expression (m.name + " ()");
                call.add_argument (expr);
                return call;
        }
@@ -363,7 +363,7 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                Method m;
                var type = SemanticAnalyzer.get_data_type_for_symbol (st);
                type.value_owned = true;
-               if (!wrapper_method (type, "gvariant_deserialize_struct "+type.to_string(), out m)) {
+               if (!wrapper_method (type, "gvariant_deserialize_struct " + type.to_string (), out m)) {
                        m.add_parameter (new Parameter ("variant", data_type ("GLib.Variant", false), 
b.source_reference));
                        push_builder (new CodeBuilder.for_subroutine (m));
 
@@ -386,14 +386,14 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                        pop_builder ();
                        check (m);
                }
-               var call = (MethodCall) expression (m.name+"()");
+               var call = (MethodCall) expression (m.name + " ()");
                call.add_argument (expr);
                return call;
        }
 
        Expression deserialize_hash_table (DataType type, Expression expr) {
                Method m;
-               if (!wrapper_method (copy_type (type, true), "gvariant_deserialize_hash_table 
"+type.to_string(), out m)) {
+               if (!wrapper_method (copy_type (type, true), "gvariant_deserialize_hash_table " + 
type.to_string (), out m)) {
                        m.add_parameter (new Parameter ("variant", data_type ("GLib.Variant", false), 
b.source_reference));
                        push_builder (new CodeBuilder.for_subroutine (m));
 
@@ -426,7 +426,7 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                        pop_builder ();
                        check (m);
                }
-               var call = (MethodCall) expression (m.name+"()");
+               var call = (MethodCall) expression (m.name + " ()");
                call.add_argument (expr);
                return call;
        }
@@ -456,7 +456,7 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                foreach (var enum_value in en.get_values ()) {
                        string dbus_value = get_dbus_value (enum_value, enum_value.name);
                        b.add_section (expression (@"\"$dbus_value\""));
-                       b.add_return (expression (@"$(en.get_full_name()).$(enum_value.name)"));
+                       b.add_return (expression (@"$(en.get_full_name ()).$(enum_value.name)"));
                }
                b.close ();
                pop_builder ();
@@ -477,7 +477,7 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                b.add_return (expression ("null"));
                foreach (var enum_value in en.get_values ()) {
                        string dbus_value = get_dbus_value (enum_value, enum_value.name);
-                       b.add_section (expression (@"$(en.get_full_name()).$(enum_value.name)"));
+                       b.add_section (expression (@"$(en.get_full_name ()).$(enum_value.name)"));
                        b.add_return (expression (@"\"$dbus_value\""));
                }
                b.close ();
@@ -509,7 +509,7 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                if (is_string_marshalled_enum (type.data_type)) {
                        get_basic_type_info ("s", out basic_type);
                        result = deserialize_basic (basic_type, expr.inner);
-                       var call = (MethodCall) expression (@"$(type.data_type.get_full_name()).from_string 
()");
+                       var call = (MethodCall) expression (@"$(type.data_type.get_full_name ()).from_string 
()");
                        call.add_argument (result);
                        result = call;
                } else if (get_basic_type_info (get_type_signature (type), out basic_type)) {
@@ -518,10 +518,8 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                        result = deserialize_array ((ArrayType) type, expr.inner);
                } else if (type.data_type is Struct) {
                        result = deserialize_struct ((Struct) type.data_type, expr.inner);
-               } else if (type is ObjectType) {
-                       if (type.data_type.get_full_name () == "GLib.HashTable") {
-                               result = deserialize_hash_table ((ObjectType) type, expr.inner);
-                       }
+               } else if (type is ObjectType && type.data_type.get_full_name () == "GLib.HashTable") {
+                       result = deserialize_hash_table ((ObjectType) type, expr.inner);
                }
 
                context.analyzer.replaced_nodes.add (expr.inner);
diff --git a/vala/valacodetransformer.vala b/vala/valacodetransformer.vala
index 6d1b01a9f..7e6001a08 100644
--- a/vala/valacodetransformer.vala
+++ b/vala/valacodetransformer.vala
@@ -74,7 +74,7 @@ public class Vala.CodeTransformer : CodeVisitor {
        }
 
        public string temp_func_cname () {
-               return "_vala_func_"+CodeNode.get_temp_name ().substring (1);
+               return "_vala_func_" + CodeNode.get_temp_name ().substring (1);
        }
 
        public bool wrapper_method (DataType return_type, string? cache_key, out Method m, Symbol? parent = 
null) {
@@ -107,7 +107,7 @@ public class Vala.CodeTransformer : CodeVisitor {
        }
 
        public Expression expression (string str) {
-               return new Parser().parse_expression_string (str, b.source_reference);
+               return new Parser ().parse_expression_string (str, b.source_reference);
        }
 
        public void check (CodeNode node) {


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