[vala/staging: 2/6] Use more "...".printf to concat strings
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 2/6] Use more "...".printf to concat strings
- Date: Sun, 30 Oct 2016 14:56:16 +0000 (UTC)
commit 41ad68f553b53680dba2ff416542e66fecf00235
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Oct 20 21:15:58 2016 +0200
Use more "...".printf to concat strings
codegen/valaccodearraymodule.vala | 8 ++--
codegen/valaccodeattribute.vala | 14 +++---
codegen/valaccodebasemodule.vala | 28 +++++-----
codegen/valaccodememberaccessmodule.vala | 4 +-
codegen/valaccodemethodmodule.vala | 8 ++--
codegen/valagdbusclientmodule.vala | 4 +-
codegen/valagtypemodule.vala | 84 +++++++++++++++---------------
vala/valagirparser.vala | 12 ++--
vala/valapropertyaccessor.vala | 4 +-
vapigen/valagidlparser.vala | 2 +-
10 files changed, 84 insertions(+), 84 deletions(-)
---
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index 8922464..2b78bbc 100644
--- a/codegen/valaccodearraymodule.vala
+++ b/codegen/valaccodearraymodule.vala
@@ -211,7 +211,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
var fun = new CCodeFunction (cname, "void");
fun.modifiers = CCodeModifiers.STATIC;
- fun.add_parameter (new CCodeParameter ("array", "%s*".printf (get_ccode_name (st))));
+ fun.add_parameter (new CCodeParameter ("array", "%s *".printf (get_ccode_name (st))));
fun.add_parameter (new CCodeParameter ("array_length", "gint"));
push_function (fun);
@@ -547,8 +547,8 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
var function = new CCodeFunction (dup_func, "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", get_ccode_name (array_type) + "*"));
- function.add_parameter (new CCodeParameter ("dest", get_ccode_name (array_type) + "*"));
+ function.add_parameter (new CCodeParameter ("self", "%s *".printf (get_ccode_name
(array_type))));
+ function.add_parameter (new CCodeParameter ("dest", "%s *".printf (get_ccode_name
(array_type))));
// definition
@@ -599,7 +599,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
var function = new CCodeFunction (add_func, "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("array", get_ccode_name (array_type) + "*"));
+ function.add_parameter (new CCodeParameter ("array", "%s *".printf (get_ccode_name
(array_type))));
function.add_parameter (new CCodeParameter ("length", "int*"));
function.add_parameter (new CCodeParameter ("size", "int*"));
diff --git a/codegen/valaccodeattribute.vala b/codegen/valaccodeattribute.vala
index d7cb200..7725aa7 100644
--- a/codegen/valaccodeattribute.vala
+++ b/codegen/valaccodeattribute.vala
@@ -199,7 +199,7 @@ public class Vala.CCodeAttribute : AttributeCache {
_copy_function = ccode.get_string ("copy_function");
}
if (_copy_function == null && sym is Struct) {
- _copy_function = lower_case_prefix + "copy";
+ _copy_function = "%scopy".printf (lower_case_prefix);
}
copy_function_set = true;
}
@@ -214,7 +214,7 @@ public class Vala.CCodeAttribute : AttributeCache {
_destroy_function = ccode.get_string ("destroy_function");
}
if (_destroy_function == null && sym is Struct) {
- _destroy_function = lower_case_prefix + "destroy";
+ _destroy_function = "%sdestroy".printf (lower_case_prefix);
}
destroy_function_set = true;
}
@@ -771,7 +771,7 @@ public class Vala.CCodeAttribute : AttributeCache {
if (sym is Class) {
var cl = (Class) sym;
if (cl.is_fundamental ()) {
- return lower_case_prefix + "ref";
+ return "%sref".printf (lower_case_prefix);
} else if (cl.base_class != null) {
return CCodeBaseModule.get_ccode_ref_function (cl.base_class);
}
@@ -790,7 +790,7 @@ public class Vala.CCodeAttribute : AttributeCache {
if (sym is Class) {
var cl = (Class) sym;
if (cl.is_fundamental ()) {
- return lower_case_prefix + "unref";
+ return "%sunref".printf (lower_case_prefix);
} else if (cl.base_class != null) {
return CCodeBaseModule.get_ccode_unref_function (cl.base_class);
}
@@ -825,10 +825,10 @@ public class Vala.CCodeAttribute : AttributeCache {
if (cl.base_class != null) {
return CCodeBaseModule.get_ccode_free_function (cl.base_class);
}
- return lower_case_prefix + "free";
+ return "%sfree".printf (lower_case_prefix);
} else if (sym is Struct) {
if (!sym.external_package) {
- return lower_case_prefix + "free";
+ return "%sfree".printf (lower_case_prefix);
}
}
return null;
@@ -1229,7 +1229,7 @@ public class Vala.CCodeAttribute : AttributeCache {
if (result.has_suffix ("_async")) {
result = result.substring (0, result.length - "_async".length);
}
- return result + "_finish";
+ return "%s_finish".printf (result);
}
private string get_default_real_name () {
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 257ce71..b0bd6eb 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1477,9 +1477,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
CCodeParameter cvalueparam;
if (returns_real_struct) {
- cvalueparam = new CCodeParameter ("result", get_ccode_name (acc.value_type) + "*");
+ cvalueparam = new CCodeParameter ("result", "%s *".printf (get_ccode_name
(acc.value_type)));
} else if (!acc.readable && prop.property_type.is_real_non_null_struct_type ()) {
- cvalueparam = new CCodeParameter ("value", get_ccode_name (acc.value_type) + "*");
+ cvalueparam = new CCodeParameter ("value", "%s *".printf (get_ccode_name
(acc.value_type)));
} else {
cvalueparam = new CCodeParameter ("value", get_ccode_name (acc.value_type));
}
@@ -1596,9 +1596,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
CCodeParameter cvalueparam;
if (returns_real_struct) {
- cvalueparam = new CCodeParameter ("result", get_ccode_name (acc.value_type) + "*");
+ cvalueparam = new CCodeParameter ("result", "%s *".printf (get_ccode_name
(acc.value_type)));
} else if (!acc.readable && prop.property_type.is_real_non_null_struct_type ()) {
- cvalueparam = new CCodeParameter ("value", get_ccode_name (acc.value_type) + "*");
+ cvalueparam = new CCodeParameter ("value", "%s *".printf (get_ccode_name
(acc.value_type)));
} else {
cvalueparam = new CCodeParameter ("value", get_ccode_name (acc.value_type));
}
@@ -2792,8 +2792,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var function = new CCodeFunction (equal_func, "gboolean");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("s1", "const " + get_ccode_name (st) + "*"));
- function.add_parameter (new CCodeParameter ("s2", "const " + get_ccode_name (st) + "*"));
+ function.add_parameter (new CCodeParameter ("s1", "const %s *".printf (get_ccode_name (st))));
+ function.add_parameter (new CCodeParameter ("s2", "const %s *".printf (get_ccode_name (st))));
push_function (function);
@@ -2884,8 +2884,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var function = new CCodeFunction (equal_func, "gboolean");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("s1", "const " + get_ccode_name (sym) + "*"));
- function.add_parameter (new CCodeParameter ("s2", "const " + get_ccode_name (sym) + "*"));
+ function.add_parameter (new CCodeParameter ("s1", "const %s *".printf (get_ccode_name
(sym))));
+ function.add_parameter (new CCodeParameter ("s2", "const %s *".printf (get_ccode_name
(sym))));
push_function (function);
@@ -5061,7 +5061,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (to.is_real_non_null_struct_type ()) {
// structs are returned via out parameter
- cfunc.add_parameter (new CCodeParameter ("result", get_ccode_name (to) + "*"));
+ cfunc.add_parameter (new CCodeParameter ("result", "%s *".printf (get_ccode_name
(to))));
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF,
get_cvalue_ (result)));
} else if (to is ArrayType) {
// return array length if appropriate
@@ -5463,10 +5463,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var function = new CCodeFunction (array_contains_func, "gboolean");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("stack", "%s*".printf (get_ccode_name
(array_type.element_type))));
+ function.add_parameter (new CCodeParameter ("stack", "%s *".printf (get_ccode_name
(array_type.element_type))));
function.add_parameter (new CCodeParameter ("stack_length", "int"));
if (array_type.element_type is StructValueType) {
- function.add_parameter (new CCodeParameter ("needle", get_ccode_name
(array_type.element_type) + "*"));
+ function.add_parameter (new CCodeParameter ("needle", "%s *".printf (get_ccode_name
(array_type.element_type))));
} else {
function.add_parameter (new CCodeParameter ("needle", get_ccode_name
(array_type.element_type)));
}
@@ -6540,7 +6540,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var function = new CCodeFunction (get_ccode_destroy_function (st), "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", get_ccode_name (st) + "*"));
+ function.add_parameter (new CCodeParameter ("self", "%s *".printf (get_ccode_name (st))));
push_context (new EmitContext ());
push_function (function);
@@ -6569,8 +6569,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var function = new CCodeFunction (get_ccode_copy_function (st), "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", "const " + get_ccode_name (st) + "*"));
- function.add_parameter (new CCodeParameter ("dest", get_ccode_name (st) + "*"));
+ function.add_parameter (new CCodeParameter ("self", "const %s *".printf (get_ccode_name
(st))));
+ function.add_parameter (new CCodeParameter ("dest", "%s *".printf (get_ccode_name (st))));
push_context (new EmitContext ());
push_function (function);
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index cfbd9d3..65c71ae 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -461,7 +461,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
var type_as_struct = result.value_type.data_type as Struct;
if (param.direction == ParameterDirection.OUT) {
- name = "_vala_" + name;
+ name = "_vala_%s".printf (name);
}
if (param.direction == ParameterDirection.REF ||
@@ -484,7 +484,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
if (delegate_type != null && delegate_type.delegate_symbol.has_target) {
var target_cname = get_ccode_delegate_target_name (param);
if (param.direction == ParameterDirection.OUT) {
- target_cname = "_vala_" + target_cname;
+ target_cname = "_vala_%s".printf (target_cname);
}
CCodeExpression target_expr = new CCodeIdentifier (target_cname);
CCodeExpression delegate_target_destroy_notify = new CCodeIdentifier
(get_delegate_target_destroy_notify_cname (get_variable_cname (name)));
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 9c8e921..19f507b 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -558,7 +558,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
}
} else if (!m.coroutine) {
// declare local variable for out parameter to allow
assignment even when caller passes NULL
- var vardecl = new CCodeVariableDeclarator.zero
(get_variable_cname ("_vala_" + param.name), default_value_for_type (param.variable_type, true));
+ var vardecl = new CCodeVariableDeclarator.zero
(get_variable_cname ("_vala_%s".printf (param.name)), default_value_for_type (param.variable_type, true));
ccode.add_declaration (get_ccode_name (param.variable_type),
vardecl);
if (param.variable_type is ArrayType) {
@@ -567,7 +567,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
if (!array_type.fixed_length) {
for (int dim = 1; dim <= array_type.rank;
dim++) {
- vardecl = new
CCodeVariableDeclarator.zero (get_array_length_cname (get_variable_cname ("_vala_" + param.name), dim), new
CCodeConstant ("0"));
+ vardecl = new
CCodeVariableDeclarator.zero (get_array_length_cname (get_variable_cname ("_vala_%s".printf (param.name)),
dim), new CCodeConstant ("0"));
ccode.add_declaration ("int",
vardecl);
}
}
@@ -576,11 +576,11 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
var d = deleg_type.delegate_symbol;
if (d.has_target) {
// create variable to store delegate target
- vardecl = new CCodeVariableDeclarator.zero
("_vala_" + get_ccode_delegate_target_name (param), new CCodeConstant ("NULL"));
+ vardecl = new CCodeVariableDeclarator.zero
("_vala_%s".printf (get_ccode_delegate_target_name (param)), new CCodeConstant ("NULL"));
ccode.add_declaration ("void *", vardecl);
if (deleg_type.is_disposable ()) {
- vardecl = new
CCodeVariableDeclarator.zero (get_delegate_target_destroy_notify_cname (get_variable_cname ("_vala_" +
param.name)), new CCodeConstant ("NULL"));
+ vardecl = new
CCodeVariableDeclarator.zero (get_delegate_target_destroy_notify_cname (get_variable_cname ("_vala_%s".printf
(param.name))), new CCodeConstant ("NULL"));
ccode.add_declaration
("GDestroyNotify", vardecl);
}
}
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index 7ec2387..079ac52 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -774,7 +774,7 @@ public class Vala.GDBusClientModule : GDBusModule {
foreach (Parameter param in m.get_parameters ()) {
if (param.direction == ParameterDirection.OUT) {
- ccode.add_declaration (get_ccode_name (param.variable_type),
new CCodeVariableDeclarator ("_vala_" + param.name));
+ ccode.add_declaration (get_ccode_name (param.variable_type),
new CCodeVariableDeclarator ("_vala_%s".printf (param.name)));
var array_type = param.variable_type as ArrayType;
@@ -784,7 +784,7 @@ public class Vala.GDBusClientModule : GDBusModule {
}
}
- var target = new CCodeIdentifier ("_vala_" + param.name);
+ var target = new CCodeIdentifier ("_vala_%s".printf
(param.name));
bool may_fail;
receive_dbus_value (param.variable_type, new CCodeIdentifier
("_reply_message"), new CCodeIdentifier ("_reply_iter"), target, param, new CCodeIdentifier ("error"), out
may_fail);
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 4bbfab6..ed25185 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -34,7 +34,7 @@ public class Vala.GTypeModule : GErrorModule {
string ctypename = get_ccode_name (param.variable_type);
if (param.direction != ParameterDirection.IN) {
- ctypename += "*";
+ ctypename = "%s *".printf (ctypename);
}
var cparam = new CCodeParameter (get_variable_cname (param.name), ctypename);
@@ -91,8 +91,8 @@ public class Vala.GTypeModule : GErrorModule {
}
if (is_fundamental) {
- var ref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "ref",
"gpointer");
- var unref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "unref",
"void");
+ var ref_fun = new CCodeFunction ("%sref".printf (get_ccode_lower_case_prefix (cl)),
"gpointer");
+ var unref_fun = new CCodeFunction ("%sunref".printf (get_ccode_lower_case_prefix
(cl)), "void");
if (cl.is_private_symbol ()) {
ref_fun.modifiers = CCodeModifiers.STATIC;
unref_fun.modifiers = CCodeModifiers.STATIC;
@@ -173,14 +173,14 @@ public class Vala.GTypeModule : GErrorModule {
decl_space.add_function_declaration (function);
} else if (!is_gtypeinstance && !is_gsource) {
if (cl.base_class == null) {
- var function = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "free",
"void");
+ var function = new CCodeFunction ("%sfree".printf
(get_ccode_lower_case_prefix (cl)), "void");
if (cl.is_private_symbol ()) {
function.modifiers = CCodeModifiers.STATIC;
} else if (context.hide_internal && cl.is_internal_symbol ()) {
function.modifiers = CCodeModifiers.INTERNAL;
}
- function.add_parameter (new CCodeParameter ("self", get_ccode_name (cl) +
"*"));
+ function.add_parameter (new CCodeParameter ("self", "%s *".printf
(get_ccode_name (cl))));
decl_space.add_function_declaration (function);
}
@@ -196,7 +196,7 @@ public class Vala.GTypeModule : GErrorModule {
}
public override void generate_class_struct_declaration (Class cl, CCodeFile decl_space) {
- if (add_symbol_declaration (decl_space, cl, "struct _" + get_ccode_name (cl))) {
+ if (add_symbol_declaration (decl_space, cl, "struct _%s".printf (get_ccode_name (cl)))) {
return;
}
@@ -274,7 +274,7 @@ public class Vala.GTypeModule : GErrorModule {
vdeclarator.add_parameter (cselfparam);
string creturn_type;
if (prop.property_type.is_real_non_null_struct_type ()) {
- var cvalueparam = new CCodeParameter ("result", get_ccode_name
(prop.get_accessor.value_type) + "*");
+ var cvalueparam = new CCodeParameter ("result", "%s *".printf
(get_ccode_name (prop.get_accessor.value_type)));
vdeclarator.add_parameter (cvalueparam);
creturn_type = "void";
} else {
@@ -297,7 +297,7 @@ public class Vala.GTypeModule : GErrorModule {
if (prop.set_accessor != null) {
CCodeParameter cvalueparam;
if (prop.property_type.is_real_non_null_struct_type ()) {
- cvalueparam = new CCodeParameter ("value", get_ccode_name
(prop.set_accessor.value_type) + "*");
+ cvalueparam = new CCodeParameter ("value", "%s *".printf
(get_ccode_name (prop.set_accessor.value_type)));
} else {
cvalueparam = new CCodeParameter ("value", get_ccode_name
(prop.set_accessor.value_type));
}
@@ -324,7 +324,7 @@ public class Vala.GTypeModule : GErrorModule {
foreach (Field f in cl.get_fields ()) {
string field_ctype = get_ccode_name (f.variable_type);
if (f.is_volatile) {
- field_ctype = "volatile " + field_ctype;
+ field_ctype = "volatile %s".printf (field_ctype);
}
if (f.access != SymbolAccessibility.PRIVATE) {
@@ -402,7 +402,7 @@ public class Vala.GTypeModule : GErrorModule {
}
void generate_class_private_declaration (Class cl, CCodeFile decl_space) {
- if (decl_space.add_declaration (get_ccode_name (cl) + "Private")) {
+ if (decl_space.add_declaration ("%sPrivate".printf (get_ccode_name (cl)))) {
return;
}
@@ -431,7 +431,7 @@ public class Vala.GTypeModule : GErrorModule {
foreach (Field f in cl.get_fields ()) {
string field_ctype = get_ccode_name (f.variable_type);
if (f.is_volatile) {
- field_ctype = "volatile " + field_ctype;
+ field_ctype = "volatile %s".printf (field_ctype);
}
if (f.binding == MemberBinding.INSTANCE) {
@@ -670,7 +670,7 @@ public class Vala.GTypeModule : GErrorModule {
var ref_count = new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"),
"ref_count");
// ref function
- var ref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "ref",
"gpointer");
+ var ref_fun = new CCodeFunction ("%sref".printf (get_ccode_lower_case_prefix
(cl)), "gpointer");
ref_fun.add_parameter (new CCodeParameter ("instance", "gpointer"));
if (cl.is_private_symbol ()) {
ref_fun.modifiers = CCodeModifiers.STATIC;
@@ -679,7 +679,7 @@ public class Vala.GTypeModule : GErrorModule {
}
push_function (ref_fun);
- ccode.add_declaration (get_ccode_name (cl) + "*", new CCodeVariableDeclarator
("self", new CCodeIdentifier ("instance")));
+ ccode.add_declaration ("%s *".printf (get_ccode_name (cl)), new
CCodeVariableDeclarator ("self", new CCodeIdentifier ("instance")));
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_atomic_int_inc"));
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF,
ref_count));
ccode.add_expression (ccall);
@@ -689,7 +689,7 @@ public class Vala.GTypeModule : GErrorModule {
cfile.add_function (ref_fun);
// unref function
- var unref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) +
"unref", "void");
+ var unref_fun = new CCodeFunction ("%sunref".printf
(get_ccode_lower_case_prefix (cl)), "void");
unref_fun.add_parameter (new CCodeParameter ("instance", "gpointer"));
if (cl.is_private_symbol ()) {
unref_fun.modifiers = CCodeModifiers.STATIC;
@@ -698,7 +698,7 @@ public class Vala.GTypeModule : GErrorModule {
}
push_function (unref_fun);
- ccode.add_declaration (get_ccode_name (cl) + "*", new CCodeVariableDeclarator
("self", new CCodeIdentifier ("instance")));
+ ccode.add_declaration ("%s *".printf (get_ccode_name (cl)), new
CCodeVariableDeclarator ("self", new CCodeIdentifier ("instance")));
ccall = new CCodeFunctionCall (new CCodeIdentifier
("g_atomic_int_dec_and_test"));
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF,
ref_count));
ccode.open_if (ccall);
@@ -763,7 +763,7 @@ public class Vala.GTypeModule : GErrorModule {
push_function (function);
var vpointer = new CCodeMemberAccess(new CCodeMemberAccess.pointer (new CCodeIdentifier
("value"), "data[0]"),"v_pointer");
- var ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_lower_case_prefix (cl) +
"unref"));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%sunref".printf
(get_ccode_lower_case_prefix (cl))));
ccall.add_argument (vpointer);
ccode.open_if (vpointer);
@@ -785,7 +785,7 @@ public class Vala.GTypeModule : GErrorModule {
var dest_vpointer = new CCodeMemberAccess (new CCodeMemberAccess.pointer (new CCodeIdentifier
("dest_value"), "data[0]"), "v_pointer");
var src_vpointer = new CCodeMemberAccess (new CCodeMemberAccess.pointer (new CCodeIdentifier
("src_value"), "data[0]"), "v_pointer");
- var ref_ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_lower_case_prefix (cl)
+ "ref"));
+ var ref_ccall = new CCodeFunctionCall (new CCodeIdentifier ("%sref".printf
(get_ccode_lower_case_prefix (cl))));
ref_ccall.add_argument ( src_vpointer );
ccode.open_if (src_vpointer);
@@ -826,7 +826,7 @@ public class Vala.GTypeModule : GErrorModule {
push_function (function);
- ccode.add_declaration (get_ccode_name (cl) + "**", new CCodeVariableDeclarator ("object_p",
new CCodeMemberAccess (new CCodeIdentifier ("collect_values[0]"), "v_pointer")));
+ ccode.add_declaration ("%s **".printf (get_ccode_name (cl)), new CCodeVariableDeclarator
("object_p", new CCodeMemberAccess (new CCodeIdentifier ("collect_values[0]"), "v_pointer")));
var value_type_name_fct = new CCodeFunctionCall (new CCodeIdentifier ("G_VALUE_TYPE_NAME"));
value_type_name_fct.add_argument (new CCodeConstant ("value"));
@@ -871,7 +871,7 @@ public class Vala.GTypeModule : GErrorModule {
var collect_vpointer = new CCodeMemberAccess (new CCodeIdentifier ("collect_values[0]"),
"v_pointer");
ccode.open_if (collect_vpointer);
- ccode.add_declaration (get_ccode_name (cl) + "*", new CCodeVariableDeclarator ("object",
collect_vpointer));
+ ccode.add_declaration ("%s *".printf (get_ccode_name (cl)), new CCodeVariableDeclarator
("object", collect_vpointer));
var obj_identifier = new CCodeIdentifier ("object");
var l_expression = new CCodeMemberAccess (new CCodeMemberAccess.pointer (obj_identifier,
"parent_instance"), "g_class");
var sub_condition = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, l_expression,
new CCodeConstant ("NULL"));
@@ -986,7 +986,7 @@ public class Vala.GTypeModule : GErrorModule {
push_function (function);
- ccode.add_declaration (get_ccode_name (cl)+"*", new CCodeVariableDeclarator ("old"));
+ ccode.add_declaration ("%s *".printf (get_ccode_name (cl)), new CCodeVariableDeclarator
("old"));
var ccall_typecheck = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_CHECK_VALUE_TYPE"));
ccall_typecheck.add_argument (new CCodeIdentifier ( "value" ));
@@ -1056,7 +1056,7 @@ public class Vala.GTypeModule : GErrorModule {
push_function (function);
- ccode.add_declaration (get_ccode_name (cl)+"*", new CCodeVariableDeclarator ("old"));
+ ccode.add_declaration ("%s *".printf (get_ccode_name (cl)), new CCodeVariableDeclarator
("old"));
var ccall_typecheck = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_CHECK_VALUE_TYPE"));
ccall_typecheck.add_argument (new CCodeIdentifier ( "value" ));
@@ -1191,8 +1191,8 @@ public class Vala.GTypeModule : GErrorModule {
fundamental_class = fundamental_class.base_class;
}
- var ccast = new CCodeCastExpression (new CCodeIdentifier ("klass"), get_ccode_name
(fundamental_class) + "Class *");
- var finalize_assignment = new CCodeAssignment (new CCodeMemberAccess.pointer (ccast,
"finalize"), new CCodeIdentifier (get_ccode_lower_case_prefix (cl) + "finalize"));
+ var ccast = new CCodeCastExpression (new CCodeIdentifier ("klass"), "%sClass
*".printf (get_ccode_name (fundamental_class)));
+ var finalize_assignment = new CCodeAssignment (new CCodeMemberAccess.pointer (ccast,
"finalize"), new CCodeIdentifier ("%sfinalize".printf (get_ccode_lower_case_prefix (cl))));
ccode.add_expression (finalize_assignment);
}
@@ -1213,7 +1213,7 @@ public class Vala.GTypeModule : GErrorModule {
// there is currently no default handler for abstract async methods
if (!m.is_abstract || !m.coroutine) {
- var ccast = new CCodeCastExpression (new CCodeIdentifier ("klass"),
get_ccode_name (base_type) + "Class *");
+ var ccast = new CCodeCastExpression (new CCodeIdentifier ("klass"), "%sClass
*".printf (get_ccode_name (base_type)));
ccode.add_assignment (new CCodeMemberAccess.pointer (ccast,
get_ccode_vfunc_name (m.base_method)), new CCodeIdentifier (get_ccode_real_name (m)));
if (m.coroutine) {
@@ -1227,7 +1227,7 @@ public class Vala.GTypeModule : GErrorModule {
if (sig.default_handler == null) {
continue;
}
- var ccast = new CCodeCastExpression (new CCodeIdentifier ("klass"), get_ccode_name
(cl) + "Class *");
+ var ccast = new CCodeCastExpression (new CCodeIdentifier ("klass"), "%sClass
*".printf (get_ccode_name (cl)));
ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, get_ccode_vfunc_name
(sig.default_handler)), new CCodeIdentifier (get_ccode_real_name (sig.default_handler)));
}
@@ -1285,9 +1285,9 @@ public class Vala.GTypeModule : GErrorModule {
cfile.add_function (function);
CCodeExpression cfunc = new CCodeIdentifier (function.name);
- string cast = return_type + "(*)";
- string cast_args = get_ccode_name (iface) + "*";
- cast += "(" + cast_args + ")";
+ string cast = "%s (*)".printf (return_type);
+ string cast_args = "%s *".printf (get_ccode_name (iface));
+ cast = "%s (%s)".printf (cast, cast_args);
cfunc = new CCodeCastExpression (cfunc, cast);
var ciface = new CCodeIdentifier ("iface");
ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, base_name), cfunc);
@@ -1304,7 +1304,7 @@ public class Vala.GTypeModule : GErrorModule {
/* save pointer to parent vtable */
string parent_iface_var = "%s_%s_parent_iface".printf (get_ccode_lower_case_name (cl),
get_ccode_lower_case_name (iface));
- var parent_decl = new CCodeDeclaration (get_ccode_type_name (iface) + "*");
+ var parent_decl = new CCodeDeclaration ("%s *".printf (get_ccode_type_name (iface)));
var parent_var_decl = new CCodeVariableDeclarator (parent_iface_var);
parent_var_decl.initializer = new CCodeConstant ("NULL");
parent_decl.add_declarator (parent_var_decl);
@@ -1501,9 +1501,9 @@ public class Vala.GTypeModule : GErrorModule {
if (m.return_type.is_real_non_null_struct_type ()) {
cast = "void (*)";
} else {
- cast = get_ccode_name (m.return_type) + " (*)";
+ cast = "%s (*)".printf (get_ccode_name (m.return_type));
}
- string cast_args = get_ccode_name (base_type) + "*";
+ string cast_args = "%s *".printf (get_ccode_name (base_type));
var vdeclarator = new CCodeFunctionDeclarator (get_ccode_vfunc_name (m));
var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
@@ -1527,14 +1527,14 @@ public class Vala.GTypeModule : GErrorModule {
var tmp = cparam_map.get (min_pos);
if (tmp.ellipsis) {
- cast_args += ", " + " ...";
+ cast_args = "%s, ...".printf (cast_args);
} else {
- cast_args += ", " + tmp.type_name;
+ cast_args = "%s, %s".printf (cast_args, tmp.type_name);
}
}
last_pos = min_pos;
}
- cast += "(" + cast_args + ")";
+ cast = "%s (%s)".printf (cast, cast_args);
return new CCodeCastExpression (cfunc, cast);
}
@@ -1576,7 +1576,7 @@ public class Vala.GTypeModule : GErrorModule {
var function = new CCodeFunction ("%s_class_finalize".printf (get_ccode_lower_case_name (cl,
null)), "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("klass", get_ccode_name (cl) + "Class *"));
+ function.add_parameter (new CCodeParameter ("klass", "%sClass *".printf (get_ccode_name
(cl))));
push_function (function);
@@ -1598,7 +1598,7 @@ public class Vala.GTypeModule : GErrorModule {
var function = new CCodeFunction ("%s_base_finalize".printf (get_ccode_lower_case_name (cl,
null)), "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("klass", get_ccode_name (cl) + "Class *"));
+ function.add_parameter (new CCodeParameter ("klass", "%sClass *".printf (get_ccode_name
(cl))));
push_function (function);
@@ -1630,7 +1630,7 @@ public class Vala.GTypeModule : GErrorModule {
}
var func = new CCodeFunction ("%s_finalize".printf (get_ccode_lower_case_name (cl,
null)));
- func.add_parameter (new CCodeParameter ("obj", get_ccode_name (fundamental_class) +
"*"));
+ func.add_parameter (new CCodeParameter ("obj", "%s *".printf (get_ccode_name
(fundamental_class))));
func.modifiers = CCodeModifiers.STATIC;
push_function (func);
@@ -1643,7 +1643,7 @@ public class Vala.GTypeModule : GErrorModule {
if (!cl.is_compact) {
ccast = generate_instance_cast (new CCodeIdentifier ("obj"), cl);
} else {
- ccast = new CCodeCastExpression (new CCodeIdentifier ("obj"), get_ccode_name
(cl) + "*");
+ ccast = new CCodeCastExpression (new CCodeIdentifier ("obj"), "%s *".printf
(get_ccode_name (cl)));
}
ccode.add_declaration ("%s *".printf (get_ccode_name (cl)), new
CCodeVariableDeclarator ("self"));
@@ -1656,14 +1656,14 @@ public class Vala.GTypeModule : GErrorModule {
ccode.add_expression (call);
}
} else {
- var function = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "free", "void");
+ var function = new CCodeFunction ("%sfree".printf (get_ccode_lower_case_prefix (cl)),
"void");
if (cl.is_private_symbol ()) {
function.modifiers = CCodeModifiers.STATIC;
} else if (context.hide_internal && cl.is_internal_symbol ()) {
function.modifiers = CCodeModifiers.INTERNAL;
}
- function.add_parameter (new CCodeParameter ("self", get_ccode_name (cl) + "*"));
+ function.add_parameter (new CCodeParameter ("self", "%s *".printf (get_ccode_name
(cl))));
push_function (function);
}
@@ -1993,7 +1993,7 @@ public class Vala.GTypeModule : GErrorModule {
vdeclarator.add_parameter (cselfparam);
string creturn_type;
if (returns_real_struct) {
- var cvalueparam = new CCodeParameter ("value", get_ccode_name
(prop.get_accessor.value_type) + "*");
+ var cvalueparam = new CCodeParameter ("value", "%s *".printf
(get_ccode_name (prop.get_accessor.value_type)));
vdeclarator.add_parameter (cvalueparam);
creturn_type = "void";
} else {
@@ -2015,7 +2015,7 @@ public class Vala.GTypeModule : GErrorModule {
var vdeclarator = new CCodeFunctionDeclarator ("set_%s".printf
(prop.name));
vdeclarator.add_parameter (cselfparam);
if (returns_real_struct) {
- var cvalueparam = new CCodeParameter ("value", get_ccode_name
(prop.set_accessor.value_type) + "*");
+ var cvalueparam = new CCodeParameter ("value", "%s *".printf
(get_ccode_name (prop.set_accessor.value_type)));
vdeclarator.add_parameter (cvalueparam);
} else {
var cvalueparam = new CCodeParameter ("value", get_ccode_name
(prop.set_accessor.value_type));
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 73273f3..122e0ce 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -672,7 +672,7 @@ public class Vala.GirParser : CodeVisitor {
}
if (p != null) {
- prefix = p+"_"+prefix;
+ prefix = "%s_%s".printf (p, prefix ?? "");
}
}
@@ -772,7 +772,7 @@ public class Vala.GirParser : CodeVisitor {
if (finish_cname.has_suffix ("_async")) {
finish_cname = finish_cname.substring (0, finish_cname.length -
"_async".length);
}
- finish_cname += "_finish";
+ finish_cname = "%s_finish".printf (finish_cname);
}
return finish_cname;
}
@@ -966,7 +966,7 @@ public class Vala.GirParser : CodeVisitor {
var getters = parent.lookup_all ("get_%s".printf (name));
if (getters != null) {
foreach (var g in getters) {
- if ((getter == null || !g.merged) && g.get_cname ()
== parent.get_lower_case_cprefix() + "get_" + name) {
+ if ((getter == null || !g.merged) && g.get_cname ()
== "%sget_%s".printf (parent.get_lower_case_cprefix (), name)) {
getter = g;
}
}
@@ -976,7 +976,7 @@ public class Vala.GirParser : CodeVisitor {
var setters = parent.lookup_all ("set_%s".printf (name));
if (setters != null) {
foreach (var s in setters) {
- if ((setter == null || !s.merged) && s.get_cname ()
== parent.get_lower_case_cprefix() + "set_" + name) {
+ if ((setter == null || !s.merged) && s.get_cname ()
== "%sset_%s".printf (parent.get_lower_case_cprefix (), name)) {
setter = s;
}
}
@@ -1121,9 +1121,9 @@ public class Vala.GirParser : CodeVisitor {
var f = fn.symbol as Field;
if (f != null) {
if (f.binding == MemberBinding.INSTANCE) {
- f.set_attribute_string ("CCode",
"cname", name + "." + fn.get_cname ());
+ f.set_attribute_string ("CCode",
"cname", "%s.%s".printf (name, fn.get_cname ()));
}
- f.name = symbol.name + "_" + f.name;
+ f.name = "%s_%s".printf (symbol.name, f.name);
fn.name = f.name;
parent.add_member (fn);
}
diff --git a/vala/valapropertyaccessor.vala b/vala/valapropertyaccessor.vala
index 5a91b3f..5491f5e 100644
--- a/vala/valapropertyaccessor.vala
+++ b/vala/valapropertyaccessor.vala
@@ -121,9 +121,9 @@ public class Vala.PropertyAccessor : Subroutine {
public Method? get_method () {
Method? m = null;
if (readable) {
- m = new Method ("get_"+prop.name, value_type, source_reference, comment);
+ m = new Method ("get_%s".printf (prop.name), value_type, source_reference, comment);
} else if (writable) {
- m = new Method ("set_"+prop.name, new VoidType(), source_reference, comment);
+ m = new Method ("set_%s".printf (prop.name), new VoidType(), source_reference,
comment);
m.add_parameter (value_parameter.copy ());
}
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala
index 731ea26..ceb6b33 100644
--- a/vapigen/valagidlparser.vala
+++ b/vapigen/valagidlparser.vala
@@ -210,7 +210,7 @@ public class Vala.GIdlParser : CodeVisitor {
if (name == null || name == ".new") {
name = "new";
} else {
- name = "new_"+name;
+ name = "new_%s".printf (name);
}
}
if (container != null) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]