[vala/wip/transform: 53/99] Fix some code-style issues
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/transform: 53/99] Fix some code-style issues
- Date: Sun, 9 Feb 2014 22:42:46 +0000 (UTC)
commit 5a34958052d3ab8af83e0054a3dd00f791d5f88d
Author: Rico Tzschichholz <ricotz t-online de>
Date: Mon Oct 22 13:15:13 2012 +0200
Fix some code-style issues
codegen/valagdbusclienttransformer.vala | 20 +++++-----
codegen/valagdbusservertransformer.vala | 18 ++++----
codegen/valagvarianttransformer.vala | 64 +++++++++++++++----------------
vala/valacodetransformer.vala | 4 +-
4 files changed, 52 insertions(+), 54 deletions(-)
---
diff --git a/codegen/valagdbusclienttransformer.vala b/codegen/valagdbusclienttransformer.vala
index c25f0e6..e94b56c 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,11 +117,11 @@ 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";
- b.add_expression (expression (@"$reply = $yield_str this.get_connection().$method_str
($message, GLib.DBusSendMessageFlags.NONE, this.get_default_timeout (), null, $cancellable)"));
+ b.add_expression (expression (@"$reply = $yield_str this.get_connection
().$method_str ($message, GLib.DBusSendMessageFlags.NONE, this.get_default_timeout (), null, $cancellable)"));
b.add_expression (expression (@"$reply.to_gerror ()"));
}
@@ -131,7 +131,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));
@@ -193,7 +193,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 ())"));
}
@@ -281,7 +281,7 @@ public class Vala.GDBusClientTransformer : GVariantTransformer {
var variant = b.add_temp_declaration (data_type ("GLib.Variant"), expression
("value"));
b.add_expression (expression (@"call_sync (\"org.freedesktop.DBus.Properties.Set\",
new Variant (\"(ssv)\", \"$dbus_iface_name\", \"$dbus_name\", $variant), GLib.DBusCallFlags.NONE, $timeout,
null)"));
pop_builder ();
- }
+ }
Property proxy = new Property (prop.name, prop.property_type, proxy_get, proxy_set,
prop.source_reference);
proxy_class.add_property (proxy);
@@ -325,7 +325,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;
@@ -349,7 +349,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 3db5282..9b1ae5a 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 e5b9236..ce025c1 100644
--- a/codegen/valagvarianttransformer.vala
+++ b/codegen/valagvarianttransformer.vala
@@ -68,7 +68,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;
}
@@ -149,20 +149,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;
}
@@ -172,14 +172,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);
@@ -189,7 +189,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)) {
@@ -201,12 +201,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) {
@@ -223,7 +223,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));
@@ -235,7 +235,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)";
}
@@ -247,14 +247,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));
@@ -268,14 +268,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;
}
@@ -292,7 +292,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));
@@ -302,11 +302,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 ()"));
}
@@ -318,7 +318,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;
}
@@ -331,7 +331,7 @@ public class Vala.GVariantTransformer : CCodeTransformer {
if (dim == array_type.rank) {
var element_access = new ElementAccess (expression (array), b.source_reference);
- for (int i=0; i < array_type.rank; i++) {
+ for (int i = 0; i < array_type.rank; i++) {
element_access.append_index (expression (indices[i]));
}
if (is_gvariant_type (array_type.element_type)) {
@@ -361,7 +361,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));
@@ -384,14 +384,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));
@@ -424,7 +424,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;
}
@@ -454,7 +454,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 ();
@@ -475,7 +475,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 ();
@@ -507,7 +507,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)) {
@@ -516,10 +516,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 6d1b01a..7e6001a 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]