[vala/wip/attributes: 2/8] codegen: Add CCodeBaseModule.get_ccode_name
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 2/8] codegen: Add CCodeBaseModule.get_ccode_name
- Date: Sun, 26 Jun 2011 13:50:29 +0000 (UTC)
commit 0c3496500c9206e701b5a29193db476c8bb18c34
Author: Luca Bruno <lucabru src gnome org>
Date: Sat Jun 25 09:23:16 2011 +0200
codegen: Add CCodeBaseModule.get_ccode_name
codegen/valaccodearraymodule.vala | 32 ++--
codegen/valaccodeassignmentmodule.vala | 4 +-
codegen/valaccodebasemodule.vala | 239 ++++++++++++++++--------------
codegen/valaccodecontrolflowmodule.vala | 2 +-
codegen/valaccodedelegatemodule.vala | 26 ++--
codegen/valaccodememberaccessmodule.vala | 38 +++---
codegen/valaccodemethodcallmodule.vala | 22 ++--
codegen/valaccodemethodmodule.vala | 50 +++---
codegen/valaccodestructmodule.vala | 46 +++---
codegen/valaclassregisterfunction.vala | 4 +-
codegen/valagasyncmodule.vala | 30 ++--
codegen/valagdbusclientmodule.vala | 40 +++---
codegen/valagdbusmodule.vala | 4 +-
codegen/valagdbusservermodule.vala | 50 +++---
codegen/valagerrormodule.vala | 14 +-
codegen/valagobjectmodule.vala | 24 ++--
codegen/valagsignalmodule.vala | 6 +-
codegen/valagtypemodule.vala | 180 +++++++++++-----------
codegen/valagvariantmodule.vala | 36 +++---
codegen/valatyperegisterfunction.vala | 10 +-
20 files changed, 438 insertions(+), 419 deletions(-)
---
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index 18e38df..59d569e 100644
--- a/codegen/valaccodearraymodule.vala
+++ b/codegen/valaccodearraymodule.vala
@@ -62,7 +62,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
gnew = new CCodeFunctionCall (new CCodeIdentifier ("calloc"));
} else {
gnew = new CCodeFunctionCall (new CCodeIdentifier ("g_new0"));
- gnew.add_argument (new CCodeIdentifier (expr.element_type.get_cname ()));
+ gnew.add_argument (new CCodeIdentifier (get_ccode_name (expr.element_type)));
}
bool first = true;
@@ -103,7 +103,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
if (context.profile == Profile.POSIX) {
var csizeof = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- csizeof.add_argument (new CCodeIdentifier (expr.element_type.get_cname ()));
+ csizeof.add_argument (new CCodeIdentifier (get_ccode_name (expr.element_type)));
gnew.add_argument (csizeof);
}
@@ -222,7 +222,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
}
public override string? append_struct_array_free (Struct st) {
- string cname = "_vala_%s_array_free".printf (st.get_cname ());;
+ string cname = "_vala_%s_array_free".printf (get_ccode_name (st));
if (cfile.add_declaration (cname)) {
return cname;
@@ -230,7 +230,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
var fun = new CCodeFunction (cname, "void");
fun.modifiers = CCodeModifiers.STATIC;
- fun.add_parameter (new CCodeParameter ("array", "%s*".printf (st.get_cname ())));
+ fun.add_parameter (new CCodeParameter ("array", "%s*".printf (get_ccode_name (st))));
fun.add_parameter (new CCodeParameter ("array_length", "gint"));
push_function (fun);
@@ -483,10 +483,10 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
// declaration
- var function = new CCodeFunction (dup_func, array_type.get_cname ());
+ var function = new CCodeFunction (dup_func, get_ccode_name (array_type));
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", array_type.get_cname ()));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (array_type)));
// total length over all dimensions
function.add_parameter (new CCodeParameter ("length", "int"));
if (array_type.element_type is GenericType) {
@@ -503,7 +503,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
if (requires_copy (array_type.element_type)) {
var cvardecl = new CCodeVariableDeclarator ("result");
var gnew = new CCodeFunctionCall (new CCodeIdentifier ("g_new0"));
- gnew.add_argument (new CCodeIdentifier (array_type.element_type.get_cname ()));
+ gnew.add_argument (new CCodeIdentifier (get_ccode_name (array_type.element_type)));
CCodeExpression length_expr = new CCodeIdentifier ("length");
// add extra item to have array NULL-terminated for all reference types
@@ -512,7 +512,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
}
gnew.add_argument (length_expr);
- ccode.add_declaration (array_type.get_cname (), cvardecl);
+ ccode.add_declaration (get_ccode_name (array_type), cvardecl);
ccode.add_assignment (new CCodeIdentifier ("result"), gnew);
ccode.add_declaration ("int", new CCodeVariableDeclarator ("i"));
@@ -530,7 +530,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
dup_call.add_argument (new CCodeIdentifier ("self"));
var sizeof_call = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- sizeof_call.add_argument (new CCodeIdentifier (array_type.element_type.get_cname ()));
+ sizeof_call.add_argument (new CCodeIdentifier (get_ccode_name (array_type.element_type)));
dup_call.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeIdentifier ("length"), sizeof_call));
ccode.add_return (dup_call);
@@ -559,8 +559,8 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
var function = new CCodeFunction (dup_func, "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", array_type.get_cname () + "*"));
- function.add_parameter (new CCodeParameter ("dest", array_type.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (array_type) + "*"));
+ function.add_parameter (new CCodeParameter ("dest", get_ccode_name (array_type) + "*"));
// definition
@@ -584,7 +584,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
dup_call.add_argument (new CCodeIdentifier ("self"));
var sizeof_call = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- sizeof_call.add_argument (new CCodeIdentifier (array_type.element_type.get_cname ()));
+ sizeof_call.add_argument (new CCodeIdentifier (get_ccode_name (array_type.element_type)));
dup_call.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeConstant ("%d".printf (array_type.length)), sizeof_call));
ccode.add_expression (dup_call);
@@ -611,13 +611,13 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
var function = new CCodeFunction (add_func, "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("array", array_type.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("array", get_ccode_name (array_type) + "*"));
function.add_parameter (new CCodeParameter ("length", "int*"));
function.add_parameter (new CCodeParameter ("size", "int*"));
push_function (function);
- string typename = array_type.element_type.get_cname ();
+ string typename = get_ccode_name (array_type.element_type);
CCodeExpression value = new CCodeIdentifier ("value");
if (array_type.element_type.is_real_struct_type ()) {
if (!array_type.element_type.nullable || !array_type.element_type.value_owned) {
@@ -635,7 +635,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
var size = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("size"));
var renew_call = new CCodeFunctionCall (new CCodeIdentifier ("g_renew"));
- renew_call.add_argument (new CCodeIdentifier (array_type.element_type.get_cname ()));
+ renew_call.add_argument (new CCodeIdentifier (get_ccode_name (array_type.element_type)));
renew_call.add_argument (array);
if (array_type.element_type.is_reference_type_or_type_parameter ()) {
// NULL terminate array
@@ -715,7 +715,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
return base.generate_parameter (param, decl_space, cparam_map, carg_map);
}
- string ctypename = param.variable_type.get_cname ();
+ string ctypename = get_ccode_name (param.variable_type);
if (param.direction != ParameterDirection.IN) {
ctypename += "*";
diff --git a/codegen/valaccodeassignmentmodule.vala b/codegen/valaccodeassignmentmodule.vala
index 725fde0..de8eaa0 100644
--- a/codegen/valaccodeassignmentmodule.vala
+++ b/codegen/valaccodeassignmentmodule.vala
@@ -136,7 +136,7 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
// it is necessary to use memcpy for fixed-length (stack-allocated) arrays
// simple assignments do not work in C
var sizeof_call = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- sizeof_call.add_argument (new CCodeIdentifier (array_type.element_type.get_cname ()));
+ sizeof_call.add_argument (new CCodeIdentifier (get_ccode_name (array_type.element_type)));
var size = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeConstant ("%d".printf (array_type.length)), sizeof_call);
var ccopy = new CCodeFunctionCall (new CCodeIdentifier ("memcpy"));
ccopy.add_argument (lhs);
@@ -196,7 +196,7 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
// it is necessary to use memcpy for fixed-length (stack-allocated) arrays
// simple assignments do not work in C
var sizeof_call = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- sizeof_call.add_argument (new CCodeIdentifier (array_type.element_type.get_cname ()));
+ sizeof_call.add_argument (new CCodeIdentifier (get_ccode_name (array_type.element_type)));
var size = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeConstant ("%d".printf (array_type.length)), sizeof_call);
var ccopy = new CCodeFunctionCall (new CCodeIdentifier ("memcpy"));
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index cac0f59..8b12e45 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -666,11 +666,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
public virtual bool generate_enum_declaration (Enum en, CCodeFile decl_space) {
- if (add_symbol_declaration (decl_space, en, en.get_cname ())) {
+ if (add_symbol_declaration (decl_space, en, get_ccode_name (en))) {
return false;
}
- var cenum = new CCodeEnum (en.get_cname ());
+ var cenum = new CCodeEnum (get_ccode_name (en));
cenum.deprecated = en.deprecated;
@@ -678,14 +678,14 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
foreach (EnumValue ev in en.get_values ()) {
CCodeEnumValue c_ev;
if (ev.value == null) {
- c_ev = new CCodeEnumValue (ev.get_cname ());
+ c_ev = new CCodeEnumValue (get_ccode_name (ev));
if (en.is_flags) {
c_ev.value = new CCodeConstant ("1 << %d".printf (flag_shift));
flag_shift += 1;
}
} else {
ev.value.emit (this);
- c_ev = new CCodeEnumValue (ev.get_cname (), get_cvalue (ev.value));
+ c_ev = new CCodeEnumValue (get_ccode_name (ev), get_cvalue (ev.value));
}
c_ev.deprecated = ev.deprecated;
cenum.add_value (c_ev);
@@ -757,7 +757,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
push_context (init_context);
- var initf = new CCodeFunctionCall (new CCodeIdentifier (mutex_type.default_construction_method.get_cname ()));
+ var initf = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (mutex_type.default_construction_method)));
initf.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, l));
ccode.add_expression (initf);
pop_context ();
@@ -778,7 +778,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return;
}
- if (add_symbol_declaration (decl_space, c, c.get_cname ())) {
+ if (add_symbol_declaration (decl_space, c, get_ccode_name (c))) {
return;
}
@@ -802,7 +802,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
cinitializer = null;
}
- cdecl.add_declarator (new CCodeVariableDeclarator ("%s%s".printf (c.get_cname (), arr), cinitializer));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("%s%s".printf (get_ccode_name (c), arr), cinitializer));
if (c.is_private_symbol ()) {
cdecl.modifiers = CCodeModifiers.STATIC;
} else {
@@ -811,7 +811,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
decl_space.add_constant_declaration (cdecl);
} else {
- var cdefine = new CCodeMacroReplacement.with_expression (c.get_cname (), get_cvalue (c.value));
+ var cdefine = new CCodeMacroReplacement.with_expression (get_ccode_name (c), get_cvalue (c.value));
decl_space.add_type_member_declaration (cdefine);
}
}
@@ -838,7 +838,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var cinitializer = get_cvalue (c.value);
- ccode.add_declaration (type_name, new CCodeVariableDeclarator ("%s%s".printf (c.get_cname (), arr), cinitializer), CCodeModifiers.STATIC);
+ ccode.add_declaration (type_name, new CCodeVariableDeclarator ("%s%s".printf (get_ccode_name (c), arr), cinitializer), CCodeModifiers.STATIC);
return;
}
@@ -854,19 +854,19 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
public void generate_field_declaration (Field f, CCodeFile decl_space) {
- if (add_symbol_declaration (decl_space, f, f.get_cname ())) {
+ if (add_symbol_declaration (decl_space, f, get_ccode_name (f))) {
return;
}
generate_type_declaration (f.variable_type, decl_space);
- string field_ctype = f.variable_type.get_cname ();
+ string field_ctype = get_ccode_name (f.variable_type);
if (f.is_volatile) {
field_ctype = "volatile " + field_ctype;
}
var cdecl = new CCodeDeclaration (field_ctype);
- cdecl.add_declarator (new CCodeVariableDeclarator (f.get_cname (), null, f.variable_type.get_cdeclarator_suffix ()));
+ cdecl.add_declarator (new CCodeVariableDeclarator (get_ccode_name (f), null, f.variable_type.get_cdeclarator_suffix ()));
if (f.is_private_symbol ()) {
cdecl.modifiers = CCodeModifiers.STATIC;
} else {
@@ -879,8 +879,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (f.get_lock_used ()) {
// Declare mutex for static member
- var flock = new CCodeDeclaration (mutex_type.get_cname ());
- var flock_decl = new CCodeVariableDeclarator (get_symbol_lock_name (f.get_cname ()), new CCodeConstant ("{0}"));
+ 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}"));
flock.add_declarator (flock_decl);
if (f.is_private_symbol ()) {
@@ -898,8 +898,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
for (int dim = 1; dim <= array_type.rank; dim++) {
var len_type = int_type.copy ();
- cdecl = new CCodeDeclaration (len_type.get_cname ());
- cdecl.add_declarator (new CCodeVariableDeclarator (get_array_length_cname (f.get_cname (), dim)));
+ cdecl = new CCodeDeclaration (get_ccode_name (len_type));
+ cdecl.add_declarator (new CCodeVariableDeclarator (get_array_length_cname (get_ccode_name (f), dim)));
if (f.is_private_symbol ()) {
cdecl.modifiers = CCodeModifiers.STATIC;
} else {
@@ -914,7 +914,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
// create field to store delegate target
cdecl = new CCodeDeclaration ("gpointer");
- cdecl.add_declarator (new CCodeVariableDeclarator (get_delegate_target_cname (f.get_cname ())));
+ cdecl.add_declarator (new CCodeVariableDeclarator (get_delegate_target_cname (get_ccode_name (f))));
if (f.is_private_symbol ()) {
cdecl.modifiers = CCodeModifiers.STATIC;
} else {
@@ -924,7 +924,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (delegate_type.value_owned) {
cdecl = new CCodeDeclaration ("GDestroyNotify");
- cdecl.add_declarator (new CCodeVariableDeclarator (get_delegate_target_destroy_notify_cname (f.get_cname ())));
+ cdecl.add_declarator (new CCodeVariableDeclarator (get_delegate_target_destroy_notify_cname (get_ccode_name (f))));
if (f.is_private_symbol ()) {
cdecl.modifiers = CCodeModifiers.STATIC;
} else {
@@ -946,16 +946,16 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
CCodeExpression lhs = null;
- string field_ctype = f.variable_type.get_cname ();
+ string field_ctype = get_ccode_name (f.variable_type);
if (f.is_volatile) {
field_ctype = "volatile " + field_ctype;
}
if (f.binding == MemberBinding.INSTANCE) {
if (is_gtypeinstance && f.access == SymbolAccessibility.PRIVATE) {
- lhs = new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), "priv"), f.get_cname ());
+ lhs = new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), "priv"), get_ccode_name (f));
} else {
- lhs = new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), f.get_cname ());
+ lhs = new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), get_ccode_name (f));
}
if (f.initializer != null) {
@@ -1010,9 +1010,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (f.access == SymbolAccessibility.PRIVATE) {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf (cl.get_upper_case_cname ())));
ccall.add_argument (new CCodeIdentifier ("klass"));
- lhs = new CCodeMemberAccess (ccall, f.get_cname (), true);
+ lhs = new CCodeMemberAccess (ccall, get_ccode_name (f), true);
} else {
- lhs = new CCodeMemberAccess (new CCodeIdentifier ("klass"), f.get_cname (), true);
+ lhs = new CCodeMemberAccess (new CCodeIdentifier ("klass"), get_ccode_name (f), true);
}
if (f.initializer != null) {
@@ -1042,9 +1042,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
generate_field_declaration (f, internal_header_file);
}
- lhs = new CCodeIdentifier (f.get_cname ());
+ lhs = new CCodeIdentifier (get_ccode_name (f));
- var var_decl = new CCodeVariableDeclarator (f.get_cname (), null, f.variable_type.get_cdeclarator_suffix ());
+ var var_decl = new CCodeVariableDeclarator (get_ccode_name (f), null, f.variable_type.get_cdeclarator_suffix ());
var_decl.initializer = default_value_for_type (f.variable_type, true);
if (class_init_context != null) {
@@ -1079,8 +1079,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
for (int dim = 1; dim <= array_type.rank; dim++) {
var len_type = int_type.copy ();
- var len_def = new CCodeDeclaration (len_type.get_cname ());
- len_def.add_declarator (new CCodeVariableDeclarator (get_array_length_cname (f.get_cname (), dim), new CCodeConstant ("0")));
+ var len_def = new CCodeDeclaration (get_ccode_name (len_type));
+ len_def.add_declarator (new CCodeVariableDeclarator (get_array_length_cname (get_ccode_name (f), dim), new CCodeConstant ("0")));
if (!f.is_private_symbol ()) {
len_def.modifiers = CCodeModifiers.EXTERN;
} else {
@@ -1092,8 +1092,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (array_type.rank == 1 && f.is_internal_symbol ()) {
var len_type = int_type.copy ();
- var cdecl = new CCodeDeclaration (len_type.get_cname ());
- cdecl.add_declarator (new CCodeVariableDeclarator (get_array_size_cname (f.get_cname ()), new CCodeConstant ("0")));
+ var cdecl = new CCodeDeclaration (get_ccode_name (len_type));
+ cdecl.add_declarator (new CCodeVariableDeclarator (get_array_size_cname (get_ccode_name (f)), new CCodeConstant ("0")));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_type_member_declaration (cdecl);
}
@@ -1104,7 +1104,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
// create field to store delegate target
var target_def = new CCodeDeclaration ("gpointer");
- target_def.add_declarator (new CCodeVariableDeclarator (get_delegate_target_cname (f.get_cname ()), new CCodeConstant ("NULL")));
+ target_def.add_declarator (new CCodeVariableDeclarator (get_delegate_target_cname (get_ccode_name (f)), new CCodeConstant ("NULL")));
if (!f.is_private_symbol ()) {
target_def.modifiers = CCodeModifiers.EXTERN;
} else {
@@ -1114,7 +1114,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (delegate_type.value_owned) {
var target_destroy_notify_def = new CCodeDeclaration ("GDestroyNotify");
- target_destroy_notify_def.add_declarator (new CCodeVariableDeclarator (get_delegate_target_destroy_notify_cname (f.get_cname ()), new CCodeConstant ("NULL")));
+ target_destroy_notify_def.add_declarator (new CCodeVariableDeclarator (get_delegate_target_destroy_notify_cname (get_ccode_name (f)), new CCodeConstant ("NULL")));
if (!f.is_private_symbol ()) {
target_destroy_notify_def.modifiers = CCodeModifiers.EXTERN;
} else {
@@ -1135,7 +1135,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var temp_decl = get_temp_variable (f.variable_type);
var vardecl = new CCodeVariableDeclarator.zero (temp_decl.name, rhs);
- ccode.add_declaration (temp_decl.variable_type.get_cname (), vardecl);
+ ccode.add_declaration (get_ccode_name (temp_decl.variable_type), vardecl);
var tmp = get_variable_cexpression (get_variable_cname (temp_decl.name));
ccode.add_assignment (lhs, tmp);
@@ -1290,7 +1290,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
public void generate_property_accessor_declaration (PropertyAccessor acc, CCodeFile decl_space) {
- if (add_symbol_declaration (decl_space, acc, acc.get_cname ())) {
+ if (add_symbol_declaration (decl_space, acc, get_ccode_name (acc))) {
return;
}
@@ -1301,26 +1301,26 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
CCodeParameter cvalueparam;
if (returns_real_struct) {
- cvalueparam = new CCodeParameter ("result", acc.value_type.get_cname () + "*");
+ cvalueparam = new CCodeParameter ("result", get_ccode_name (acc.value_type) + "*");
} else if (!acc.readable && prop.property_type.is_real_non_null_struct_type ()) {
- cvalueparam = new CCodeParameter ("value", acc.value_type.get_cname () + "*");
+ cvalueparam = new CCodeParameter ("value", get_ccode_name (acc.value_type) + "*");
} else {
- cvalueparam = new CCodeParameter ("value", acc.value_type.get_cname ());
+ cvalueparam = new CCodeParameter ("value", get_ccode_name (acc.value_type));
}
generate_type_declaration (acc.value_type, decl_space);
CCodeFunction function;
if (acc.readable && !returns_real_struct) {
- function = new CCodeFunction (acc.get_cname (), acc.value_type.get_cname ());
+ function = new CCodeFunction (get_ccode_name (acc), get_ccode_name (acc.value_type));
} else {
- function = new CCodeFunction (acc.get_cname (), "void");
+ function = new CCodeFunction (get_ccode_name (acc), "void");
}
if (prop.binding == MemberBinding.INSTANCE) {
var t = (TypeSymbol) prop.parent_symbol;
var this_type = get_data_type_for_symbol (t);
generate_type_declaration (this_type, decl_space);
- var cselfparam = new CCodeParameter ("self", this_type.get_cname ());
+ var cselfparam = new CCodeParameter ("self", get_ccode_name (this_type));
if (t is Struct) {
cselfparam.type_name += "*";
}
@@ -1406,25 +1406,25 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
var this_type = get_data_type_for_symbol (t);
- var cselfparam = new CCodeParameter ("self", this_type.get_cname ());
+ var cselfparam = new CCodeParameter ("self", get_ccode_name (this_type));
if (t is Struct) {
cselfparam.type_name += "*";
}
CCodeParameter cvalueparam;
if (returns_real_struct) {
- cvalueparam = new CCodeParameter ("result", acc.value_type.get_cname () + "*");
+ cvalueparam = new CCodeParameter ("result", get_ccode_name (acc.value_type) + "*");
} else if (!acc.readable && prop.property_type.is_real_non_null_struct_type ()) {
- cvalueparam = new CCodeParameter ("value", acc.value_type.get_cname () + "*");
+ cvalueparam = new CCodeParameter ("value", get_ccode_name (acc.value_type) + "*");
} else {
- cvalueparam = new CCodeParameter ("value", acc.value_type.get_cname ());
+ cvalueparam = new CCodeParameter ("value", get_ccode_name (acc.value_type));
}
if (prop.is_abstract || prop.is_virtual) {
CCodeFunction function;
if (acc.readable && !returns_real_struct) {
- function = new CCodeFunction (acc.get_cname (), current_return_type.get_cname ());
+ function = new CCodeFunction (get_ccode_name (acc), get_ccode_name (current_return_type));
} else {
- function = new CCodeFunction (acc.get_cname (), "void");
+ function = new CCodeFunction (get_ccode_name (acc), "void");
}
function.add_parameter (cselfparam);
if (acc.writable || acc.construction || returns_real_struct) {
@@ -1526,14 +1526,14 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
cname = "%s_real_set_%s".printf (t.get_lower_case_cname (null), prop.name);
}
} else {
- cname = acc.get_cname ();
+ cname = get_ccode_name (acc);
}
CCodeFunction function;
if (acc.writable || acc.construction || returns_real_struct) {
function = new CCodeFunction (cname, "void");
} else {
- function = new CCodeFunction (cname, acc.value_type.get_cname ());
+ function = new CCodeFunction (cname, get_ccode_name (acc.value_type));
}
ObjectType base_type = null;
@@ -1545,7 +1545,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
base_type = new ObjectType ((ObjectTypeSymbol) prop.base_interface_property.parent_symbol);
}
function.modifiers |= CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("base", base_type.get_cname ()));
+ function.add_parameter (new CCodeParameter ("base", get_ccode_name (base_type)));
} else {
function.add_parameter (cselfparam);
}
@@ -1592,12 +1592,12 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (acc.readable && !returns_real_struct) {
// do not declare result variable if exit block is known to be unreachable
if (acc.return_block == null || acc.return_block.get_predecessors ().size > 0) {
- ccode.add_declaration (acc.value_type.get_cname (), new CCodeVariableDeclarator ("result"));
+ ccode.add_declaration (get_ccode_name (acc.value_type), new CCodeVariableDeclarator ("result"));
}
}
if (is_virtual) {
- ccode.add_declaration (this_type.get_cname (), new CCodeVariableDeclarator ("self"));
+ ccode.add_declaration (get_ccode_name (this_type), new CCodeVariableDeclarator ("self"));
ccode.add_assignment (new CCodeIdentifier ("self"), get_cvalue_ (transform_value (new GLibValue (base_type, new CCodeIdentifier ("base")), this_type, acc)));
}
@@ -1645,7 +1645,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var param_type = param.variable_type.copy ();
param_type.value_owned = true;
- data.add_field (param_type.get_cname (), get_variable_cname (param.name));
+ data.add_field (get_ccode_name (param_type), get_variable_cname (param.name));
bool is_unowned_delegate = param.variable_type is DelegateType && !param.variable_type.value_owned;
@@ -1702,7 +1702,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
} else {
if (in_constructor || (current_method != null && current_method.binding == MemberBinding.INSTANCE) ||
(current_property_accessor != null && current_property_accessor.prop.binding == MemberBinding.INSTANCE)) {
- data.add_field ("%s *".printf (current_type_symbol.get_cname ()), "self");
+ data.add_field ("%s *".printf (get_ccode_name (current_type_symbol)), "self");
}
if (current_method != null) {
@@ -1725,7 +1725,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (local.captured) {
generate_type_declaration (local.variable_type, cfile);
- data.add_field (local.variable_type.get_cname (), get_variable_cname (local.name) + local.variable_type.get_cdeclarator_suffix ());
+ data.add_field (get_ccode_name (local.variable_type), get_variable_cname (local.name) + local.variable_type.get_cdeclarator_suffix ());
if (local.variable_type is ArrayType) {
var array_type = (ArrayType) local.variable_type;
@@ -2025,7 +2025,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
bool has_simple_struct_initializer (LocalVariable local) {
var st = local.variable_type.data_type as Struct;
var initializer = local.initializer as ObjectCreationExpression;
- if (st != null && (!st.is_simple_type () || st.get_cname () == "va_list") && !local.variable_type.nullable &&
+ if (st != null && (!st.is_simple_type () || get_ccode_name (st) == "va_list") && !local.variable_type.nullable &&
local.variable_type.data_type != gvalue_type && initializer != null && initializer.get_object_initializer ().size == 0) {
return true;
} else {
@@ -2051,7 +2051,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (!local.captured) {
if (current_method != null && current_method.coroutine) {
- closure_struct.add_field (local.variable_type.get_cname (), get_variable_cname (local.name) + local.variable_type.get_cdeclarator_suffix ());
+ closure_struct.add_field (get_ccode_name (local.variable_type), get_variable_cname (local.name) + local.variable_type.get_cdeclarator_suffix ());
} else {
var cvar = new CCodeVariableDeclarator (get_variable_cname (local.name), null, local.variable_type.get_cdeclarator_suffix ());
@@ -2062,7 +2062,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
cvar.init0 = true;
}
- ccode.add_declaration (local.variable_type.get_cname (), cvar);
+ ccode.add_declaration (get_ccode_name (local.variable_type), cvar);
}
if (local.variable_type is ArrayType) {
@@ -2349,8 +2349,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 " + st.get_cname () + "*"));
- function.add_parameter (new CCodeParameter ("s2", "const " + st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("s1", "const " + get_ccode_name (st) + "*"));
+ function.add_parameter (new CCodeParameter ("s2", "const " + get_ccode_name (st) + "*"));
push_function (function);
@@ -2438,8 +2438,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 " + sym.get_cname () + "*"));
- function.add_parameter (new CCodeParameter ("s2", "const " + sym.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("s1", "const " + get_ccode_name (sym) + "*"));
+ function.add_parameter (new CCodeParameter ("s2", "const " + get_ccode_name (sym) + "*"));
push_function (function);
@@ -2484,10 +2484,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return dup_func;
}
- var function = new CCodeFunction (dup_func, value_type.get_cname ());
+ var function = new CCodeFunction (dup_func, get_ccode_name (value_type));
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", value_type.get_cname ()));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (value_type)));
push_function (function);
@@ -2498,10 +2498,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ccode.add_return (dup_call);
} else {
- ccode.add_declaration (value_type.get_cname (), new CCodeVariableDeclarator ("dup"));
+ ccode.add_declaration (get_ccode_name (value_type), new CCodeVariableDeclarator ("dup"));
var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("g_new0"));
- creation_call.add_argument (new CCodeConstant (value_type.data_type.get_cname ()));
+ creation_call.add_argument (new CCodeConstant (get_ccode_name (value_type.data_type)));
creation_call.add_argument (new CCodeConstant ("1"));
ccode.add_assignment (new CCodeIdentifier ("dup"), creation_call);
@@ -2519,7 +2519,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
cfile.add_include ("string.h");
var sizeof_call = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- sizeof_call.add_argument (new CCodeConstant (value_type.data_type.get_cname ()));
+ sizeof_call.add_argument (new CCodeConstant (get_ccode_name (value_type.data_type)));
var copy_call = new CCodeFunctionCall (new CCodeIdentifier ("memcpy"));
copy_call.add_argument (new CCodeIdentifier ("dup"));
@@ -2540,16 +2540,16 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
protected string generate_dup_func_wrapper (DataType type) {
- string destroy_func = "_vala_%s_copy".printf (type.data_type.get_cname ());
+ string destroy_func = "_vala_%s_copy".printf (get_ccode_name (type.data_type));
if (!add_wrapper (destroy_func)) {
// wrapper already defined
return destroy_func;
}
- var function = new CCodeFunction (destroy_func, type.get_cname ());
+ var function = new CCodeFunction (destroy_func, get_ccode_name (type));
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", type.get_cname ()));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (type)));
push_function (function);
@@ -2571,7 +2571,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
protected string generate_free_func_wrapper (DataType type) {
- string destroy_func = "_vala_%s_free".printf (type.data_type.get_cname ());
+ string destroy_func = "_vala_%s_free".printf (get_ccode_name (type.data_type));
if (!add_wrapper (destroy_func)) {
// wrapper already defined
@@ -2580,7 +2580,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var function = new CCodeFunction (destroy_func, "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", type.get_cname ()));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (type)));
push_function (function);
@@ -2748,7 +2748,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var function = new CCodeFunction (destroy_func, "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", collection_type.get_cname ()));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (collection_type)));
push_function (function);
@@ -2758,7 +2758,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
string destroy_node_func = "%s_node".printf (destroy_func);
var wrapper = new CCodeFunction (destroy_node_func, "gboolean");
wrapper.modifiers = CCodeModifiers.STATIC;
- wrapper.add_parameter (new CCodeParameter ("node", collection_type.get_cname ()));
+ wrapper.add_parameter (new CCodeParameter ("node", get_ccode_name (collection_type)));
wrapper.add_parameter (new CCodeParameter ("unused", "gpointer"));
push_function (wrapper);
@@ -3044,7 +3044,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
if (is_in_coroutine ()) {
- closure_struct.add_field (local.variable_type.get_cname (), local.name);
+ closure_struct.add_field (get_ccode_name (local.variable_type), local.name);
// even though closure struct is zerod, we need to initialize temporary variables
// as they might be used multiple times when declared in a loop
@@ -3055,13 +3055,13 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var memset_call = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
memset_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_variable_cexpression (local.name)));
memset_call.add_argument (new CCodeConstant ("0"));
- memset_call.add_argument (new CCodeIdentifier ("sizeof (%s)".printf (local.variable_type.get_cname ())));
+ memset_call.add_argument (new CCodeIdentifier ("sizeof (%s)".printf (get_ccode_name (local.variable_type))));
ccode.add_expression (memset_call);
} else if (vardecl.initializer != null) {
ccode.add_assignment (get_variable_cexpression (local.name), vardecl.initializer);
}
} else {
- ccode.add_declaration (local.variable_type.get_cname (), vardecl);
+ ccode.add_declaration (get_ccode_name (local.variable_type), vardecl);
}
}
@@ -3362,7 +3362,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public override void visit_lock_statement (LockStatement stmt) {
var l = get_lock_expression (stmt, stmt.resource);
- var fc = new CCodeFunctionCall (new CCodeIdentifier (((Method) mutex_type.scope.lookup ("lock")).get_cname ()));
+ var fc = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (mutex_type.scope.lookup ("lock"))));
fc.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, l));
ccode.add_expression (fc);
@@ -3371,7 +3371,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public override void visit_unlock_statement (UnlockStatement stmt) {
var l = get_lock_expression (stmt, stmt.resource);
- var fc = new CCodeFunctionCall (new CCodeIdentifier (((Method) mutex_type.scope.lookup ("unlock")).get_cname ()));
+ var fc = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (mutex_type.scope.lookup ("unlock"))));
fc.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, l));
ccode.add_expression (fc);
@@ -3394,7 +3394,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (expr.formal_value_type is GenericType && !(expr.value_type is GenericType)) {
var st = expr.formal_value_type.type_parameter.parent_symbol.parent_symbol as Struct;
if (expr.formal_value_type.type_parameter.parent_symbol != garray_type &&
- (st == null || st.get_cname () != "va_list")) {
+ (st == null || get_ccode_name (st) != "va_list")) {
// GArray and va_list don't use pointer-based generics
set_cvalue (expr, convert_from_generic_pointer (get_cvalue (expr), expr.value_type));
}
@@ -3465,7 +3465,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
// translated string constant
var m = (Method) root_symbol.scope.lookup ("GLib").scope.lookup ("_");
- add_symbol_declaration (cfile, m, m.get_cname ());
+ add_symbol_declaration (cfile, m, get_ccode_name (m));
var translate = new CCodeFunctionCall (new CCodeIdentifier ("_"));
translate.add_argument (get_cvalue (expr));
@@ -4007,7 +4007,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
public virtual void generate_class_declaration (Class cl, CCodeFile decl_space) {
- if (add_symbol_declaration (decl_space, cl, cl.get_cname ())) {
+ if (add_symbol_declaration (decl_space, cl, get_ccode_name (cl))) {
return;
}
}
@@ -4049,7 +4049,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
check_type (expr.type_reference);
var st = expr.type_reference.data_type as Struct;
- if ((st != null && (!st.is_simple_type () || st.get_cname () == "va_list")) || expr.get_object_initializer ().size > 0) {
+ if ((st != null && (!st.is_simple_type () || get_ccode_name (st) == "va_list")) || expr.get_object_initializer ().size > 0) {
// value-type initialization or object creation expression with object initializer
var local = expr.parent_node as LocalVariable;
@@ -4071,7 +4071,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
creation_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, instance));
creation_call.add_argument (new CCodeConstant ("0"));
- creation_call.add_argument (new CCodeIdentifier ("sizeof (%s)".printf (expr.type_reference.get_cname ())));
+ creation_call.add_argument (new CCodeIdentifier ("sizeof (%s)".printf (get_ccode_name (expr.type_reference))));
creation_expr = creation_call;
}
@@ -4094,14 +4094,14 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
creation_call = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname ()));
creation_call.add_argument (new CCodeIdentifier (cl.get_type_id ()));
} else {
- creation_call = new CCodeFunctionCall (new CCodeIdentifier (m.get_cname ()));
+ creation_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (m)));
}
if ((st != null && !st.is_simple_type ()) && !(m.cinstance_parameter_position < 0)) {
creation_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, instance));
- } else if (st != null && st.get_cname () == "va_list") {
+ } else if (st != null && get_ccode_name (st) == "va_list") {
creation_call.add_argument (instance);
- if (m.get_cname () == "va_start") {
+ if (get_ccode_name (m) == "va_start") {
Parameter last_param = null;
foreach (var param in current_method.get_parameters ()) {
if (param.ellipsis) {
@@ -4146,7 +4146,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
// g_array_new: element size
if (cl == garray_type && param.name == "element_size") {
var csizeof = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- csizeof.add_argument (new CCodeIdentifier (expr.type_reference.get_type_arguments ().get (0).get_cname ()));
+ csizeof.add_argument (new CCodeIdentifier (get_ccode_name (expr.type_reference.get_type_arguments ().get (0))));
cexpr = csizeof;
}
@@ -4251,7 +4251,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
// cast the return value of the creation method back to the intended type if
// it requested a special C return type
if (get_custom_creturn_type (m) != null) {
- creation_expr = new CCodeCastExpression (creation_expr, expr.type_reference.get_cname ());
+ creation_expr = new CCodeCastExpression (creation_expr, get_ccode_name (expr.type_reference));
}
} else if (expr.symbol_reference is ErrorCode) {
var ecode = (ErrorCode) expr.symbol_reference;
@@ -4267,7 +4267,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
creation_call = new CCodeFunctionCall (new CCodeIdentifier ("g_error_new"));
}
creation_call.add_argument (new CCodeIdentifier (edomain.get_upper_case_cname ()));
- creation_call.add_argument (new CCodeIdentifier (ecode.get_cname ()));
+ creation_call.add_argument (new CCodeIdentifier (get_ccode_name (ecode)));
foreach (Expression arg in expr.get_argument_list ()) {
creation_call.add_argument (get_cvalue (arg));
@@ -4362,7 +4362,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
generate_type_declaration (expr.type_reference, cfile);
var csizeof = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- csizeof.add_argument (new CCodeIdentifier (expr.type_reference.get_cname ()));
+ csizeof.add_argument (new CCodeIdentifier (get_ccode_name (expr.type_reference)));
set_cvalue (expr, csizeof);
}
@@ -4440,7 +4440,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
emit_temp_var (temp_decl);
var ctemp = get_variable_cexpression (temp_decl.name);
- rv = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeCastExpression (rv, (new PointerType(to)).get_cname ()));
+ rv = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeCastExpression (rv, get_ccode_name (new PointerType (to))));
var holds = new CCodeFunctionCall (new CCodeIdentifier ("G_VALUE_HOLDS"));
holds.add_argument (gvalue);
holds.add_argument (new CCodeIdentifier (to.get_type_id ()));
@@ -4473,12 +4473,12 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
cfunc.add_parameter (new CCodeParameter ("value", "GVariant*"));
if (!to.is_real_non_null_struct_type ()) {
- cfunc.return_type = to.get_cname ();
+ cfunc.return_type = get_ccode_name (to);
}
if (to.is_real_non_null_struct_type ()) {
// structs are returned via out parameter
- cfunc.add_parameter (new CCodeParameter ("result", to.get_cname () + "*"));
+ cfunc.add_parameter (new CCodeParameter ("result", get_ccode_name (to) + "*"));
} else if (to is ArrayType) {
// return array length if appropriate
var array_type = (ArrayType) to;
@@ -4540,7 +4540,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ccode.add_assignment (ctemp, get_cvalue (expr.inner));
var ccheck = create_type_check (ctemp, expr.type_reference);
- var ccast = new CCodeCastExpression (ctemp, expr.type_reference.get_cname ());
+ var ccast = new CCodeCastExpression (ctemp, get_ccode_name (expr.type_reference));
var cnull = new CCodeConstant ("NULL");
set_cvalue (expr, new CCodeConditionalExpression (ccheck, ccast, cnull));
@@ -4574,7 +4574,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
// nullable integer or float or boolean or struct cast to non-nullable
innercexpr = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, innercexpr);
}
- set_cvalue (expr, new CCodeCastExpression (innercexpr, expr.type_reference.get_cname ()));
+ set_cvalue (expr, new CCodeCastExpression (innercexpr, get_ccode_name (expr.type_reference)));
if (expr.type_reference is DelegateType) {
if (get_delegate_target (expr.inner) != null) {
@@ -4882,7 +4882,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var matches_call = new CCodeFunctionCall (new CCodeIdentifier ("g_error_matches"));
matches_call.add_argument ((CCodeExpression) ccodenode);
matches_call.add_argument (new CCodeIdentifier (et.error_domain.get_upper_case_cname ()));
- matches_call.add_argument (new CCodeIdentifier (et.error_code.get_cname ()));
+ matches_call.add_argument (new CCodeIdentifier (get_ccode_name (et.error_code)));
return matches_call;
} else if (et != null && et.error_domain != null) {
var instance_domain = new CCodeMemberAccess.pointer ((CCodeExpression) ccodenode, "domain");
@@ -4909,12 +4909,12 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var function = new CCodeFunction (array_contains_func, "gboolean");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("stack", array_type.get_cname ()));
+ function.add_parameter (new CCodeParameter ("stack", get_ccode_name (array_type)));
function.add_parameter (new CCodeParameter ("stack_length", "int"));
if (array_type.element_type is StructValueType) {
- function.add_parameter (new CCodeParameter ("needle", array_type.element_type.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("needle", get_ccode_name (array_type.element_type) + "*"));
} else {
- function.add_parameter (new CCodeParameter ("needle", array_type.element_type.get_cname ()));
+ function.add_parameter (new CCodeParameter ("needle", get_ccode_name (array_type.element_type)));
}
push_function (function);
@@ -4978,7 +4978,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
bool expr_owned = lambda.value_type.value_owned;
- set_cvalue (lambda, new CCodeIdentifier (lambda.method.get_cname ()));
+ set_cvalue (lambda, new CCodeIdentifier (get_ccode_name (lambda.method)));
var delegate_type = (DelegateType) lambda.target_type;
if (lambda.method.closure) {
@@ -5021,7 +5021,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public CCodeExpression convert_from_generic_pointer (CCodeExpression cexpr, DataType actual_type) {
var result = cexpr;
if (is_reference_type_argument (actual_type) || is_nullable_value_type_argument (actual_type)) {
- result = new CCodeCastExpression (cexpr, actual_type.get_cname ());
+ result = new CCodeCastExpression (cexpr, get_ccode_name (actual_type));
} else if (is_signed_integer_type_argument (actual_type)) {
var cconv = new CCodeFunctionCall (new CCodeIdentifier ("GPOINTER_TO_INT"));
cconv.add_argument (cexpr);
@@ -5181,7 +5181,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var cfunc = new CCodeFunction (variant_func, "GVariant*");
cfunc.modifiers = CCodeModifiers.STATIC;
- cfunc.add_parameter (new CCodeParameter ("value", type.get_cname ()));
+ cfunc.add_parameter (new CCodeParameter ("value", get_ccode_name (type)));
if (type is ArrayType) {
// return array length if appropriate
@@ -5273,11 +5273,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (context.checking && (iface != null || (cl != null && !cl.is_compact))) {
// checked cast for strict subtypes of GTypeInstance
return generate_instance_cast (cexpr, target_type.data_type);
- } else if (target_type.data_type != null && expression_type.get_cname () != target_type.get_cname ()) {
+ } else if (target_type.data_type != null && get_ccode_name (expression_type) != get_ccode_name (target_type)) {
var st = target_type.data_type as Struct;
if (target_type.data_type.is_reference_type () || (st != null && st.is_simple_type ())) {
// don't cast non-simple structs
- return new CCodeCastExpression (cexpr, target_type.get_cname ());
+ return new CCodeCastExpression (cexpr, get_ccode_name (target_type));
} else {
return cexpr;
}
@@ -5325,7 +5325,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
set_func = get_dynamic_property_setter_cname ((DynamicProperty) prop);
} else {
generate_property_accessor_declaration (base_property.set_accessor, cfile);
- set_func = base_property.set_accessor.get_cname ();
+ set_func = get_ccode_name (base_property.set_accessor);
if (!prop.external && prop.external_package) {
// internal VAPI properties
@@ -5614,7 +5614,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var function = new CCodeFunction (st.get_destroy_function (), "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (st) + "*"));
push_context (new EmitContext ());
push_function (function);
@@ -5643,8 +5643,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var function = new CCodeFunction (st.get_copy_function (), "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", "const " + st.get_cname () + "*"));
- function.add_parameter (new CCodeParameter ("dest", st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", "const " + get_ccode_name (st) + "*"));
+ function.add_parameter (new CCodeParameter ("dest", get_ccode_name (st) + "*"));
push_context (new EmitContext ());
push_function (function);
@@ -5918,9 +5918,28 @@ public class Vala.CCodeAttribute : AttributeCache {
public string const_name {
get {
if (_const_name == null) {
- _const_name = CCodeBaseModule.get_ccode_name (node);
- if (node is Class && ((Class) node).is_immutable) {
- _const_name = "const %s".printf (_const_name);
+ if (node is DataType) {
+ var type = (DataType) node;
+ string ptr;
+ TypeSymbol t;
+ // FIXME: workaround to make constant arrays possible
+ if (type is ArrayType) {
+ t = ((ArrayType) type).element_type.data_type;
+ } else {
+ t = type.data_type;
+ }
+ if (!t.is_reference_type ()) {
+ ptr = "";
+ } else {
+ ptr = "*";
+ }
+
+ _const_name = "const %s%s".printf (CCodeBaseModule.get_ccode_name (t), ptr);
+ } else {
+ _const_name = CCodeBaseModule.get_ccode_name (node);
+ if (node is Class && ((Class) node).is_immutable) {
+ _const_name = "const %s".printf (_const_name);
+ }
}
}
return _const_name;
diff --git a/codegen/valaccodecontrolflowmodule.vala b/codegen/valaccodecontrolflowmodule.vala
index 46c8ed1..8bfdd55 100644
--- a/codegen/valaccodecontrolflowmodule.vala
+++ b/codegen/valaccodecontrolflowmodule.vala
@@ -73,7 +73,7 @@ public abstract class Vala.CCodeControlFlowModule : CCodeMethodModule {
if (is_constant_ccode_expression (cexpr)) {
var cname = "%s_label%d".printf (temp_var.name, label_count++);
- ccode.add_declaration (gquark_type.get_cname (), new CCodeVariableDeclarator (cname, czero), CCodeModifiers.STATIC);
+ ccode.add_declaration (get_ccode_name (gquark_type), new CCodeVariableDeclarator (cname, czero), CCodeModifiers.STATIC);
}
}
}
diff --git a/codegen/valaccodedelegatemodule.vala b/codegen/valaccodedelegatemodule.vala
index bb38b85..3b25684 100644
--- a/codegen/valaccodedelegatemodule.vala
+++ b/codegen/valaccodedelegatemodule.vala
@@ -28,25 +28,25 @@
*/
public class Vala.CCodeDelegateModule : CCodeArrayModule {
public override void generate_delegate_declaration (Delegate d, CCodeFile decl_space) {
- if (add_symbol_declaration (decl_space, d, d.get_cname ())) {
+ if (add_symbol_declaration (decl_space, d, get_ccode_name (d))) {
return;
}
- string return_type_cname = d.return_type.get_cname ();
+ string return_type_cname = get_ccode_name (d.return_type);
if (d.return_type.is_real_non_null_struct_type ()) {
// structs are returned via out parameter
return_type_cname = "void";
}
- if (return_type_cname == d.get_cname ()) {
+ if (return_type_cname == get_ccode_name (d)) {
// recursive delegate
return_type_cname = "GCallback";
} else {
generate_type_declaration (d.return_type, decl_space);
}
- var cfundecl = new CCodeFunctionDeclarator (d.get_cname ());
+ var cfundecl = new CCodeFunctionDeclarator (get_ccode_name (d));
foreach (Parameter param in d.get_parameters ()) {
var cparam = generate_parameter (param, decl_space, new HashMap<int,CCodeParameter> (), null);
@@ -103,7 +103,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
}
}
} else if (d.return_type.is_real_non_null_struct_type ()) {
- var cparam = new CCodeParameter ("result", "%s*".printf (d.return_type.get_cname ()));
+ var cparam = new CCodeParameter ("result", "%s*".printf (get_ccode_name (d.return_type)));
cfundecl.add_parameter (cparam);
}
if (d.has_target) {
@@ -181,12 +181,12 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
if (dynamic_sig != null) {
delegate_name = get_dynamic_signal_cname (dynamic_sig);
} else if (sig != null) {
- delegate_name = sig.parent_symbol.get_lower_case_cprefix () + sig.get_cname ();
+ delegate_name = sig.parent_symbol.get_lower_case_cprefix () + get_ccode_name (sig);
} else {
- delegate_name = Symbol.camel_case_to_lower_case (d.get_cname ());
+ delegate_name = Symbol.camel_case_to_lower_case (get_ccode_name (d));
}
- string wrapper_name = "_%s_%s".printf (m.get_cname (), delegate_name);
+ string wrapper_name = "_%s_%s".printf (get_ccode_name (m), delegate_name);
if (!add_wrapper (wrapper_name)) {
// wrapper already defined
@@ -195,7 +195,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
// declaration
- string return_type_cname = d.return_type.get_cname ();
+ string return_type_cname = get_ccode_name (d.return_type);
if (d.return_type.is_real_non_null_struct_type ()) {
// structs are returned via out parameter
@@ -254,7 +254,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
}
}
} else if (d.return_type.is_real_non_null_struct_type ()) {
- var cparam = new CCodeParameter ("result", "%s*".printf (d.return_type.get_cname ()));
+ var cparam = new CCodeParameter ("result", "%s*".printf (get_ccode_name (d.return_type)));
cparam_map.set (get_param_pos (-3), cparam);
}
@@ -380,7 +380,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
carg_map.set (get_param_pos (-1), new CCodeIdentifier ("error"));
}
- var ccall = new CCodeFunctionCall (new CCodeIdentifier (m.get_cname ()));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (m)));
// append C arguments in the right order
last_pos = -1;
@@ -445,12 +445,12 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
return base.generate_parameter (param, decl_space, cparam_map, carg_map);
}
- string ctypename = param.variable_type.get_cname ();
+ string ctypename = get_ccode_name (param.variable_type);
string target_ctypename = "void*";
string target_destroy_notify_ctypename = "GDestroyNotify";
if (param.parent_symbol is Delegate
- && param.variable_type.get_cname () == ((Delegate) param.parent_symbol).get_cname ()) {
+ && get_ccode_name (param.variable_type) == get_ccode_name (param.parent_symbol)) {
// recursive delegate
ctypename = "GCallback";
}
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 4387a32..03faf35 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -82,14 +82,14 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
vclass.add_argument (inst);
set_cvalue (expr, new CCodeMemberAccess.pointer (vclass, m.name));
} else {
- set_cvalue (expr, new CCodeIdentifier (m.base_method.get_cname ()));
+ set_cvalue (expr, new CCodeIdentifier (get_ccode_name (m.base_method)));
}
} else if (m.base_interface_method != null) {
- set_cvalue (expr, new CCodeIdentifier (m.base_interface_method.get_cname ()));
+ set_cvalue (expr, new CCodeIdentifier (get_ccode_name (m.base_interface_method)));
} else if (m is CreationMethod) {
set_cvalue (expr, new CCodeIdentifier (m.get_real_cname ()));
} else {
- set_cvalue (expr, new CCodeIdentifier (m.get_cname ()));
+ set_cvalue (expr, new CCodeIdentifier (get_ccode_name (m)));
}
set_delegate_target_destroy_notify (expr, new CCodeConstant ("NULL"));
@@ -131,7 +131,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
generate_enum_declaration ((Enum) ev.parent_symbol, cfile);
- set_cvalue (expr, new CCodeConstant (ev.get_cname ()));
+ set_cvalue (expr, new CCodeConstant (get_ccode_name (ev)));
} else if (expr.symbol_reference is Constant) {
var c = (Constant) expr.symbol_reference;
@@ -153,12 +153,12 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
}
set_cvalue (expr, new CCodeConstant ("\"%s\"".printf (s)));
} else {
- set_cvalue (expr, new CCodeIdentifier (c.get_cname ()));
+ set_cvalue (expr, new CCodeIdentifier (get_ccode_name (c)));
}
if (array_type != null) {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("G_N_ELEMENTS"));
- ccall.add_argument (new CCodeIdentifier (c.get_cname ()));
+ ccall.add_argument (new CCodeIdentifier (get_ccode_name (c)));
append_array_length (expr, ccall);
}
} else if (expr.symbol_reference is Property) {
@@ -206,7 +206,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
!(prop.property_type is ArrayType || prop.property_type is DelegateType)) {
CCodeExpression inst;
inst = new CCodeMemberAccess.pointer (pub_inst, "priv");
- set_cvalue (expr, new CCodeMemberAccess.pointer (inst, prop.field.get_cname()));
+ set_cvalue (expr, new CCodeMemberAccess.pointer (inst, get_ccode_name (prop.field)));
} else if (!prop.no_accessor_method) {
var base_property = prop;
if (prop.base_property != null) {
@@ -218,7 +218,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
if (prop is DynamicProperty) {
getter_cname = get_dynamic_property_getter_cname ((DynamicProperty) prop);
} else {
- getter_cname = base_property.get_accessor.get_cname ();
+ getter_cname = get_ccode_name (base_property.get_accessor);
}
var ccall = new CCodeFunctionCall (new CCodeIdentifier (getter_cname));
@@ -548,9 +548,9 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
inst = pub_inst;
}
if (instance_target_type.data_type.is_reference_type () || (instance != null && instance.value_type is PointerType)) {
- result.cvalue = new CCodeMemberAccess.pointer (inst, field.get_cname ());
+ result.cvalue = new CCodeMemberAccess.pointer (inst, get_ccode_name (field));
} else {
- result.cvalue = new CCodeMemberAccess (inst, field.get_cname ());
+ result.cvalue = new CCodeMemberAccess (inst, get_ccode_name (field));
}
if (array_type != null && !field.no_array_length) {
@@ -582,8 +582,8 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
}
}
} else if (delegate_type != null && delegate_type.delegate_symbol.has_target && !field.no_delegate_target) {
- string target_cname = get_delegate_target_cname (field.get_cname ());
- string target_destroy_notify_cname = get_delegate_target_destroy_notify_cname (field.get_cname ());
+ string target_cname = get_delegate_target_cname (get_ccode_name (field));
+ string target_destroy_notify_cname = get_delegate_target_destroy_notify_cname (get_ccode_name (field));
if (((TypeSymbol) field.parent_symbol).is_reference_type ()) {
result.delegate_target_cvalue = new CCodeMemberAccess.pointer (inst, target_cname);
@@ -623,15 +623,15 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
if (field.access == SymbolAccessibility.PRIVATE) {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf (cl.get_upper_case_cname ())));
ccall.add_argument (klass);
- result.cvalue = new CCodeMemberAccess.pointer (ccall, field.get_cname ());
+ result.cvalue = new CCodeMemberAccess.pointer (ccall, get_ccode_name (field));
} else {
- result.cvalue = new CCodeMemberAccess.pointer (cast, field.get_cname ());
+ result.cvalue = new CCodeMemberAccess.pointer (cast, get_ccode_name (field));
}
} else {
generate_field_declaration (field, cfile);
- result.cvalue = new CCodeIdentifier (field.get_cname ());
+ result.cvalue = new CCodeIdentifier (get_ccode_name (field));
if (array_type != null && !field.no_array_length) {
for (int dim = 1; dim <= array_type.rank; dim++) {
@@ -639,18 +639,18 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
if (field.has_array_length_cname) {
length_cname = field.get_array_length_cname ();
} else {
- length_cname = get_array_length_cname (field.get_cname (), dim);
+ length_cname = get_array_length_cname (get_ccode_name (field), dim);
}
result.append_array_length_cvalue (new CCodeIdentifier (length_cname));
}
if (array_type.rank == 1 && field.is_internal_symbol ()) {
- set_array_size_cvalue (result, new CCodeIdentifier (get_array_size_cname (field.get_cname ())));
+ set_array_size_cvalue (result, new CCodeIdentifier (get_array_size_cname (get_ccode_name (field))));
}
} else if (delegate_type != null && delegate_type.delegate_symbol.has_target && !field.no_delegate_target) {
- result.delegate_target_cvalue = new CCodeIdentifier (get_delegate_target_cname (field.get_cname ()));
+ result.delegate_target_cvalue = new CCodeIdentifier (get_delegate_target_cname (get_ccode_name (field)));
if (result.value_type.value_owned) {
- result.delegate_target_destroy_notify_cvalue = new CCodeIdentifier (get_delegate_target_destroy_notify_cname (field.get_cname ()));
+ result.delegate_target_destroy_notify_cvalue = new CCodeIdentifier (get_delegate_target_destroy_notify_cname (get_ccode_name (field)));
}
}
}
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 4f8ce16..9f5e985 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -77,7 +77,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
if (m != null && m.coroutine) {
// async call
- async_call = new CCodeFunctionCall (new CCodeIdentifier (m.get_cname ()));
+ async_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (m)));
var finish_call = new CCodeFunctionCall (new CCodeIdentifier (m.get_finish_cname ()));
if (ma.inner is BaseAccess) {
@@ -161,7 +161,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
if (m is ArrayResizeMethod) {
var array_type = (ArrayType) ma.inner.value_type;
- in_arg_map.set (get_param_pos (0), new CCodeIdentifier (array_type.element_type.get_cname ()));
+ in_arg_map.set (get_param_pos (0), new CCodeIdentifier (get_ccode_name (array_type.element_type)));
} else if (m is ArrayMoveMethod) {
requires_array_move = true;
}
@@ -238,14 +238,14 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
// generic method
int type_param_index = 0;
foreach (var type_arg in ma.get_type_arguments ()) {
- in_arg_map.set (get_param_pos (m.generic_type_parameter_position + 0.01 * type_param_index), new CCodeIdentifier (type_arg.get_cname ()));
+ in_arg_map.set (get_param_pos (m.generic_type_parameter_position + 0.01 * type_param_index), new CCodeIdentifier (get_ccode_name (type_arg)));
type_param_index++;
}
} else {
// method in generic type
int type_param_index = 0;
foreach (var type_arg in ma.inner.value_type.get_type_arguments ()) {
- in_arg_map.set (get_param_pos (m.generic_type_parameter_position + 0.01 * type_param_index), new CCodeIdentifier (type_arg.get_cname ()));
+ in_arg_map.set (get_param_pos (m.generic_type_parameter_position + 0.01 * type_param_index), new CCodeIdentifier (get_ccode_name (type_arg)));
type_param_index++;
}
}
@@ -254,7 +254,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
if (m is ArrayMoveMethod) {
var array_type = (ArrayType) ma.inner.value_type;
var csizeof = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- csizeof.add_argument (new CCodeIdentifier (array_type.element_type.get_cname ()));
+ csizeof.add_argument (new CCodeIdentifier (get_ccode_name (array_type.element_type)));
in_arg_map.set (get_param_pos (0.1), csizeof);
} else if (m is DynamicMethod) {
m.clear_parameters ();
@@ -282,7 +282,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
}
generate_dynamic_method_wrapper ((DynamicMethod) m);
} else if (m is CreationMethod && context.profile == Profile.GOBJECT && m.parent_symbol is Class) {
- ccode.add_assignment (new CCodeIdentifier ("self"), new CCodeCastExpression (ccall, current_class.get_cname () + "*"));
+ ccode.add_assignment (new CCodeIdentifier ("self"), new CCodeCastExpression (ccall, CCodeBaseModule.get_ccode_name (current_class) + "*"));
if (current_method.body.captured) {
// capture self after setting it
@@ -708,7 +708,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
var clen = get_array_length_cexpression (ma.inner, 1);
var celems = get_cvalue (ma.inner);
var array_type = (ArrayType) ma.inner.value_type;
- var csizeof = new CCodeIdentifier ("sizeof (%s)".printf (array_type.element_type.get_cname ()));
+ var csizeof = new CCodeIdentifier ("sizeof (%s)".printf (get_ccode_name (array_type.element_type)));
var cdelta = new CCodeBinaryExpression (CCodeBinaryOperator.MINUS, temp_ref, clen);
var ccheck = new CCodeBinaryExpression (CCodeBinaryOperator.GREATER_THAN, temp_ref, clen);
@@ -742,7 +742,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
if (expr.formal_value_type is GenericType && !(expr.value_type is GenericType)) {
var st = expr.formal_value_type.type_parameter.parent_symbol.parent_symbol as Struct;
if (expr.formal_value_type.type_parameter.parent_symbol == garray_type ||
- (st != null && st.get_cname () == "va_list")) {
+ (st != null && get_ccode_name (st) == "va_list")) {
// GArray and va_list don't use pointer-based generics
// above logic copied from visit_expression ()
// TODO avoid code duplication
@@ -796,7 +796,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
var function = new CCodeFunction (to_string_func, "const char*");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("value", en.get_cname ()));
+ function.add_parameter (new CCodeParameter ("value", get_ccode_name (en)));
// definition
push_context (new EmitContext ());
@@ -804,8 +804,8 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
ccode.open_switch (new CCodeConstant ("value"));
foreach (var enum_value in en.get_values ()) {
- ccode.add_case (new CCodeIdentifier (enum_value.get_cname ()));
- ccode.add_return (new CCodeConstant ("\""+enum_value.get_cname ()+"\""));
+ ccode.add_case (new CCodeIdentifier (get_ccode_name (enum_value)));
+ ccode.add_return (new CCodeConstant ("\""+get_ccode_name (enum_value)+"\""));
}
ccode.close ();
ccode.add_return (new CCodeConstant ("NULL"));
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index e2f0985..1beb3d5 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -67,13 +67,13 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
// structs are returned via out parameter
creturn_type = new VoidType ();
}
- cfunc.return_type = get_creturn_type (m, creturn_type.get_cname ());
+ cfunc.return_type = get_creturn_type (m, get_ccode_name (creturn_type));
generate_type_declaration (m.return_type, decl_space);
if (m.return_type.is_real_non_null_struct_type ()) {
// structs are returned via out parameter
- var cparam = new CCodeParameter ("result", m.return_type.get_cname () + "*");
+ var cparam = new CCodeParameter ("result", get_ccode_name (m.return_type) + "*");
cparam_map.set (get_param_pos (-3), cparam);
if (carg_map != null) {
carg_map.set (get_param_pos (-3), get_result_cexpression ());
@@ -155,11 +155,11 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
if (m.is_async_callback) {
return;
}
- if (add_symbol_declaration (decl_space, m, m.get_cname ())) {
+ if (add_symbol_declaration (decl_space, m, get_ccode_name (m))) {
return;
}
- var function = new CCodeFunction (m.get_cname ());
+ var function = new CCodeFunction (get_ccode_name (m));
if (m.is_private_symbol () && !m.external) {
function.modifiers |= CCodeModifiers.STATIC;
@@ -331,7 +331,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
function = new CCodeFunction (m.get_real_cname () + "_co", "gboolean");
// data struct to hold parameters, local variables, and the return value
- function.add_parameter (new CCodeParameter ("data", Symbol.lower_case_to_camel_case (m.get_cname ()) + "Data*"));
+ function.add_parameter (new CCodeParameter ("data", Symbol.lower_case_to_camel_case (get_ccode_name (m)) + "Data*"));
function.modifiers |= CCodeModifiers.STATIC;
cfile.add_function_declaration (function);
@@ -396,7 +396,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
// as closures have block data parameter
if (m.binding == MemberBinding.INSTANCE) {
var cself = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data%d_".printf (block_id)), "self");
- ccode.add_declaration ("%s *".printf (current_type_symbol.get_cname ()), new CCodeVariableDeclarator ("self"));
+ ccode.add_declaration ("%s *".printf (get_ccode_name (current_type_symbol)), new CCodeVariableDeclarator ("self"));
ccode.add_assignment (new CCodeIdentifier ("self"), cself);
}
@@ -431,7 +431,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
var self_target_type = new ObjectType (cl);
CCodeExpression cself = get_cvalue_ (transform_value (new GLibValue (base_expression_type, new CCodeIdentifier ("base")), self_target_type, m));
- ccode.add_declaration ("%s *".printf (cl.get_cname ()), new CCodeVariableDeclarator ("self"));
+ ccode.add_declaration ("%s *".printf (get_ccode_name (cl)), new CCodeVariableDeclarator ("self"));
ccode.add_assignment (new CCodeIdentifier ("self"), cself);
} else if (m.binding == MemberBinding.INSTANCE
&& !(m is CreationMethod)) {
@@ -452,7 +452,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 ("_" + param.name), default_value_for_type (param.variable_type, true));
- ccode.add_declaration (param.variable_type.get_cname (), vardecl);
+ ccode.add_declaration (get_ccode_name (param.variable_type), vardecl);
if (param.variable_type is ArrayType) {
// create variables to store array dimensions
@@ -484,20 +484,20 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
if (!(m.return_type is VoidType) && !m.return_type.is_real_non_null_struct_type () && !m.coroutine) {
var vardecl = new CCodeVariableDeclarator ("result", default_value_for_type (m.return_type, true));
vardecl.init0 = true;
- ccode.add_declaration (m.return_type.get_cname (), vardecl);
+ ccode.add_declaration (get_ccode_name (m.return_type), vardecl);
}
if (m is CreationMethod) {
if (in_gobject_creation_method) {
- ccode.add_declaration ("%s *".printf (((Class) current_type_symbol).get_cname ()), new CCodeVariableDeclarator.zero ("self", new CCodeConstant ("NULL")));
+ ccode.add_declaration ("%s *".printf (get_ccode_name (current_type_symbol)), new CCodeVariableDeclarator.zero ("self", new CCodeConstant ("NULL")));
} else if (is_gtypeinstance_creation_method (m)) {
var cl = (Class) m.parent_symbol;
- ccode.add_declaration (cl.get_cname () + "*", new CCodeVariableDeclarator.zero ("self", new CCodeConstant ("NULL")));
+ ccode.add_declaration (get_ccode_name (cl) + "*", new CCodeVariableDeclarator.zero ("self", new CCodeConstant ("NULL")));
if (cl.is_fundamental ()) {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_create_instance"));
ccall.add_argument (new CCodeIdentifier ("object_type"));
- ccode.add_assignment (new CCodeIdentifier ("self"), new CCodeCastExpression (ccall, cl.get_cname () + "*"));
+ ccode.add_assignment (new CCodeIdentifier ("self"), new CCodeCastExpression (ccall, get_ccode_name (cl) + "*"));
/* type, dup func, and destroy func fields for generic types */
foreach (TypeParameter type_param in current_class.get_type_parameters ()) {
@@ -521,12 +521,12 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
}
} else if (current_type_symbol is Class) {
var cl = (Class) m.parent_symbol;
- ccode.add_declaration (cl.get_cname () + "*", new CCodeVariableDeclarator ("self"));
+ ccode.add_declaration (get_ccode_name (cl) + "*", new CCodeVariableDeclarator ("self"));
if (!((CreationMethod) m).chain_up) {
// TODO implicitly chain up to base class as in add_object_creation
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_slice_new0"));
- ccall.add_argument (new CCodeIdentifier (cl.get_cname ()));
+ ccall.add_argument (new CCodeIdentifier (get_ccode_name (cl)));
ccode.add_assignment (new CCodeIdentifier ("self"), ccall);
}
@@ -544,7 +544,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
var czero = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
czero.add_argument (new CCodeIdentifier ("self"));
czero.add_argument (new CCodeConstant ("0"));
- czero.add_argument (new CCodeIdentifier ("sizeof (%s)".printf (st.get_cname ())));
+ czero.add_argument (new CCodeIdentifier ("sizeof (%s)".printf (get_ccode_name (st))));
ccode.add_expression (czero);
}
}
@@ -648,7 +648,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
var type_name_call = new CCodeFunctionCall (new CCodeIdentifier ("g_type_name"));
type_name_call.add_argument (type_from_instance_call);
- var error_string = "\"Type `%%s' does not implement abstract method `%s'\"".printf (m.get_cname ());
+ var error_string = "\"Type `%%s' does not implement abstract method `%s'\"".printf (get_ccode_name (m));
var cerrorcall = new CCodeFunctionCall (new CCodeIdentifier ("g_critical"));
cerrorcall.add_argument (new CCodeConstant (error_string));
@@ -725,7 +725,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
public virtual CCodeParameter generate_parameter (Parameter param, CCodeFile decl_space, Map<int,CCodeParameter> cparam_map, Map<int,CCodeExpression>? carg_map) {
CCodeParameter cparam;
if (!param.ellipsis) {
- string ctypename = param.variable_type.get_cname ();
+ string ctypename = get_ccode_name (param.variable_type);
generate_type_declaration (param.variable_type, decl_space);
@@ -791,15 +791,15 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
CCodeParameter instance_param = null;
if (m.base_interface_method != null && !m.is_abstract && !m.is_virtual) {
var base_type = new ObjectType ((Interface) m.base_interface_method.parent_symbol);
- instance_param = new CCodeParameter ("base", base_type.get_cname ());
+ instance_param = new CCodeParameter ("base", get_ccode_name (base_type));
} else if (m.overrides) {
var base_type = new ObjectType ((Class) m.base_method.parent_symbol);
- instance_param = new CCodeParameter ("base", base_type.get_cname ());
+ instance_param = new CCodeParameter ("base", get_ccode_name (base_type));
} else {
if (m.parent_symbol is Struct && !((Struct) m.parent_symbol).is_simple_type ()) {
- instance_param = new CCodeParameter ("*self", this_type.get_cname ());
+ instance_param = new CCodeParameter ("*self", get_ccode_name (this_type));
} else {
- instance_param = new CCodeParameter ("self", this_type.get_cname ());
+ instance_param = new CCodeParameter ("self", get_ccode_name (this_type));
}
}
cparam_map.set (get_param_pos (m.cinstance_parameter_position), instance_param);
@@ -807,7 +807,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
TypeSymbol parent_type = find_parent_type (m);
DataType this_type;
this_type = new ClassType ((Class) parent_type);
- var class_param = new CCodeParameter ("klass", this_type.get_cname ());
+ var class_param = new CCodeParameter ("klass", get_ccode_name (this_type));
cparam_map.set (get_param_pos (m.cinstance_parameter_position), class_param);
}
@@ -891,7 +891,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
public void generate_vfunc (Method m, DataType return_type, Map<int,CCodeParameter> cparam_map, Map<int,CCodeExpression> carg_map, string suffix = "", int direction = 3) {
push_context (new EmitContext ());
- string cname = m.get_cname ();
+ string cname = get_ccode_name (m);
if (suffix == "_finish" && cname.has_suffix ("_async")) {
cname = cname.substring (0, cname.length - "_async".length);
}
@@ -931,7 +931,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
ccode.add_return (vcall);
} else {
/* store method return value for postconditions */
- ccode.add_declaration (get_creturn_type (m, return_type.get_cname ()), new CCodeVariableDeclarator ("result"));
+ ccode.add_declaration (get_creturn_type (m, get_ccode_name (return_type)), new CCodeVariableDeclarator ("result"));
ccode.add_assignment (new CCodeIdentifier ("result"), vcall);
}
@@ -1008,7 +1008,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
// do not generate _new functions for creation methods of abstract classes
if (current_type_symbol is Class && !current_class.is_compact && !current_class.is_abstract) {
- var vfunc = new CCodeFunction (m.get_cname ());
+ var vfunc = new CCodeFunction (get_ccode_name (m));
var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
var carg_map = new HashMap<int,CCodeExpression> (direct_hash, direct_equal);
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index a1abbbf..a6bb108 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -26,7 +26,7 @@ using GLib;
public abstract class Vala.CCodeStructModule : CCodeBaseModule {
public override void generate_struct_declaration (Struct st, CCodeFile decl_space) {
- if (add_symbol_declaration (decl_space, st, st.get_cname ())) {
+ if (add_symbol_declaration (decl_space, st, get_ccode_name (st))) {
return;
}
@@ -58,11 +58,11 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
}
}
- var instance_struct = new CCodeStruct ("_%s".printf (st.get_cname ()));
+ var instance_struct = new CCodeStruct ("_%s".printf (get_ccode_name (st)));
instance_struct.deprecated = st.deprecated;
foreach (Field f in st.get_fields ()) {
- string field_ctype = f.variable_type.get_cname ();
+ string field_ctype = get_ccode_name (f.variable_type);
if (f.is_volatile) {
field_ctype = "volatile " + field_ctype;
}
@@ -70,7 +70,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
if (f.binding == MemberBinding.INSTANCE) {
generate_type_declaration (f.variable_type, decl_space);
- instance_struct.add_field (field_ctype, f.get_cname () + f.variable_type.get_cdeclarator_suffix (), f.deprecated ? " G_GNUC_DEPRECATED" : null);
+ instance_struct.add_field (field_ctype, get_ccode_name (f) + f.variable_type.get_cdeclarator_suffix (), f.deprecated ? " G_GNUC_DEPRECATED" : null);
if (f.variable_type is ArrayType && !f.no_array_length) {
// create fields to store array dimensions
var array_type = (ArrayType) f.variable_type;
@@ -85,11 +85,11 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
} else {
length_cname = get_array_length_cname (f.name, dim);
}
- instance_struct.add_field (len_type.get_cname (), length_cname);
+ instance_struct.add_field (get_ccode_name (len_type), length_cname);
}
if (array_type.rank == 1 && f.is_internal_symbol ()) {
- instance_struct.add_field (len_type.get_cname (), get_array_size_cname (f.name));
+ instance_struct.add_field (get_ccode_name (len_type), get_array_size_cname (f.name));
}
}
} else if (f.variable_type is DelegateType) {
@@ -106,25 +106,25 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
}
if (st.base_struct == null) {
- decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (st.get_cname ()), new CCodeVariableDeclarator (st.get_cname ())));
+ decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (get_ccode_name (st)), new CCodeVariableDeclarator (get_ccode_name (st))));
decl_space.add_type_definition (instance_struct);
} else {
- decl_space.add_type_declaration (new CCodeTypeDefinition (st.base_struct.get_cname (), new CCodeVariableDeclarator (st.get_cname ())));
+ decl_space.add_type_declaration (new CCodeTypeDefinition (get_ccode_name (st.base_struct), new CCodeVariableDeclarator (get_ccode_name (st))));
}
- var function = new CCodeFunction (st.get_dup_function (), st.get_cname () + "*");
+ var function = new CCodeFunction (st.get_dup_function (), get_ccode_name (st) + "*");
if (st.is_private_symbol ()) {
function.modifiers = CCodeModifiers.STATIC;
}
- function.add_parameter (new CCodeParameter ("self", "const " + st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", "const " + get_ccode_name (st) + "*"));
decl_space.add_function_declaration (function);
function = new CCodeFunction (st.get_free_function (), "void");
if (st.is_private_symbol ()) {
function.modifiers = CCodeModifiers.STATIC;
}
- function.add_parameter (new CCodeParameter ("self", st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (st) + "*"));
decl_space.add_function_declaration (function);
if (st.is_disposable ()) {
@@ -132,15 +132,15 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
if (st.is_private_symbol ()) {
function.modifiers = CCodeModifiers.STATIC;
}
- function.add_parameter (new CCodeParameter ("self", "const " + st.get_cname () + "*"));
- function.add_parameter (new CCodeParameter ("dest", st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", "const " + get_ccode_name (st) + "*"));
+ function.add_parameter (new CCodeParameter ("dest", get_ccode_name (st) + "*"));
decl_space.add_function_declaration (function);
function = new CCodeFunction (st.get_destroy_function (), "void");
if (st.is_private_symbol ()) {
function.modifiers = CCodeModifiers.STATIC;
}
- function.add_parameter (new CCodeParameter ("self", st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (st) + "*"));
decl_space.add_function_declaration (function);
}
}
@@ -184,19 +184,19 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
}
void add_struct_dup_function (Struct st) {
- var function = new CCodeFunction (st.get_dup_function (), st.get_cname () + "*");
+ var function = new CCodeFunction (st.get_dup_function (), get_ccode_name (st) + "*");
if (st.access == SymbolAccessibility.PRIVATE) {
function.modifiers = CCodeModifiers.STATIC;
}
- function.add_parameter (new CCodeParameter ("self", "const " + st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", "const " + get_ccode_name (st) + "*"));
push_function (function);
- ccode.add_declaration (st.get_cname () + "*", new CCodeVariableDeclarator ("dup"));
+ ccode.add_declaration (get_ccode_name (st) + "*", new CCodeVariableDeclarator ("dup"));
var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("g_new0"));
- creation_call.add_argument (new CCodeConstant (st.get_cname ()));
+ creation_call.add_argument (new CCodeConstant (get_ccode_name (st)));
creation_call.add_argument (new CCodeConstant ("1"));
ccode.add_assignment (new CCodeIdentifier ("dup"), creation_call);
@@ -209,7 +209,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
cfile.add_include ("string.h");
var sizeof_call = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- sizeof_call.add_argument (new CCodeConstant (st.get_cname ()));
+ sizeof_call.add_argument (new CCodeConstant (get_ccode_name (st)));
var copy_call = new CCodeFunctionCall (new CCodeIdentifier ("memcpy"));
copy_call.add_argument (new CCodeIdentifier ("dup"));
@@ -231,7 +231,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
function.modifiers = CCodeModifiers.STATIC;
}
- function.add_parameter (new CCodeParameter ("self", st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (st) + "*"));
push_function (function);
@@ -256,8 +256,8 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
function.modifiers = CCodeModifiers.STATIC;
}
- function.add_parameter (new CCodeParameter ("self", "const " + st.get_cname () + "*"));
- function.add_parameter (new CCodeParameter ("dest", st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", "const " + get_ccode_name (st) + "*"));
+ function.add_parameter (new CCodeParameter ("dest", get_ccode_name (st) + "*"));
push_function (function);
@@ -289,7 +289,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
function.modifiers = CCodeModifiers.STATIC;
}
- function.add_parameter (new CCodeParameter ("self", st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (st) + "*"));
push_function (function);
diff --git a/codegen/valaclassregisterfunction.vala b/codegen/valaclassregisterfunction.vala
index 8e8cb5c..73660c3 100644
--- a/codegen/valaclassregisterfunction.vala
+++ b/codegen/valaclassregisterfunction.vala
@@ -47,7 +47,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
}
public override string get_type_struct_name () {
- return "%sClass".printf (class_reference.get_cname ());
+ return "%sClass".printf (CCodeBaseModule.get_ccode_name (class_reference));
}
public override string get_base_init_func_name () {
@@ -79,7 +79,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
}
public override string get_instance_struct_size () {
- return "sizeof (%s)".printf (class_reference.get_cname ());
+ return "sizeof (%s)".printf (CCodeBaseModule.get_ccode_name (class_reference));
}
public override string get_instance_init_func_name () {
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index 80c284e..0a03228 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -24,7 +24,7 @@ using GLib;
public class Vala.GAsyncModule : GSignalModule {
CCodeStruct generate_data_struct (Method m) {
- string dataname = Symbol.lower_case_to_camel_case (m.get_cname ()) + "Data";
+ string dataname = Symbol.lower_case_to_camel_case (get_ccode_name (m)) + "Data";
var data = new CCodeStruct ("_" + dataname);
data.add_field ("int", "_state_");
@@ -35,9 +35,9 @@ public class Vala.GAsyncModule : GSignalModule {
if (m.binding == MemberBinding.INSTANCE) {
var type_sym = (TypeSymbol) m.parent_symbol;
if (type_sym is ObjectTypeSymbol) {
- data.add_field (type_sym.get_cname () + "*", "self");
+ data.add_field (get_ccode_name (type_sym) + "*", "self");
} else {
- data.add_field (type_sym.get_cname (), "self");
+ data.add_field (get_ccode_name (type_sym), "self");
}
}
@@ -46,7 +46,7 @@ public class Vala.GAsyncModule : GSignalModule {
var param_type = param.variable_type.copy ();
param_type.value_owned = true;
- data.add_field (param_type.get_cname (), get_variable_cname (param.name));
+ data.add_field (get_ccode_name (param_type), get_variable_cname (param.name));
if (param.variable_type is ArrayType) {
var array_type = (ArrayType) param.variable_type;
@@ -67,7 +67,7 @@ public class Vala.GAsyncModule : GSignalModule {
}
if (!(m.return_type is VoidType)) {
- data.add_field (m.return_type.get_cname (), "result");
+ data.add_field (get_ccode_name (m.return_type), "result");
if (m.return_type is ArrayType) {
var array_type = (ArrayType) m.return_type;
if (!m.no_array_length) {
@@ -88,7 +88,7 @@ public class Vala.GAsyncModule : GSignalModule {
}
CCodeFunction generate_free_function (Method m) {
- var dataname = Symbol.lower_case_to_camel_case (m.get_cname ()) + "Data";
+ var dataname = Symbol.lower_case_to_camel_case (get_ccode_name (m)) + "Data";
var freefunc = new CCodeFunction (m.get_real_cname () + "_data_free", "void");
freefunc.modifiers = CCodeModifiers.STATIC;
@@ -150,7 +150,7 @@ public class Vala.GAsyncModule : GSignalModule {
void generate_async_function (Method m) {
push_context (new EmitContext ());
- var dataname = Symbol.lower_case_to_camel_case (m.get_cname ()) + "Data";
+ var dataname = Symbol.lower_case_to_camel_case (get_ccode_name (m)) + "Data";
var asyncfunc = new CCodeFunction (m.get_real_cname (), "void");
var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
@@ -184,7 +184,7 @@ public class Vala.GAsyncModule : GSignalModule {
var self_target_type = new ObjectType (type_symbol);
var cself = get_cvalue_ (transform_value (new GLibValue (base_expression_type, new CCodeIdentifier ("base")), self_target_type, m));
- ccode.add_declaration ("%s *".printf (type_symbol.get_cname ()), new CCodeVariableDeclarator ("self"));
+ ccode.add_declaration ("%s *".printf (get_ccode_name (type_symbol)), new CCodeVariableDeclarator ("self"));
ccode.add_assignment (new CCodeIdentifier ("self"), cself);
}
@@ -300,11 +300,11 @@ public class Vala.GAsyncModule : GSignalModule {
public override void generate_method_declaration (Method m, CCodeFile decl_space) {
if (m.coroutine) {
- if (add_symbol_declaration (decl_space, m, m.get_cname ())) {
+ if (add_symbol_declaration (decl_space, m, get_ccode_name (m))) {
return;
}
- var asyncfunc = new CCodeFunction (m.get_cname (), "void");
+ var asyncfunc = new CCodeFunction (get_ccode_name (m), "void");
var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
cparam_map.set (get_param_pos (-1), new CCodeParameter ("_callback_", "GAsyncReadyCallback"));
cparam_map.set (get_param_pos (-0.9), new CCodeParameter ("_user_data_", "gpointer"));
@@ -386,7 +386,7 @@ public class Vala.GAsyncModule : GSignalModule {
void generate_finish_function (Method m) {
push_context (new EmitContext ());
- string dataname = Symbol.lower_case_to_camel_case (m.get_cname ()) + "Data";
+ string dataname = Symbol.lower_case_to_camel_case (get_ccode_name (m)) + "Data";
var finishfunc = new CCodeFunction (m.get_finish_real_cname ());
@@ -404,7 +404,7 @@ public class Vala.GAsyncModule : GSignalModule {
var return_type = m.return_type;
if (!(return_type is VoidType) && !return_type.is_real_non_null_struct_type ()) {
- ccode.add_declaration (m.return_type.get_cname (), new CCodeVariableDeclarator ("result"));
+ ccode.add_declaration (get_ccode_name (m.return_type), new CCodeVariableDeclarator ("result"));
}
var data_var = new CCodeIdentifier ("_data_");
@@ -473,9 +473,9 @@ public class Vala.GAsyncModule : GSignalModule {
public override string generate_ready_function (Method m) {
// generate ready callback handler
- var dataname = Symbol.lower_case_to_camel_case (m.get_cname ()) + "Data";
+ var dataname = Symbol.lower_case_to_camel_case (get_ccode_name (m)) + "Data";
- var readyfunc = new CCodeFunction (m.get_cname () + "_ready", "void");
+ var readyfunc = new CCodeFunction (get_ccode_name (m) + "_ready", "void");
if (!add_wrapper (readyfunc.name)) {
// wrapper already defined
@@ -539,7 +539,7 @@ public class Vala.GAsyncModule : GSignalModule {
generate_cparameters (m, decl_space, cparam_map, new CCodeFunction ("fake"), vdeclarator, null, null, 2);
- vdecl = new CCodeDeclaration (creturn_type.get_cname ());
+ vdecl = new CCodeDeclaration (get_ccode_name (creturn_type));
vdecl.add_declarator (vdeclarator);
type_struct.add_declaration (vdecl);
}
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index c8ee193..5f9a3f9 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -45,7 +45,7 @@ public class Vala.GDBusClientModule : GDBusModule {
public override void generate_dynamic_method_wrapper (DynamicMethod method) {
var dynamic_method = (DynamicMethod) method;
- var func = new CCodeFunction (method.get_cname ());
+ var func = new CCodeFunction (get_ccode_name (method));
func.modifiers = CCodeModifiers.STATIC;
var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
@@ -77,7 +77,7 @@ public class Vala.GDBusClientModule : GDBusModule {
string lower_cname = main_iface.get_lower_case_cprefix () + "proxy";
var proxy_iface_init = new CCodeFunction (lower_cname + "_" + iface.get_lower_case_cprefix () + "interface_init", "void");
- proxy_iface_init.add_parameter (new CCodeParameter ("iface", iface.get_cname () + "Iface*"));
+ proxy_iface_init.add_parameter (new CCodeParameter ("iface", get_ccode_name (iface) + "Iface*"));
push_function (proxy_iface_init);
@@ -169,7 +169,7 @@ public class Vala.GDBusClientModule : GDBusModule {
cfile.add_include ("gio/gio.h");
// create proxy class
- string cname = iface.get_cname () + "Proxy";
+ string cname = get_ccode_name (iface) + "Proxy";
string lower_cname = iface.get_lower_case_cprefix () + "proxy";
cfile.add_type_declaration (new CCodeTypeDefinition ("GDBusProxy", new CCodeVariableDeclarator (cname)));
@@ -206,10 +206,10 @@ public class Vala.GDBusClientModule : GDBusModule {
public override void visit_method_call (MethodCall expr) {
var mtype = expr.call.value_type as MethodType;
- bool bus_get_proxy_async = (mtype != null && mtype.method_symbol.get_cname () == "g_bus_get_proxy");
- bool bus_get_proxy_sync = (mtype != null && mtype.method_symbol.get_cname () == "g_bus_get_proxy_sync");
- bool conn_get_proxy_async = (mtype != null && mtype.method_symbol.get_cname () == "g_dbus_connection_get_proxy");
- bool conn_get_proxy_sync = (mtype != null && mtype.method_symbol.get_cname () == "g_dbus_connection_get_proxy_sync");
+ bool bus_get_proxy_async = (mtype != null && get_ccode_name (mtype.method_symbol) == "g_bus_get_proxy");
+ bool bus_get_proxy_sync = (mtype != null && get_ccode_name (mtype.method_symbol) == "g_bus_get_proxy_sync");
+ bool conn_get_proxy_async = (mtype != null && get_ccode_name (mtype.method_symbol) == "g_dbus_connection_get_proxy");
+ bool conn_get_proxy_sync = (mtype != null && get_ccode_name (mtype.method_symbol) == "g_dbus_connection_get_proxy_sync");
if (!bus_get_proxy_async && !bus_get_proxy_sync && !conn_get_proxy_async && !conn_get_proxy_sync) {
base.visit_method_call (expr);
return;
@@ -383,11 +383,11 @@ public class Vala.GDBusClientModule : GDBusModule {
}
string generate_dbus_signal_handler (Signal sig, ObjectTypeSymbol sym) {
- string wrapper_name = "_dbus_handle_%s_%s".printf (sym.get_lower_case_cname (), sig.get_cname ());
+ string wrapper_name = "_dbus_handle_%s_%s".printf (sym.get_lower_case_cname (), get_ccode_name (sig));
var function = new CCodeFunction (wrapper_name);
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", sym.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (sym) + "*"));
function.add_parameter (new CCodeParameter ("parameters", "GVariant*"));
push_function (function);
@@ -408,7 +408,7 @@ public class Vala.GDBusClientModule : GDBusModule {
var owned_type = param.variable_type.copy ();
owned_type.value_owned = true;
- ccode.add_declaration (owned_type.get_cname (), new CCodeVariableDeclarator.zero (param_name, default_value_for_type (param.variable_type, true)));
+ ccode.add_declaration (get_ccode_name (owned_type), new CCodeVariableDeclarator.zero (param_name, default_value_for_type (param.variable_type, true)));
var st = param.variable_type.data_type as Struct;
if (st != null && !st.is_simple_type ()) {
@@ -487,7 +487,7 @@ public class Vala.GDBusClientModule : GDBusModule {
}
var ccall = new CCodeFunctionCall (new CCodeIdentifier (generate_dbus_signal_handler (sig, sym)));
- ccall.add_argument (new CCodeCastExpression (new CCodeIdentifier ("proxy"), sym.get_cname () + "*"));
+ ccall.add_argument (new CCodeCastExpression (new CCodeIdentifier ("proxy"), get_ccode_name (sym) + "*"));
ccall.add_argument (new CCodeIdentifier ("parameters"));
ccode.add_expression (ccall);
@@ -716,7 +716,7 @@ public class Vala.GDBusClientModule : GDBusModule {
foreach (Parameter param in m.get_parameters ()) {
if (param.direction == ParameterDirection.OUT) {
- ccode.add_declaration (param.variable_type.get_cname (), new CCodeVariableDeclarator ("_" + param.name));
+ ccode.add_declaration (get_ccode_name (param.variable_type), new CCodeVariableDeclarator ("_" + param.name));
var array_type = param.variable_type as ArrayType;
@@ -755,7 +755,7 @@ public class Vala.GDBusClientModule : GDBusModule {
var target = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("result"));
receive_dbus_value (m.return_type, new CCodeIdentifier ("_reply_message"), new CCodeIdentifier ("_reply_iter"), target, m);
} else {
- ccode.add_declaration (m.return_type.get_cname (), new CCodeVariableDeclarator ("_result"));
+ ccode.add_declaration (get_ccode_name (m.return_type), new CCodeVariableDeclarator ("_result"));
var array_type = m.return_type as ArrayType;
@@ -886,10 +886,10 @@ public class Vala.GDBusClientModule : GDBusModule {
var function = new CCodeFunction (proxy_name);
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", "%s*".printf (iface.get_cname ())));
+ function.add_parameter (new CCodeParameter ("self", "%s*".printf (get_ccode_name (iface))));
if (prop.property_type.is_real_non_null_struct_type ()) {
- function.add_parameter (new CCodeParameter ("result", "%s*".printf (prop.get_accessor.value_type.get_cname ())));
+ function.add_parameter (new CCodeParameter ("result", "%s*".printf (get_ccode_name (prop.get_accessor.value_type))));
} else {
if (array_type != null) {
for (int dim = 1; dim <= array_type.rank; dim++) {
@@ -897,7 +897,7 @@ public class Vala.GDBusClientModule : GDBusModule {
}
}
- function.return_type = prop.get_accessor.value_type.get_cname ();
+ function.return_type = get_ccode_name (prop.get_accessor.value_type);
}
push_function (function);
@@ -964,7 +964,7 @@ public class Vala.GDBusClientModule : GDBusModule {
var result = deserialize_expression (prop.get_accessor.value_type, new CCodeIdentifier ("_inner_reply"), target);
ccode.add_assignment (target, result);
} else {
- ccode.add_declaration (prop.get_accessor.value_type.get_cname (), new CCodeVariableDeclarator ("_result"));
+ ccode.add_declaration (get_ccode_name (prop.get_accessor.value_type), new CCodeVariableDeclarator ("_result"));
if (array_type != null) {
for (int dim = 1; dim <= array_type.rank; dim++) {
@@ -1011,12 +1011,12 @@ public class Vala.GDBusClientModule : GDBusModule {
var function = new CCodeFunction (proxy_name);
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", "%s*".printf (iface.get_cname ())));
+ function.add_parameter (new CCodeParameter ("self", "%s*".printf (get_ccode_name (iface))));
if (prop.property_type.is_real_non_null_struct_type ()) {
- function.add_parameter (new CCodeParameter ("value", "%s*".printf (prop.set_accessor.value_type.get_cname ())));
+ function.add_parameter (new CCodeParameter ("value", "%s*".printf (get_ccode_name (prop.set_accessor.value_type))));
} else {
- function.add_parameter (new CCodeParameter ("value", prop.set_accessor.value_type.get_cname ()));
+ function.add_parameter (new CCodeParameter ("value", get_ccode_name (prop.set_accessor.value_type)));
if (array_type != null) {
for (int dim = 1; dim <= array_type.rank; dim++) {
diff --git a/codegen/valagdbusmodule.vala b/codegen/valagdbusmodule.vala
index 1708d03..ce23ca2 100644
--- a/codegen/valagdbusmodule.vala
+++ b/codegen/valagdbusmodule.vala
@@ -74,7 +74,7 @@ public class Vala.GDBusModule : GVariantModule {
}
var error_entry = new CCodeInitializerList ();
- error_entry.append (new CCodeIdentifier (ecode.get_cname ()));
+ error_entry.append (new CCodeIdentifier (get_ccode_name (ecode)));
error_entry.append (new CCodeConstant ("\"%s.%s\"".printf (edomain_dbus_name, ecode_dbus_name)));
error_entries.append (error_entry);
}
@@ -86,7 +86,7 @@ public class Vala.GDBusModule : GVariantModule {
string quark_fun_name = edomain.get_lower_case_cprefix () + "quark";
- var cquark_fun = new CCodeFunction (quark_fun_name, gquark_type.data_type.get_cname ());
+ var cquark_fun = new CCodeFunction (quark_fun_name, get_ccode_name (gquark_type.data_type));
push_function (cquark_fun);
string quark_name = "%squark_volatile".printf (edomain.get_lower_case_cprefix ());
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index 6593d08..44b4c2d 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -46,7 +46,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
}
string generate_dbus_wrapper (Method m, ObjectTypeSymbol sym, bool ready = false) {
- string wrapper_name = "_dbus_%s".printf (m.get_cname ());
+ string wrapper_name = "_dbus_%s".printf (get_ccode_name (m));
if (m.base_method != null) {
m = m.base_method;
@@ -63,7 +63,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
function.modifiers = CCodeModifiers.STATIC;
if (!ready) {
- function.add_parameter (new CCodeParameter ("self", sym.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (sym) + "*"));
function.add_parameter (new CCodeParameter ("parameters", "GVariant*"));
function.add_parameter (new CCodeParameter ("invocation", "GDBusMethodInvocation*"));
} else {
@@ -105,11 +105,11 @@ public class Vala.GDBusServerModule : GDBusClientModule {
CCodeFunctionCall ccall;
if (!ready) {
- ccall = new CCodeFunctionCall (new CCodeIdentifier (m.get_cname ()));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (m)));
ccall.add_argument (new CCodeIdentifier ("self"));
} else {
ccall = new CCodeFunctionCall (new CCodeIdentifier (m.get_finish_cname ()));
- ccall.add_argument (new CCodeCastExpression (new CCodeIdentifier ("source_object"), sym.get_cname () + "*"));
+ ccall.add_argument (new CCodeCastExpression (new CCodeIdentifier ("source_object"), get_ccode_name (sym) + "*"));
ccall.add_argument (new CCodeIdentifier ("_res_"));
}
@@ -136,7 +136,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
var owned_type = param.variable_type.copy ();
owned_type.value_owned = true;
- ccode.add_declaration (owned_type.get_cname (), new CCodeVariableDeclarator.zero (param_name, default_value_for_type (param.variable_type, true)));
+ ccode.add_declaration (get_ccode_name (owned_type), new CCodeVariableDeclarator.zero (param_name, default_value_for_type (param.variable_type, true)));
var array_type = param.variable_type as ArrayType;
if (array_type != null) {
@@ -292,7 +292,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
var owned_type = param.variable_type.copy ();
owned_type.value_owned = true;
- ccode.add_declaration (owned_type.get_cname (), new CCodeVariableDeclarator.zero (param_name, default_value_for_type (param.variable_type, true)));
+ ccode.add_declaration (get_ccode_name (owned_type), new CCodeVariableDeclarator.zero (param_name, default_value_for_type (param.variable_type, true)));
var array_type = param.variable_type as ArrayType;
if (array_type != null) {
@@ -308,7 +308,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
if (!(m.return_type is VoidType)) {
if (m.return_type.is_real_non_null_struct_type ()) {
- ccode.add_declaration (m.return_type.get_cname (), new CCodeVariableDeclarator.zero ("result", default_value_for_type (m.return_type, true)));
+ ccode.add_declaration (get_ccode_name (m.return_type), new CCodeVariableDeclarator.zero ("result", default_value_for_type (m.return_type, true)));
send_dbus_value (m.return_type, new CCodeIdentifier ("_reply_builder"), new CCodeIdentifier ("result"), m);
@@ -318,7 +318,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
ccode.add_expression (destroy_local (local));
}
} else {
- ccode.add_declaration (m.return_type.get_cname (), new CCodeVariableDeclarator ("result"));
+ ccode.add_declaration (get_ccode_name (m.return_type), new CCodeVariableDeclarator ("result"));
var array_type = m.return_type as ArrayType;
if (array_type != null) {
@@ -418,7 +418,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
}
string generate_dbus_signal_wrapper (Signal sig, ObjectTypeSymbol sym, string dbus_iface_name) {
- string wrapper_name = "_dbus_%s_%s".printf (sym.get_lower_case_cname (), sig.get_cname ());
+ string wrapper_name = "_dbus_%s_%s".printf (sym.get_lower_case_cname (), get_ccode_name (sig));
var function = new CCodeFunction (wrapper_name, "void");
function.modifiers = CCodeModifiers.STATIC;
@@ -484,24 +484,24 @@ public class Vala.GDBusServerModule : GDBusClientModule {
}
string generate_dbus_property_get_wrapper (Property prop, ObjectTypeSymbol sym) {
- string wrapper_name = "_dbus_%s".printf (prop.get_accessor.get_cname ());
+ string wrapper_name = "_dbus_%s".printf (get_ccode_name (prop.get_accessor));
var function = new CCodeFunction (wrapper_name, "GVariant*");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", sym.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (sym) + "*"));
push_function (function);
- var ccall = new CCodeFunctionCall (new CCodeIdentifier (prop.get_accessor.get_cname ()));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (prop.get_accessor)));
ccall.add_argument (new CCodeIdentifier ("self"));
if (prop.get_accessor.value_type.is_real_non_null_struct_type ()) {
- ccode.add_declaration (prop.get_accessor.value_type.get_cname (), new CCodeVariableDeclarator.zero ("result", default_value_for_type (prop.get_accessor.value_type, true)));
+ ccode.add_declaration (get_ccode_name (prop.get_accessor.value_type), new CCodeVariableDeclarator.zero ("result", default_value_for_type (prop.get_accessor.value_type, true)));
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("result")));
ccode.add_expression (ccall);
} else {
- ccode.add_declaration (prop.get_accessor.value_type.get_cname (), new CCodeVariableDeclarator ("result"));
+ ccode.add_declaration (get_ccode_name (prop.get_accessor.value_type), new CCodeVariableDeclarator ("result"));
ccode.add_assignment (new CCodeIdentifier ("result"), ccall);
var array_type = prop.get_accessor.value_type as ArrayType;
@@ -537,22 +537,22 @@ public class Vala.GDBusServerModule : GDBusClientModule {
}
string generate_dbus_property_set_wrapper (Property prop, ObjectTypeSymbol sym) {
- string wrapper_name = "_dbus_%s".printf (prop.set_accessor.get_cname ());
+ string wrapper_name = "_dbus_%s".printf (get_ccode_name (prop.set_accessor));
var function = new CCodeFunction (wrapper_name);
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("self", sym.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (sym) + "*"));
function.add_parameter (new CCodeParameter ("_value", "GVariant*"));
push_function (function);
- var ccall = new CCodeFunctionCall (new CCodeIdentifier (prop.set_accessor.get_cname ()));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (prop.set_accessor)));
ccall.add_argument (new CCodeIdentifier ("self"));
var owned_type = prop.property_type.copy ();
owned_type.value_owned = true;
- ccode.add_declaration (owned_type.get_cname (), new CCodeVariableDeclarator.zero ("value", default_value_for_type (prop.property_type, true)));
+ ccode.add_declaration (get_ccode_name (owned_type), new CCodeVariableDeclarator.zero ("value", default_value_for_type (prop.property_type, true)));
var st = prop.property_type.data_type as Struct;
if (st != null && !st.is_simple_type ()) {
@@ -918,31 +918,31 @@ public class Vala.GDBusServerModule : GDBusClientModule {
info.append (new CCodeConstant ("\"%s\"".printf (get_type_signature (param.variable_type, param))));
var cdecl = new CCodeDeclaration ("const GDBusArgInfo");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + sig.get_cname () + "_" + param.name, info));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + get_ccode_name (sig) + "_" + param.name, info));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_constant_declaration (cdecl);
- args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + sig.get_cname () + "_" + param.name)));
+ args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + get_ccode_name (sig) + "_" + param.name)));
}
args_info.append (new CCodeConstant ("NULL"));
var cdecl = new CCodeDeclaration ("const GDBusArgInfo * const");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + sig.get_cname () + "[]", args_info));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + get_ccode_name (sig) + "[]", args_info));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_constant_declaration (cdecl);
var info = new CCodeInitializerList ();
info.append (new CCodeConstant ("-1"));
info.append (new CCodeConstant ("\"%s\"".printf (get_dbus_name_for_member (sig))));
- info.append (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + sig.get_cname ())), "GDBusArgInfo **"));
+ info.append (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + get_ccode_name (sig))), "GDBusArgInfo **"));
cdecl = new CCodeDeclaration ("const GDBusSignalInfo");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_signal_info_" + sig.get_cname (), info));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_signal_info_" + get_ccode_name (sig), info));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_constant_declaration (cdecl);
- infos.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_signal_info_" + sig.get_cname ())));
+ infos.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_signal_info_" + get_ccode_name (sig))));
}
infos.append (new CCodeConstant ("NULL"));
@@ -1096,7 +1096,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
public override void visit_method_call (MethodCall expr) {
var mtype = expr.call.value_type as MethodType;
- if (mtype == null || mtype.method_symbol.get_cname () != "g_dbus_connection_register_object") {
+ if (mtype == null || get_ccode_name (mtype.method_symbol) != "g_dbus_connection_register_object") {
base.visit_method_call (expr);
return;
}
diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala
index 7331280..cf717fe 100644
--- a/codegen/valagerrormodule.vala
+++ b/codegen/valagerrormodule.vala
@@ -29,18 +29,18 @@ public class Vala.GErrorModule : CCodeDelegateModule {
private bool is_in_catch = false;
public override void generate_error_domain_declaration (ErrorDomain edomain, CCodeFile decl_space) {
- if (add_symbol_declaration (decl_space, edomain, edomain.get_cname ())) {
+ if (add_symbol_declaration (decl_space, edomain, get_ccode_name (edomain))) {
return;
}
- var cenum = new CCodeEnum (edomain.get_cname ());
+ var cenum = new CCodeEnum (get_ccode_name (edomain));
foreach (ErrorCode ecode in edomain.get_codes ()) {
if (ecode.value == null) {
- cenum.add_value (new CCodeEnumValue (ecode.get_cname ()));
+ cenum.add_value (new CCodeEnumValue (get_ccode_name (ecode)));
} else {
ecode.value.emit (this);
- cenum.add_value (new CCodeEnumValue (ecode.get_cname (), get_cvalue (ecode.value)));
+ cenum.add_value (new CCodeEnumValue (get_ccode_name (ecode), get_cvalue (ecode.value)));
}
}
@@ -51,7 +51,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
var error_domain_define = new CCodeMacroReplacement (edomain.get_upper_case_cname (), quark_fun_name + " ()");
decl_space.add_type_definition (error_domain_define);
- var cquark_fun = new CCodeFunction (quark_fun_name, gquark_type.data_type.get_cname ());
+ var cquark_fun = new CCodeFunction (quark_fun_name, get_ccode_name (gquark_type.data_type));
decl_space.add_function_declaration (cquark_fun);
}
@@ -72,7 +72,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
string quark_fun_name = edomain.get_lower_case_cprefix () + "quark";
- var cquark_fun = new CCodeFunction (quark_fun_name, gquark_type.data_type.get_cname ());
+ var cquark_fun = new CCodeFunction (quark_fun_name, get_ccode_name (gquark_type.data_type));
push_function (cquark_fun);
var cquark_call = new CCodeFunctionCall (new CCodeIdentifier ("g_quark_from_static_string"));
@@ -218,7 +218,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
var error_match = new CCodeFunctionCall (new CCodeIdentifier ("g_error_matches"));
error_match.add_argument (inner_error);
error_match.add_argument (new CCodeIdentifier (catch_type.data_type.get_upper_case_cname ()));
- error_match.add_argument (new CCodeIdentifier (catch_type.error_code.get_cname ()));
+ error_match.add_argument (new CCodeIdentifier (get_ccode_name (catch_type.error_code)));
ccode.open_if (error_match);
} else {
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index 63419b1..8ce9c7d 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -184,7 +184,7 @@ public class Vala.GObjectModule : GTypeModule {
push_function (get_prop);
CCodeFunctionCall ccall = generate_instance_cast (new CCodeIdentifier ("object"), cl);
- ccode.add_declaration ("%s *".printf (cl.get_cname ()), new CCodeVariableDeclarator ("self", ccall));
+ ccode.add_declaration ("%s *".printf (get_ccode_name (cl)), new CCodeVariableDeclarator ("self", ccall));
ccode.open_switch (new CCodeIdentifier ("property_id"));
var props = cl.get_properties ();
@@ -218,9 +218,9 @@ public class Vala.GObjectModule : GTypeModule {
var st = prop.property_type.data_type as Struct;
ccode.open_block ();
- ccode.add_declaration (st.get_cname (), new CCodeVariableDeclarator ("boxed"));
+ ccode.add_declaration (get_ccode_name (st), new CCodeVariableDeclarator ("boxed"));
- ccall = new CCodeFunctionCall (new CCodeIdentifier (base_prop.get_accessor.get_cname ()));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (base_prop.get_accessor)));
ccall.add_argument (cself);
var boxed_addr = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("boxed"));
ccall.add_argument (boxed_addr);
@@ -237,7 +237,7 @@ public class Vala.GObjectModule : GTypeModule {
}
ccode.close ();
} else {
- ccall = new CCodeFunctionCall (new CCodeIdentifier (base_prop.get_accessor.get_cname ()));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (base_prop.get_accessor)));
ccall.add_argument (cself);
var array_type = prop.property_type as ArrayType;
if (array_type != null && array_type.element_type.data_type == string_type.data_type) {
@@ -284,7 +284,7 @@ public class Vala.GObjectModule : GTypeModule {
push_function (set_prop);
CCodeFunctionCall ccall = generate_instance_cast (new CCodeIdentifier ("object"), cl);
- ccode.add_declaration ("%s *".printf (cl.get_cname ()), new CCodeVariableDeclarator ("self", ccall));
+ ccode.add_declaration ("%s *".printf (get_ccode_name (cl)), new CCodeVariableDeclarator ("self", ccall));
ccode.open_switch (new CCodeIdentifier ("property_id"));
var props = cl.get_properties ();
@@ -313,7 +313,7 @@ public class Vala.GObjectModule : GTypeModule {
}
ccode.add_case (new CCodeIdentifier (prop.get_upper_case_cname ()));
- ccall = new CCodeFunctionCall (new CCodeIdentifier (base_prop.set_accessor.get_cname ()));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (base_prop.set_accessor)));
ccall.add_argument (cself);
if (prop.property_type is ArrayType && ((ArrayType)prop.property_type).element_type.data_type == string_type.data_type) {
ccode.open_block ();
@@ -442,7 +442,7 @@ public class Vala.GObjectModule : GTypeModule {
ccall = generate_instance_cast (new CCodeIdentifier ("obj"), cl);
- ccode.add_declaration ("%s *".printf (cl.get_cname ()), new CCodeVariableDeclarator ("self"));
+ ccode.add_declaration ("%s *".printf (get_ccode_name (cl)), new CCodeVariableDeclarator ("self"));
ccode.add_assignment (new CCodeIdentifier ("self"), ccall);
c.body.emit (this);
@@ -520,14 +520,14 @@ public class Vala.GObjectModule : GTypeModule {
string getter_cname = "_dynamic_get_%s%d".printf (prop.name, dynamic_property_id++);
- var func = new CCodeFunction (getter_cname, prop.property_type.get_cname ());
+ var func = new CCodeFunction (getter_cname, get_ccode_name (prop.property_type));
func.modifiers |= CCodeModifiers.STATIC | CCodeModifiers.INLINE;
- func.add_parameter (new CCodeParameter ("obj", prop.dynamic_type.get_cname ()));
+ func.add_parameter (new CCodeParameter ("obj", get_ccode_name (prop.dynamic_type)));
push_function (func);
- ccode.add_declaration (prop.property_type.get_cname (), new CCodeVariableDeclarator ("result"));
+ ccode.add_declaration (get_ccode_name (prop.property_type), new CCodeVariableDeclarator ("result"));
var call = new CCodeFunctionCall (new CCodeIdentifier ("g_object_get"));
call.add_argument (new CCodeIdentifier ("obj"));
@@ -558,8 +558,8 @@ public class Vala.GObjectModule : GTypeModule {
var func = new CCodeFunction (setter_cname, "void");
func.modifiers |= CCodeModifiers.STATIC | CCodeModifiers.INLINE;
- func.add_parameter (new CCodeParameter ("obj", prop.dynamic_type.get_cname ()));
- func.add_parameter (new CCodeParameter ("value", prop.property_type.get_cname ()));
+ func.add_parameter (new CCodeParameter ("obj", get_ccode_name (prop.dynamic_type)));
+ func.add_parameter (new CCodeParameter ("value", get_ccode_name (prop.property_type)));
push_function (func);
diff --git a/codegen/valagsignalmodule.vala b/codegen/valagsignalmodule.vala
index 1bde964..dfadc76 100644
--- a/codegen/valagsignalmodule.vala
+++ b/codegen/valagsignalmodule.vala
@@ -90,7 +90,7 @@ public class Vala.GSignalModule : GObjectModule {
} else if (t.data_type is Struct) {
var st = (Struct) t.data_type;
if (st.is_simple_type ()) {
- return t.data_type.get_cname ();
+ return get_ccode_name (t.data_type);
} else {
return "gpointer";
}
@@ -336,7 +336,7 @@ public class Vala.GSignalModule : GObjectModule {
public override CCodeFunctionCall get_signal_creation (Signal sig, TypeSymbol type) {
var csignew = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_new"));
- csignew.add_argument (new CCodeConstant ("\"%s\"".printf (sig.get_cname ())));
+ csignew.add_argument (new CCodeConstant ("\"%s\"".printf (get_ccode_name (sig))));
csignew.add_argument (new CCodeIdentifier (type.get_type_id ()));
string[] flags = new string[0];
if (sig.run_type == "first") {
@@ -369,7 +369,7 @@ public class Vala.GSignalModule : GObjectModule {
} else {
var struct_offset = new CCodeFunctionCall (new CCodeIdentifier ("G_STRUCT_OFFSET"));
if (type is Class) {
- struct_offset.add_argument (new CCodeIdentifier ("%sClass".printf (type.get_cname ())));
+ struct_offset.add_argument (new CCodeIdentifier ("%sClass".printf (get_ccode_name (type))));
} else {
// interface
struct_offset.add_argument (new CCodeIdentifier (((Interface) type).get_type_cname ()));
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 2a239df..90bcf96 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -31,7 +31,7 @@ public class Vala.GTypeModule : GErrorModule {
generate_type_declaration (param.variable_type, decl_space);
- string ctypename = param.variable_type.get_cname ();
+ string ctypename = get_ccode_name (param.variable_type);
if (param.direction != ParameterDirection.IN) {
ctypename += "*";
@@ -48,7 +48,7 @@ public class Vala.GTypeModule : GErrorModule {
}
public override void generate_class_declaration (Class cl, CCodeFile decl_space) {
- if (add_symbol_declaration (decl_space, cl, cl.get_cname ())) {
+ if (add_symbol_declaration (decl_space, cl, get_ccode_name (cl))) {
return;
}
@@ -66,10 +66,10 @@ public class Vala.GTypeModule : GErrorModule {
var macro = "(%s_get_type ())".printf (cl.get_lower_case_cname (null));
decl_space.add_type_declaration (new CCodeMacroReplacement (cl.get_type_id (), macro));
- macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (cl.get_type_id (), cl.get_cname ());
+ macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (cl.get_type_id (), get_ccode_name (cl));
decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(obj)".printf (cl.get_upper_case_cname (null)), macro));
- macro = "(G_TYPE_CHECK_CLASS_CAST ((klass), %s, %sClass))".printf (cl.get_type_id (), cl.get_cname ());
+ macro = "(G_TYPE_CHECK_CLASS_CAST ((klass), %s, %sClass))".printf (cl.get_type_id (), get_ccode_name (cl));
decl_space.add_type_declaration (new CCodeMacroReplacement ("%s_CLASS(klass)".printf (cl.get_upper_case_cname (null)), macro));
macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (cl.get_type_id ());
@@ -78,15 +78,15 @@ public class Vala.GTypeModule : GErrorModule {
macro = "(G_TYPE_CHECK_CLASS_TYPE ((klass), %s))".printf (cl.get_type_id ());
decl_space.add_type_declaration (new CCodeMacroReplacement ("%s_CLASS(klass)".printf (get_type_check_function (cl)), macro));
- macro = "(G_TYPE_INSTANCE_GET_CLASS ((obj), %s, %sClass))".printf (cl.get_type_id (), cl.get_cname ());
+ macro = "(G_TYPE_INSTANCE_GET_CLASS ((obj), %s, %sClass))".printf (cl.get_type_id (), get_ccode_name (cl));
decl_space.add_type_declaration (new CCodeMacroReplacement ("%s_GET_CLASS(obj)".printf (cl.get_upper_case_cname (null)), macro));
decl_space.add_type_declaration (new CCodeNewline ());
}
if (cl.is_compact && cl.base_class != null) {
- decl_space.add_type_declaration (new CCodeTypeDefinition (cl.base_class.get_cname (), new CCodeVariableDeclarator (cl.get_cname ())));
+ decl_space.add_type_declaration (new CCodeTypeDefinition (get_ccode_name (cl.base_class), new CCodeVariableDeclarator (get_ccode_name (cl))));
} else {
- decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (cl.get_cname ()), new CCodeVariableDeclarator (cl.get_cname ())));
+ decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (get_ccode_name (cl)), new CCodeVariableDeclarator (get_ccode_name (cl))));
}
if (is_fundamental) {
@@ -162,14 +162,14 @@ public class Vala.GTypeModule : GErrorModule {
function.modifiers = CCodeModifiers.STATIC;
}
- function.add_parameter (new CCodeParameter ("self", cl.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (cl) + "*"));
decl_space.add_function_declaration (function);
}
}
if (is_gtypeinstance) {
- decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%sClass".printf (cl.get_cname ()), new CCodeVariableDeclarator ("%sClass".printf (cl.get_cname ()))));
+ decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%sClass".printf (get_ccode_name (cl)), new CCodeVariableDeclarator ("%sClass".printf (get_ccode_name (cl)))));
var type_fun = new ClassRegisterFunction (cl, context);
type_fun.init_from_type (in_plugin, true);
@@ -178,7 +178,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 _" + cl.get_cname ())) {
+ if (add_symbol_declaration (decl_space, cl, "struct _" + get_ccode_name (cl))) {
return;
}
@@ -198,11 +198,11 @@ public class Vala.GTypeModule : GErrorModule {
bool is_gtypeinstance = !cl.is_compact;
bool is_fundamental = is_gtypeinstance && cl.base_class == null;
- var instance_struct = new CCodeStruct ("_%s".printf (cl.get_cname ()));
- var type_struct = new CCodeStruct ("_%sClass".printf (cl.get_cname ()));
+ var instance_struct = new CCodeStruct ("_%s".printf (get_ccode_name (cl)));
+ var type_struct = new CCodeStruct ("_%sClass".printf (get_ccode_name (cl)));
if (cl.base_class != null) {
- instance_struct.add_field (cl.base_class.get_cname (), "parent_instance");
+ instance_struct.add_field (get_ccode_name (cl.base_class), "parent_instance");
} else if (is_fundamental) {
decl_space.add_include ("glib-object.h");
instance_struct.add_field ("GTypeInstance", "parent_instance");
@@ -215,17 +215,17 @@ public class Vala.GTypeModule : GErrorModule {
}
if (is_gtypeinstance) {
- decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %sPrivate".printf (instance_struct.name), new CCodeVariableDeclarator ("%sPrivate".printf (cl.get_cname ()))));
+ decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %sPrivate".printf (instance_struct.name), new CCodeVariableDeclarator ("%sPrivate".printf (get_ccode_name (cl)))));
- instance_struct.add_field ("%sPrivate *".printf (cl.get_cname ()), "priv");
+ instance_struct.add_field ("%sPrivate *".printf (get_ccode_name (cl)), "priv");
if (is_fundamental) {
type_struct.add_field ("GTypeClass", "parent_class");
} else {
- type_struct.add_field ("%sClass".printf (cl.base_class.get_cname ()), "parent_class");
+ type_struct.add_field ("%sClass".printf (get_ccode_name (cl.base_class)), "parent_class");
}
if (is_fundamental) {
- type_struct.add_field ("void", "(*finalize) (%s *self)".printf (cl.get_cname ()));
+ type_struct.add_field ("void", "(*finalize) (%s *self)".printf (get_ccode_name (cl)));
}
}
@@ -248,18 +248,18 @@ public class Vala.GTypeModule : GErrorModule {
var t = (ObjectTypeSymbol) prop.parent_symbol;
var this_type = new ObjectType (t);
- var cselfparam = new CCodeParameter ("self", this_type.get_cname ());
+ var cselfparam = new CCodeParameter ("self", get_ccode_name (this_type));
if (prop.get_accessor != null) {
var vdeclarator = new CCodeFunctionDeclarator ("get_%s".printf (prop.name));
vdeclarator.add_parameter (cselfparam);
string creturn_type;
if (prop.property_type.is_real_non_null_struct_type ()) {
- var cvalueparam = new CCodeParameter ("result", prop.get_accessor.value_type.get_cname () + "*");
+ var cvalueparam = new CCodeParameter ("result", get_ccode_name (prop.get_accessor.value_type) + "*");
vdeclarator.add_parameter (cvalueparam);
creturn_type = "void";
} else {
- creturn_type = prop.get_accessor.value_type.get_cname ();
+ creturn_type = get_ccode_name (prop.get_accessor.value_type);
}
var array_type = prop.property_type as ArrayType;
@@ -278,9 +278,9 @@ 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", prop.set_accessor.value_type.get_cname () + "*");
+ cvalueparam = new CCodeParameter ("value", get_ccode_name (prop.set_accessor.value_type) + "*");
} else {
- cvalueparam = new CCodeParameter ("value", prop.set_accessor.value_type.get_cname ());
+ cvalueparam = new CCodeParameter ("value", get_ccode_name (prop.set_accessor.value_type));
}
var vdeclarator = new CCodeFunctionDeclarator ("set_%s".printf (prop.name));
@@ -303,7 +303,7 @@ public class Vala.GTypeModule : GErrorModule {
}
foreach (Field f in cl.get_fields ()) {
- string field_ctype = f.variable_type.get_cname ();
+ string field_ctype = get_ccode_name (f.variable_type);
if (f.is_volatile) {
field_ctype = "volatile " + field_ctype;
}
@@ -312,7 +312,7 @@ public class Vala.GTypeModule : GErrorModule {
if (f.binding == MemberBinding.INSTANCE) {
generate_type_declaration (f.variable_type, decl_space);
- instance_struct.add_field (field_ctype, f.get_cname (), f.variable_type.get_cdeclarator_suffix ());
+ instance_struct.add_field (field_ctype, get_ccode_name (f), f.variable_type.get_cdeclarator_suffix ());
if (f.variable_type is ArrayType && !f.no_array_length) {
// create fields to store array dimensions
var array_type = (ArrayType) f.variable_type;
@@ -327,11 +327,11 @@ public class Vala.GTypeModule : GErrorModule {
} else {
length_cname = get_array_length_cname (f.name, dim);
}
- instance_struct.add_field (len_type.get_cname (), length_cname);
+ instance_struct.add_field (get_ccode_name (len_type), length_cname);
}
if (array_type.rank == 1 && f.is_internal_symbol ()) {
- instance_struct.add_field (len_type.get_cname (), get_array_size_cname (f.name));
+ instance_struct.add_field (get_ccode_name (len_type), get_array_size_cname (f.name));
}
}
} else if (f.variable_type is DelegateType) {
@@ -345,7 +345,7 @@ public class Vala.GTypeModule : GErrorModule {
}
}
} else if (f.binding == MemberBinding.CLASS) {
- type_struct.add_field (field_ctype, f.get_cname ());
+ type_struct.add_field (field_ctype, get_ccode_name (f));
}
}
}
@@ -377,21 +377,21 @@ public class Vala.GTypeModule : GErrorModule {
generate_cparameters (m, decl_space, cparam_map, new CCodeFunction ("fake"), vdeclarator);
- var vdecl = new CCodeDeclaration (creturn_type.get_cname ());
+ var vdecl = new CCodeDeclaration (get_ccode_name (creturn_type));
vdecl.add_declarator (vdeclarator);
type_struct.add_declaration (vdecl);
}
void generate_class_private_declaration (Class cl, CCodeFile decl_space) {
- if (decl_space.add_declaration (cl.get_cname () + "Private")) {
+ if (decl_space.add_declaration (get_ccode_name (cl) + "Private")) {
return;
}
bool is_gtypeinstance = !cl.is_compact;
bool has_class_locks = false;
- var instance_priv_struct = new CCodeStruct ("_%sPrivate".printf (cl.get_cname ()));
- var type_priv_struct = new CCodeStruct ("_%sClassPrivate".printf (cl.get_cname ()));
+ var instance_priv_struct = new CCodeStruct ("_%sPrivate".printf (get_ccode_name (cl)));
+ var type_priv_struct = new CCodeStruct ("_%sClassPrivate".printf (get_ccode_name (cl)));
if (is_gtypeinstance) {
/* create type, dup_func, and destroy_func fields for generic types */
@@ -410,7 +410,7 @@ public class Vala.GTypeModule : GErrorModule {
}
foreach (Field f in cl.get_fields ()) {
- string field_ctype = f.variable_type.get_cname ();
+ string field_ctype = get_ccode_name (f.variable_type);
if (f.is_volatile) {
field_ctype = "volatile " + field_ctype;
}
@@ -419,7 +419,7 @@ public class Vala.GTypeModule : GErrorModule {
if (f.access == SymbolAccessibility.PRIVATE) {
generate_type_declaration (f.variable_type, decl_space);
- instance_priv_struct.add_field (field_ctype, f.get_cname (), f.variable_type.get_cdeclarator_suffix ());
+ instance_priv_struct.add_field (field_ctype, get_ccode_name (f), f.variable_type.get_cdeclarator_suffix ());
if (f.variable_type is ArrayType && !f.no_array_length) {
// create fields to store array dimensions
var array_type = (ArrayType) f.variable_type;
@@ -433,11 +433,11 @@ public class Vala.GTypeModule : GErrorModule {
} else {
length_cname = get_array_length_cname (f.name, dim);
}
- instance_priv_struct.add_field (len_type.get_cname (), length_cname);
+ instance_priv_struct.add_field (get_ccode_name (len_type), length_cname);
}
if (array_type.rank == 1 && f.is_internal_symbol ()) {
- instance_priv_struct.add_field (len_type.get_cname (), get_array_size_cname (f.name));
+ instance_priv_struct.add_field (get_ccode_name (len_type), get_array_size_cname (f.name));
}
}
} else if (f.variable_type is DelegateType) {
@@ -455,17 +455,17 @@ public class Vala.GTypeModule : GErrorModule {
if (f.get_lock_used ()) {
cl.has_private_fields = true;
// add field for mutex
- instance_priv_struct.add_field (mutex_type.get_cname (), get_symbol_lock_name (f.name));
+ instance_priv_struct.add_field (get_ccode_name (mutex_type), get_symbol_lock_name (f.name));
}
} else if (f.binding == MemberBinding.CLASS) {
if (f.access == SymbolAccessibility.PRIVATE) {
- type_priv_struct.add_field (field_ctype, f.get_cname ());
+ type_priv_struct.add_field (field_ctype, get_ccode_name (f));
}
if (f.get_lock_used ()) {
has_class_locks = true;
// add field for mutex
- type_priv_struct.add_field (mutex_type.get_cname (), get_symbol_lock_name (f.get_cname ()));
+ type_priv_struct.add_field (get_ccode_name (mutex_type), get_symbol_lock_name (get_ccode_name (f)));
}
}
}
@@ -475,20 +475,20 @@ public class Vala.GTypeModule : GErrorModule {
if (prop.get_lock_used ()) {
cl.has_private_fields = true;
// add field for mutex
- instance_priv_struct.add_field (mutex_type.get_cname (), get_symbol_lock_name (prop.name));
+ 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 ()) {
has_class_locks = true;
// add field for mutex
- type_priv_struct.add_field (mutex_type.get_cname (), get_symbol_lock_name (prop.name));
+ type_priv_struct.add_field (get_ccode_name (mutex_type), get_symbol_lock_name (prop.name));
}
}
}
if (is_gtypeinstance) {
if (cl.has_class_private_fields || has_class_locks) {
- decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (type_priv_struct.name), new CCodeVariableDeclarator ("%sClassPrivate".printf (cl.get_cname ()))));
+ decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (type_priv_struct.name), new CCodeVariableDeclarator ("%sClassPrivate".printf (get_ccode_name (cl)))));
if (!context.require_glib_version (2, 24)) {
var cdecl = new CCodeDeclaration ("GQuark");
cdecl.add_declarator (new CCodeVariableDeclarator ("_vala_%s_class_private_quark".printf (cl.get_lower_case_cname ()), new CCodeConstant ("0")));
@@ -500,7 +500,7 @@ public class Vala.GTypeModule : GErrorModule {
/* only add the *Private struct if it is not empty, i.e. we actually have private data */
if (cl.has_private_fields || cl.get_type_parameters ().size > 0) {
decl_space.add_type_definition (instance_priv_struct);
- var macro = "(G_TYPE_INSTANCE_GET_PRIVATE ((o), %s, %sPrivate))".printf (cl.get_type_id (), cl.get_cname ());
+ var macro = "(G_TYPE_INSTANCE_GET_PRIVATE ((o), %s, %sPrivate))".printf (cl.get_type_id (), get_ccode_name (cl));
decl_space.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_PRIVATE(o)".printf (cl.get_upper_case_cname (null)), macro));
}
@@ -509,9 +509,9 @@ public class Vala.GTypeModule : GErrorModule {
string macro;
if (context.require_glib_version (2, 24)) {
- macro = "(G_TYPE_CLASS_GET_PRIVATE (klass, %s, %sClassPrivate))".printf (cl.get_type_id (), cl.get_cname ());
+ macro = "(G_TYPE_CLASS_GET_PRIVATE (klass, %s, %sClassPrivate))".printf (cl.get_type_id (), get_ccode_name (cl));
} else {
- macro = "((%sClassPrivate *) g_type_get_qdata (G_TYPE_FROM_CLASS (klass), _vala_%s_class_private_quark))".printf (cl.get_cname(), cl.get_lower_case_cname ());
+ macro = "((%sClassPrivate *) g_type_get_qdata (G_TYPE_FROM_CLASS (klass), _vala_%s_class_private_quark))".printf (get_ccode_name (cl), cl.get_lower_case_cname ());
}
decl_space.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_CLASS_PRIVATE(klass)".printf (cl.get_upper_case_cname (null)), macro));
}
@@ -538,9 +538,9 @@ public class Vala.GTypeModule : GErrorModule {
bool is_gtypeinstance = !cl.is_compact;
bool is_fundamental = is_gtypeinstance && cl.base_class == null;
- if (cl.get_cname().length < 3) {
+ if (get_ccode_name (cl).length < 3) {
cl.error = true;
- Report.error (cl.source_reference, "Class name `%s' is too short".printf (cl.get_cname ()));
+ Report.error (cl.source_reference, "Class name `%s' is too short".printf (get_ccode_name (cl)));
return;
}
@@ -653,7 +653,7 @@ public class Vala.GTypeModule : GErrorModule {
}
push_function (ref_fun);
- ccode.add_declaration (cl.get_cname () + "*", new CCodeVariableDeclarator ("self", new CCodeIdentifier ("instance")));
+ ccode.add_declaration (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);
@@ -670,7 +670,7 @@ public class Vala.GTypeModule : GErrorModule {
}
push_function (unref_fun);
- ccode.add_declaration (cl.get_cname () + "*", new CCodeVariableDeclarator ("self", new CCodeIdentifier ("instance")));
+ ccode.add_declaration (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);
@@ -796,7 +796,7 @@ public class Vala.GTypeModule : GErrorModule {
push_function (function);
- ccode.add_declaration (cl.get_cname () + "**", new CCodeVariableDeclarator ("object_p", new CCodeMemberAccess (new CCodeIdentifier ("collect_values[0]"), "v_pointer")));
+ ccode.add_declaration (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"));
@@ -841,7 +841,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 (cl.get_cname () + "*", new CCodeVariableDeclarator ("object", collect_vpointer));
+ ccode.add_declaration (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"));
@@ -952,7 +952,7 @@ public class Vala.GTypeModule : GErrorModule {
push_function (function);
- ccode.add_declaration (cl.get_cname()+"*", new CCodeVariableDeclarator ("old"));
+ ccode.add_declaration (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" ));
@@ -1020,7 +1020,7 @@ public class Vala.GTypeModule : GErrorModule {
push_function (function);
- ccode.add_declaration (cl.get_cname()+"*", new CCodeVariableDeclarator ("old"));
+ ccode.add_declaration (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" ));
@@ -1103,14 +1103,14 @@ public class Vala.GTypeModule : GErrorModule {
push_context (base_init_context);
var base_init = new CCodeFunction ("%s_base_init".printf (cl.get_lower_case_cname (null)), "void");
- base_init.add_parameter (new CCodeParameter ("klass", "%sClass *".printf (cl.get_cname ())));
+ base_init.add_parameter (new CCodeParameter ("klass", "%sClass *".printf (get_ccode_name (cl))));
base_init.modifiers = CCodeModifiers.STATIC;
push_function (base_init);
if (!context.require_glib_version (2, 24) && cl.has_class_private_fields) {
- ccode.add_declaration ("%sClassPrivate *".printf (cl.get_cname ()), new CCodeVariableDeclarator ("priv"));
- ccode.add_declaration ("%sClassPrivate *".printf (cl.get_cname ()), new CCodeVariableDeclarator ("parent_priv", new CCodeConstant ("NULL")));
+ ccode.add_declaration ("%sClassPrivate *".printf (get_ccode_name (cl)), new CCodeVariableDeclarator ("priv"));
+ ccode.add_declaration ("%sClassPrivate *".printf (get_ccode_name (cl)), new CCodeVariableDeclarator ("parent_priv", new CCodeConstant ("NULL")));
ccode.add_declaration ("GType", new CCodeVariableDeclarator ("parent_type"));
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_parent"));
@@ -1128,7 +1128,7 @@ public class Vala.GTypeModule : GErrorModule {
ccode.close ();
ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_slice_new0"));
- ccall.add_argument (new CCodeIdentifier ("%sClassPrivate".printf(cl.get_cname())));
+ ccall.add_argument (new CCodeIdentifier ("%sClassPrivate".printf(get_ccode_name (cl))));
ccode.add_assignment (new CCodeIdentifier ("priv"), ccall);
cfile.add_include ("string.h");
@@ -1137,7 +1137,7 @@ public class Vala.GTypeModule : GErrorModule {
ccall = new CCodeFunctionCall (new CCodeIdentifier ("memcpy"));
ccall.add_argument (new CCodeIdentifier ("priv"));
ccall.add_argument (new CCodeIdentifier ("parent_priv"));
- ccall.add_argument (new CCodeIdentifier ("sizeof (%sClassPrivate)".printf(cl.get_cname())));
+ ccall.add_argument (new CCodeIdentifier ("sizeof (%sClassPrivate)".printf(get_ccode_name (cl))));
ccode.add_expression (ccall);
ccode.close ();
@@ -1164,7 +1164,7 @@ public class Vala.GTypeModule : GErrorModule {
push_context (class_init_context);
var func = new CCodeFunction ("%s_class_init".printf (cl.get_lower_case_cname (null)));
- func.add_parameter (new CCodeParameter ("klass", "%sClass *".printf (cl.get_cname ())));
+ func.add_parameter (new CCodeParameter ("klass", "%sClass *".printf (get_ccode_name (cl))));
func.modifiers = CCodeModifiers.STATIC;
CCodeFunctionCall ccall;
@@ -1202,7 +1202,7 @@ public class Vala.GTypeModule : GErrorModule {
if (cl.has_private_fields || cl.get_type_parameters ().size > 0) {
ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_class_add_private"));
ccall.add_argument (new CCodeIdentifier ("klass"));
- ccall.add_argument (new CCodeConstant ("sizeof (%sPrivate)".printf (cl.get_cname ())));
+ ccall.add_argument (new CCodeConstant ("sizeof (%sPrivate)".printf (get_ccode_name (cl))));
ccode.add_expression (ccall);
}
@@ -1309,7 +1309,7 @@ public class Vala.GTypeModule : GErrorModule {
var ciface = new CCodeIdentifier ("iface");
CCodeExpression cfunc;
if (m.is_abstract || m.is_virtual) {
- cfunc = new CCodeIdentifier (m.get_cname ());
+ cfunc = new CCodeIdentifier (get_ccode_name (m));
} else {
cfunc = new CCodeIdentifier (m.get_real_cname ());
}
@@ -1347,7 +1347,7 @@ public class Vala.GTypeModule : GErrorModule {
generate_method_declaration (base_method, cfile);
- CCodeExpression cfunc = new CCodeIdentifier (base_method.get_cname ());
+ CCodeExpression cfunc = new CCodeIdentifier (get_ccode_name (base_method));
cfunc = cast_method_pointer (base_method, cfunc, iface);
var ciface = new CCodeIdentifier ("iface");
ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, m.vfunc_name), cfunc);
@@ -1419,7 +1419,7 @@ public class Vala.GTypeModule : GErrorModule {
if (base_property.get_accessor != null) {
generate_property_accessor_declaration (base_property.get_accessor, cfile);
- string cname = base_property.get_accessor.get_cname ();
+ string cname = get_ccode_name (base_property.get_accessor);
CCodeExpression cfunc = new CCodeIdentifier (cname);
cfunc = cast_property_accessor_pointer (prop.get_accessor, cfunc, iface);
ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, "get_%s".printf (prop.name)), cfunc);
@@ -1427,7 +1427,7 @@ public class Vala.GTypeModule : GErrorModule {
if (base_property.set_accessor != null) {
generate_property_accessor_declaration (base_property.set_accessor, cfile);
- string cname = base_property.set_accessor.get_cname ();
+ string cname = get_ccode_name (base_property.set_accessor);
CCodeExpression cfunc = new CCodeIdentifier (cname);
cfunc = cast_property_accessor_pointer (prop.set_accessor, cfunc, iface);
ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, "set_%s".printf (prop.name)), cfunc);
@@ -1442,21 +1442,21 @@ public class Vala.GTypeModule : GErrorModule {
CCodeExpression cast_property_accessor_pointer (PropertyAccessor acc, CCodeExpression cfunc, ObjectTypeSymbol base_type) {
string cast;
if (acc.readable && acc.value_type.is_real_non_null_struct_type ()) {
- cast = "void (*) (%s *, %s *)".printf (base_type.get_cname (), acc.value_type.get_cname ());
+ cast = "void (*) (%s *, %s *)".printf (get_ccode_name (base_type), get_ccode_name (acc.value_type));
} else if (acc.readable) {
- cast = "%s (*) (%s *)".printf (acc.value_type.get_cname (), base_type.get_cname ());
+ cast = "%s (*) (%s *)".printf (get_ccode_name (acc.value_type), get_ccode_name (base_type));
} else if (acc.value_type.is_real_non_null_struct_type ()) {
- cast = "void (*) (%s *, %s *)".printf (base_type.get_cname (), acc.value_type.get_cname ());
+ cast = "void (*) (%s *, %s *)".printf (get_ccode_name (base_type), get_ccode_name (acc.value_type));
} else {
- cast = "void (*) (%s *, %s)".printf (base_type.get_cname (), acc.value_type.get_cname ());
+ cast = "void (*) (%s *, %s)".printf (get_ccode_name (base_type), get_ccode_name (acc.value_type));
}
return new CCodeCastExpression (cfunc, cast);
}
CCodeExpression cast_method_pointer (Method m, CCodeExpression cfunc, ObjectTypeSymbol base_type) {
// Cast the function pointer to match the interface
- string cast = m.return_type.get_cname () + " (*)";
- string cast_args = base_type.get_cname () + "*";
+ string cast = get_ccode_name (m.return_type) + " (*)";
+ string cast_args = get_ccode_name (base_type) + "*";
var vdeclarator = new CCodeFunctionDeclarator (m.vfunc_name);
var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
@@ -1489,7 +1489,7 @@ public class Vala.GTypeModule : GErrorModule {
push_context (instance_init_context);
var func = new CCodeFunction ("%s_instance_init".printf (cl.get_lower_case_cname (null)));
- func.add_parameter (new CCodeParameter ("self", "%s *".printf (cl.get_cname ())));
+ func.add_parameter (new CCodeParameter ("self", "%s *".printf (get_ccode_name (cl))));
func.modifiers = CCodeModifiers.STATIC;
push_function (func);
@@ -1519,7 +1519,7 @@ public class Vala.GTypeModule : GErrorModule {
var function = new CCodeFunction ("%s_class_finalize".printf (cl.get_lower_case_cname (null)), "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("klass", cl.get_cname () + "Class *"));
+ function.add_parameter (new CCodeParameter ("klass", get_ccode_name (cl) + "Class *"));
push_function (function);
@@ -1541,7 +1541,7 @@ public class Vala.GTypeModule : GErrorModule {
var function = new CCodeFunction ("%s_base_finalize".printf (cl.get_lower_case_cname (null)), "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("klass", cl.get_cname () + "Class *"));
+ function.add_parameter (new CCodeParameter ("klass", get_ccode_name (cl) + "Class *"));
push_function (function);
@@ -1558,7 +1558,7 @@ public class Vala.GTypeModule : GErrorModule {
if (!context.require_glib_version (2, 24) && cl.has_class_private_fields) {
ccode.open_block ();
- var cdecl = new CCodeDeclaration ("%sClassPrivate *".printf (cl.get_cname ()));
+ var cdecl = new CCodeDeclaration ("%sClassPrivate *".printf (get_ccode_name (cl)));
cdecl.add_declarator (new CCodeVariableDeclarator ("priv"));
ccode.add_statement (cdecl);
@@ -1567,7 +1567,7 @@ public class Vala.GTypeModule : GErrorModule {
ccode.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("priv"), ccall)));
ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_slice_free"));
- ccall.add_argument (new CCodeIdentifier ("%sClassPrivate".printf (cl.get_cname ())));
+ ccall.add_argument (new CCodeIdentifier ("%sClassPrivate".printf (get_ccode_name (cl))));
ccall.add_argument (new CCodeIdentifier ("priv"));
ccode.add_statement (new CCodeExpressionStatement (ccall));
@@ -1590,14 +1590,14 @@ public class Vala.GTypeModule : GErrorModule {
}
var func = new CCodeFunction ("%s_finalize".printf (cl.get_lower_case_cname (null)));
- func.add_parameter (new CCodeParameter ("obj", fundamental_class.get_cname () + "*"));
+ func.add_parameter (new CCodeParameter ("obj", get_ccode_name (fundamental_class) + "*"));
func.modifiers = CCodeModifiers.STATIC;
push_function (func);
CCodeFunctionCall ccall = generate_instance_cast (new CCodeIdentifier ("obj"), cl);
- ccode.add_declaration ("%s *".printf (cl.get_cname ()), new CCodeVariableDeclarator ("self"));
+ ccode.add_declaration ("%s *".printf (get_ccode_name (cl)), new CCodeVariableDeclarator ("self"));
ccode.add_assignment (new CCodeIdentifier ("self"), ccall);
} else {
var function = new CCodeFunction (cl.get_lower_case_cprefix () + "free", "void");
@@ -1605,7 +1605,7 @@ public class Vala.GTypeModule : GErrorModule {
function.modifiers = CCodeModifiers.STATIC;
}
- function.add_parameter (new CCodeParameter ("self", cl.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("self", get_ccode_name (cl) + "*"));
push_function (function);
}
@@ -1645,7 +1645,7 @@ public class Vala.GTypeModule : GErrorModule {
cfile.add_function_declaration (instance_finalize_context.ccode);
} else {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_slice_free"));
- ccall.add_argument (new CCodeIdentifier (cl.get_cname ()));
+ ccall.add_argument (new CCodeIdentifier (get_ccode_name (cl)));
ccall.add_argument (new CCodeIdentifier ("self"));
instance_finalize_context.ccode.add_expression (ccall);
}
@@ -1834,7 +1834,7 @@ public class Vala.GTypeModule : GErrorModule {
}
public override void generate_interface_declaration (Interface iface, CCodeFile decl_space) {
- if (add_symbol_declaration (decl_space, iface, iface.get_cname ())) {
+ if (add_symbol_declaration (decl_space, iface, get_ccode_name (iface))) {
return;
}
@@ -1854,7 +1854,7 @@ public class Vala.GTypeModule : GErrorModule {
var macro = "(%s_get_type ())".printf (iface.get_lower_case_cname (null));
decl_space.add_type_declaration (new CCodeMacroReplacement (iface.get_type_id (), macro));
- macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (iface.get_type_id (), iface.get_cname ());
+ macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (iface.get_type_id (), get_ccode_name (iface));
decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(obj)".printf (iface.get_upper_case_cname (null)), macro));
macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (iface.get_type_id ());
@@ -1864,7 +1864,7 @@ public class Vala.GTypeModule : GErrorModule {
decl_space.add_type_declaration (new CCodeMacroReplacement ("%s_GET_INTERFACE(obj)".printf (iface.get_upper_case_cname (null)), macro));
decl_space.add_type_declaration (new CCodeNewline ());
- decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (iface.get_cname ()), new CCodeVariableDeclarator (iface.get_cname ())));
+ decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (get_ccode_name (iface)), new CCodeVariableDeclarator (get_ccode_name (iface))));
decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (type_struct.name), new CCodeVariableDeclarator (iface.get_type_cname ())));
type_struct.add_field ("GTypeInterface", "parent_iface");
@@ -1890,18 +1890,18 @@ public class Vala.GTypeModule : GErrorModule {
bool returns_real_struct = prop.property_type.is_real_non_null_struct_type ();
var this_type = new ObjectType (t);
- var cselfparam = new CCodeParameter ("self", this_type.get_cname ());
+ var cselfparam = new CCodeParameter ("self", get_ccode_name (this_type));
if (prop.get_accessor != null) {
var vdeclarator = new CCodeFunctionDeclarator ("get_%s".printf (prop.name));
vdeclarator.add_parameter (cselfparam);
string creturn_type;
if (returns_real_struct) {
- var cvalueparam = new CCodeParameter ("value", prop.get_accessor.value_type.get_cname () + "*");
+ var cvalueparam = new CCodeParameter ("value", get_ccode_name (prop.get_accessor.value_type) + "*");
vdeclarator.add_parameter (cvalueparam);
creturn_type = "void";
} else {
- creturn_type = prop.get_accessor.value_type.get_cname ();
+ creturn_type = get_ccode_name (prop.get_accessor.value_type);
}
var array_type = prop.property_type as ArrayType;
@@ -1919,10 +1919,10 @@ 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", prop.set_accessor.value_type.get_cname () + "*");
+ var cvalueparam = new CCodeParameter ("value", get_ccode_name (prop.set_accessor.value_type) + "*");
vdeclarator.add_parameter (cvalueparam);
} else {
- var cvalueparam = new CCodeParameter ("value", prop.set_accessor.value_type.get_cname ());
+ var cvalueparam = new CCodeParameter ("value", get_ccode_name (prop.set_accessor.value_type));
vdeclarator.add_parameter (cvalueparam);
}
@@ -1949,9 +1949,9 @@ public class Vala.GTypeModule : GErrorModule {
public override void visit_interface (Interface iface) {
push_context (new EmitContext (iface));
- if (iface.get_cname().length < 3) {
+ if (get_ccode_name (iface).length < 3) {
iface.error = true;
- Report.error (iface.source_reference, "Interface name `%s' is too short".printf (iface.get_cname ()));
+ Report.error (iface.source_reference, "Interface name `%s' is too short".printf (get_ccode_name (iface)));
return;
}
@@ -1983,13 +1983,13 @@ public class Vala.GTypeModule : GErrorModule {
push_context (new EmitContext (iface));
var base_init = new CCodeFunction ("%s_base_init".printf (iface.get_lower_case_cname (null)), "void");
- base_init.add_parameter (new CCodeParameter ("iface", "%sIface *".printf (iface.get_cname ())));
+ base_init.add_parameter (new CCodeParameter ("iface", "%sIface *".printf (get_ccode_name (iface))));
base_init.modifiers = CCodeModifiers.STATIC;
push_function (base_init);
/* make sure not to run the initialization code twice */
- ccode.add_declaration (bool_type.get_cname (), new CCodeVariableDeclarator ("initialized", new CCodeConstant ("FALSE")), CCodeModifiers.STATIC);
+ ccode.add_declaration (get_ccode_name (bool_type), new CCodeVariableDeclarator ("initialized", new CCodeConstant ("FALSE")), CCodeModifiers.STATIC);
ccode.open_if (new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, new CCodeIdentifier ("initialized")));
ccode.add_assignment (new CCodeIdentifier ("initialized"), new CCodeConstant ("TRUE"));
diff --git a/codegen/valagvariantmodule.vala b/codegen/valagvariantmodule.vala
index 91b614a..1d12dc9 100644
--- a/codegen/valagvariantmodule.vala
+++ b/codegen/valagvariantmodule.vala
@@ -213,7 +213,7 @@ public class Vala.GVariantModule : GAsyncModule {
public CCodeFunction generate_enum_from_string_function_declaration (Enum en) {
var from_string_name = "%s_from_string".printf (en.get_lower_case_cname (null));
- var from_string_func = new CCodeFunction (from_string_name, en.get_cname ());
+ var from_string_func = new CCodeFunction (from_string_name, get_ccode_name (en));
from_string_func.add_parameter (new CCodeParameter ("str", "const char*"));
from_string_func.add_parameter (new CCodeParameter ("error", "GError**"));
@@ -223,13 +223,13 @@ public class Vala.GVariantModule : GAsyncModule {
public CCodeFunction generate_enum_from_string_function (Enum en) {
var from_string_name = "%s_from_string".printf (en.get_lower_case_cname (null));
- var from_string_func = new CCodeFunction (from_string_name, en.get_cname ());
+ var from_string_func = new CCodeFunction (from_string_name, get_ccode_name (en));
from_string_func.add_parameter (new CCodeParameter ("str", "const char*"));
from_string_func.add_parameter (new CCodeParameter ("error", "GError**"));
push_function (from_string_func);
- ccode.add_declaration (en.get_cname (), new CCodeVariableDeclarator.zero ("value", new CCodeConstant ("0")));
+ ccode.add_declaration (get_ccode_name (en), new CCodeVariableDeclarator.zero ("value", new CCodeConstant ("0")));
bool firstif = true;
foreach (EnumValue enum_value in en.get_values ()) {
@@ -244,7 +244,7 @@ public class Vala.GVariantModule : GAsyncModule {
} else {
ccode.else_if (cond);
}
- ccode.add_assignment (new CCodeIdentifier ("value"), new CCodeIdentifier (enum_value.get_cname ()));
+ ccode.add_assignment (new CCodeIdentifier ("value"), new CCodeIdentifier (get_ccode_name (enum_value)));
}
ccode.add_else ();
@@ -252,7 +252,7 @@ public class Vala.GVariantModule : GAsyncModule {
set_error.add_argument (new CCodeIdentifier ("error"));
set_error.add_argument (new CCodeIdentifier ("G_DBUS_ERROR"));
set_error.add_argument (new CCodeIdentifier ("G_DBUS_ERROR_INVALID_ARGS"));
- set_error.add_argument (new CCodeConstant ("\"Invalid value for enum `%s'\"".printf (en.get_cname ())));
+ set_error.add_argument (new CCodeConstant ("\"Invalid value for enum `%s'\"".printf (get_ccode_name (en))));
ccode.add_expression (set_error);
ccode.close ();
@@ -282,11 +282,11 @@ public class Vala.GVariantModule : GAsyncModule {
string temp_name = "_tmp%d_".printf (next_temp_var_id++);
var new_call = new CCodeFunctionCall (new CCodeIdentifier ("g_new"));
- new_call.add_argument (new CCodeIdentifier (array_type.element_type.get_cname ()));
+ new_call.add_argument (new CCodeIdentifier (get_ccode_name (array_type.element_type)));
// add one extra element for NULL-termination
new_call.add_argument (new CCodeConstant ("5"));
- ccode.add_declaration (array_type.get_cname (), new CCodeVariableDeclarator (temp_name, new_call));
+ ccode.add_declaration (get_ccode_name (array_type), new CCodeVariableDeclarator (temp_name, new_call));
ccode.add_declaration ("int", new CCodeVariableDeclarator (temp_name + "_length", new CCodeConstant ("0")));
ccode.add_declaration ("int", new CCodeVariableDeclarator (temp_name + "_size", new CCodeConstant ("4")));
@@ -334,7 +334,7 @@ public class Vala.GVariantModule : GAsyncModule {
ccode.add_assignment (new CCodeIdentifier (temp_name + "_size"), new_size);
var renew_call = new CCodeFunctionCall (new CCodeIdentifier ("g_renew"));
- renew_call.add_argument (new CCodeIdentifier (array_type.element_type.get_cname ()));
+ renew_call.add_argument (new CCodeIdentifier (get_ccode_name (array_type.element_type)));
renew_call.add_argument (new CCodeIdentifier (temp_name));
// add one extra element for NULL-termination
renew_call.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier (temp_name + "_size"), new CCodeConstant ("1")));
@@ -362,7 +362,7 @@ public class Vala.GVariantModule : GAsyncModule {
string temp_name = "_tmp%d_".printf (next_temp_var_id++);
string subiter_name = "_tmp%d_".printf (next_temp_var_id++);
- ccode.add_declaration (st.get_cname (), new CCodeVariableDeclarator (temp_name));
+ ccode.add_declaration (get_ccode_name (st), new CCodeVariableDeclarator (temp_name));
ccode.add_declaration ("GVariantIter", new CCodeVariableDeclarator (subiter_name));
var iter_call = new CCodeFunctionCall (new CCodeIdentifier ("g_variant_iter_init"));
@@ -379,7 +379,7 @@ public class Vala.GVariantModule : GAsyncModule {
field_found = true;
- read_expression (f.variable_type, new CCodeIdentifier (subiter_name), new CCodeMemberAccess (new CCodeIdentifier (temp_name), f.get_cname ()), f);
+ read_expression (f.variable_type, new CCodeIdentifier (subiter_name), new CCodeMemberAccess (new CCodeIdentifier (temp_name), get_ccode_name (f)), f);
}
if (!field_found) {
@@ -472,7 +472,7 @@ public class Vala.GVariantModule : GAsyncModule {
result = deserialize_struct (st, variant_expr);
if (result != null && type.nullable) {
var csizeof = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- csizeof.add_argument (new CCodeIdentifier (st.get_cname ()));
+ csizeof.add_argument (new CCodeIdentifier (get_ccode_name (st)));
var cdup = new CCodeFunctionCall (new CCodeIdentifier ("g_memdup"));
cdup.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, result));
cdup.add_argument (csizeof);
@@ -540,7 +540,7 @@ public class Vala.GVariantModule : GAsyncModule {
var to_string_name = "%s_to_string".printf (en.get_lower_case_cname (null));
var to_string_func = new CCodeFunction (to_string_name, "const char*");
- to_string_func.add_parameter (new CCodeParameter ("value", en.get_cname ()));
+ to_string_func.add_parameter (new CCodeParameter ("value", get_ccode_name (en)));
return to_string_func;
}
@@ -549,7 +549,7 @@ public class Vala.GVariantModule : GAsyncModule {
var to_string_name = "%s_to_string".printf (en.get_lower_case_cname (null));
var to_string_func = new CCodeFunction (to_string_name, "const char*");
- to_string_func.add_parameter (new CCodeParameter ("value", en.get_cname ()));
+ to_string_func.add_parameter (new CCodeParameter ("value", get_ccode_name (en)));
push_function (to_string_func);
@@ -558,7 +558,7 @@ public class Vala.GVariantModule : GAsyncModule {
ccode.open_switch (new CCodeIdentifier ("value"));
foreach (EnumValue enum_value in en.get_values ()) {
string dbus_value = get_dbus_value (enum_value, enum_value.name);
- ccode.add_case (new CCodeIdentifier (enum_value.get_cname ()));
+ ccode.add_case (new CCodeIdentifier (get_ccode_name (enum_value)));
ccode.add_assignment (new CCodeIdentifier ("str"), new CCodeConstant ("\"%s\"".printf (dbus_value)));
ccode.add_break ();
}
@@ -578,7 +578,7 @@ public class Vala.GVariantModule : GAsyncModule {
CCodeExpression? serialize_array (ArrayType array_type, CCodeExpression array_expr) {
string array_iter_name = "_tmp%d_".printf (next_temp_var_id++);
- ccode.add_declaration (array_type.get_cname (), new CCodeVariableDeclarator (array_iter_name));
+ ccode.add_declaration (get_ccode_name (array_type), new CCodeVariableDeclarator (array_iter_name));
ccode.add_assignment (new CCodeIdentifier (array_iter_name), array_expr);
return serialize_array_dim (array_type, 1, array_expr, new CCodeIdentifier (array_iter_name));
@@ -648,7 +648,7 @@ public class Vala.GVariantModule : GAsyncModule {
field_found = true;
- write_expression (f.variable_type, new CCodeIdentifier (builder_name), new CCodeMemberAccess (struct_expr, f.get_cname ()), f);
+ write_expression (f.variable_type, new CCodeIdentifier (builder_name), new CCodeMemberAccess (struct_expr, get_ccode_name (f)), f);
}
if (!field_found) {
@@ -696,8 +696,8 @@ public class Vala.GVariantModule : GAsyncModule {
ccode.open_while (iter_next_call);
- ccode.add_declaration (key_type.get_cname (), new CCodeVariableDeclarator ("_key"));
- ccode.add_declaration (value_type.get_cname (), new CCodeVariableDeclarator ("_value"));
+ ccode.add_declaration (get_ccode_name (key_type), new CCodeVariableDeclarator ("_key"));
+ ccode.add_declaration (get_ccode_name (value_type), new CCodeVariableDeclarator ("_value"));
ccode.add_assignment (new CCodeIdentifier ("_key"), convert_from_generic_pointer (new CCodeIdentifier (key_name), key_type));
ccode.add_assignment (new CCodeIdentifier ("_value"), convert_from_generic_pointer (new CCodeIdentifier (value_name), value_type));
diff --git a/codegen/valatyperegisterfunction.vala b/codegen/valatyperegisterfunction.vala
index e3f38ad..f6d2b55 100644
--- a/codegen/valatyperegisterfunction.vala
+++ b/codegen/valatyperegisterfunction.vala
@@ -133,7 +133,7 @@ public abstract class Vala.TypeRegisterFunction {
quark_reg_call = new CCodeFunctionCall (new CCodeIdentifier ("g_quark_from_static_string"));
}
- quark_reg_call.add_argument (new CCodeConstant ("\"Vala%sClassPrivate\"".printf (get_type_declaration ().get_cname ())));
+ quark_reg_call.add_argument (new CCodeConstant ("\"Vala%sClassPrivate\"".printf (CCodeBaseModule.get_ccode_name (get_type_declaration ()))));
type_init.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("_vala_%s_class_private_quark".printf (get_type_declaration ().get_lower_case_cname ())), quark_reg_call)));
}
@@ -159,7 +159,7 @@ public abstract class Vala.TypeRegisterFunction {
reg_call.add_argument (new CCodeIdentifier ("module"));
reg_call.add_argument (new CCodeIdentifier (get_parent_type_name ()));
}
- reg_call.add_argument (new CCodeConstant ("\"%s\"".printf (get_type_declaration ().get_cname ())));
+ reg_call.add_argument (new CCodeConstant ("\"%s\"".printf (CCodeBaseModule.get_ccode_name (get_type_declaration ()))));
if (get_type_declaration () is Struct) {
var st = (Struct) get_type_declaration ();
reg_call.add_argument (new CCodeCastExpression (new CCodeIdentifier (st.get_dup_function ()), "GBoxedCopyFunc"));
@@ -171,8 +171,8 @@ public abstract class Vala.TypeRegisterFunction {
CCodeInitializerList clist_ev = null;
foreach (EnumValue ev in en.get_values ()) {
clist_ev = new CCodeInitializerList ();
- clist_ev.append (new CCodeConstant (ev.get_cname ()));
- clist_ev.append (new CCodeIdentifier ("\"%s\"".printf (ev.get_cname ())));
+ clist_ev.append (new CCodeConstant (CCodeBaseModule.get_ccode_name (ev)));
+ clist_ev.append (new CCodeIdentifier ("\"%s\"".printf (CCodeBaseModule.get_ccode_name (ev))));
clist_ev.append (ev.get_canonical_cconstant ());
clist.append (clist_ev);
}
@@ -218,7 +218,7 @@ public abstract class Vala.TypeRegisterFunction {
add_class_private_call = new CCodeFunctionCall (new CCodeIdentifier ("g_type_add_class_private"));
add_class_private_call.add_argument (new CCodeIdentifier (type_id_name));
- add_class_private_call.add_argument (new CCodeIdentifier ("sizeof (%sClassPrivate)".printf (get_type_declaration ().get_cname ())));
+ add_class_private_call.add_argument (new CCodeIdentifier ("sizeof (%sClassPrivate)".printf (CCodeBaseModule.get_ccode_name (get_type_declaration ()))));
type_init.add_statement (new CCodeExpressionStatement (add_class_private_call));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]