[vala/wip/attributes: 35/39] codegen: Use CCodeAttribute instead of C specific methods of code nodes
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 35/39] codegen: Use CCodeAttribute instead of C specific methods of code nodes
- Date: Mon, 1 Aug 2011 12:32:02 +0000 (UTC)
commit ffbd64d92ee93ad1dfbc1ebb179973a982552447
Author: Luca Bruno <lucabru src gnome org>
Date: Wed Jul 6 09:55:16 2011 +0200
codegen: Use CCodeAttribute instead of C specific methods of code nodes
codegen/valaccodearraymodule.vala | 50 +-
codegen/valaccodeassignmentmodule.vala | 2 +-
codegen/valaccodebasemodule.vala | 824 +++++++++++++++++++---------
codegen/valaccodecontrolflowmodule.vala | 2 +-
codegen/valaccodedelegatemodule.vala | 94 ++--
codegen/valaccodememberaccessmodule.vala | 118 ++--
codegen/valaccodemethodcallmodule.vala | 138 +++---
codegen/valaccodemethodmodule.vala | 115 ++--
codegen/valaccodestructmodule.vala | 80 ++--
codegen/valaclassregisterfunction.vala | 42 +-
codegen/valactype.vala | 4 -
codegen/valadovaarraymodule.vala | 2 +-
codegen/valadovaassignmentmodule.vala | 2 +-
codegen/valadovabasemodule.vala | 212 +++++---
codegen/valadovadelegatemodule.vala | 40 +-
codegen/valadovaerrormodule.vala | 10 +-
codegen/valadovamemberaccessmodule.vala | 34 +-
codegen/valadovamethodcallmodule.vala | 12 +-
codegen/valadovaobjectmodule.vala | 336 ++++++------
codegen/valadovastructmodule.vala | 12 +-
codegen/valadovavaluemodule.vala | 96 ++--
codegen/valagasyncmodule.vala | 56 +-
codegen/valagdbusclientmodule.vala | 84 ++--
codegen/valagdbusmodule.vala | 38 +-
codegen/valagdbusservermodule.vala | 140 +++---
codegen/valagerrormodule.vala | 30 +-
codegen/valagobjectmodule.vala | 72 ++--
codegen/valagsignalmodule.vala | 90 +--
codegen/valagtypemodule.vala | 470 ++++++++--------
codegen/valagvariantmodule.vala | 78 +--
codegen/valainterfaceregisterfunction.vala | 8 +-
codegen/valatyperegisterfunction.vala | 24 +-
32 files changed, 1819 insertions(+), 1496 deletions(-)
---
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index 9a2afdd..8e1d09c 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;
@@ -90,7 +90,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);
}
@@ -114,8 +114,8 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
}
public override string get_parameter_array_length_cname (Parameter param, int dim) {
- if (param.has_array_length_cname) {
- return param.get_array_length_cname ();
+ if (get_ccode_array_length_name (param) != null) {
+ return get_ccode_array_length_name (param);
} else {
return get_array_length_cname (get_variable_cname (param.name), dim);
}
@@ -215,7 +215,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;
@@ -223,7 +223,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);
@@ -473,10 +473,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) {
@@ -493,7 +493,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
@@ -502,7 +502,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"));
@@ -520,7 +520,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);
@@ -549,8 +549,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
@@ -574,7 +574,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);
@@ -601,13 +601,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) {
@@ -625,7 +625,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
@@ -705,7 +705,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 += "*";
@@ -717,15 +717,15 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
generate_type_declaration (array_type.element_type, decl_space);
- cparam_map.set (get_param_pos (param.cparameter_position), main_cparam);
+ cparam_map.set (get_param_pos (get_ccode_pos (param)), main_cparam);
if (carg_map != null) {
- carg_map.set (get_param_pos (param.cparameter_position), get_variable_cexpression (param.name));
+ carg_map.set (get_param_pos (get_ccode_pos (param)), get_variable_cexpression (param.name));
}
- if (!param.no_array_length) {
+ if (get_ccode_array_length (param)) {
string length_ctype = "int";
- if (param.array_length_type != null) {
- length_ctype = param.array_length_type;
+ if (get_ccode_array_length_type (param) != null) {
+ length_ctype = get_ccode_array_length_type (param);
}
if (param.direction != ParameterDirection.IN) {
length_ctype = "%s*".printf (length_ctype);
@@ -733,9 +733,9 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
for (int dim = 1; dim <= array_type.rank; dim++) {
var cparam = new CCodeParameter (get_parameter_array_length_cname (param, dim), length_ctype);
- cparam_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), cparam);
+ cparam_map.set (get_param_pos (get_ccode_array_length_pos (param) + 0.01 * dim), cparam);
if (carg_map != null) {
- carg_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), get_variable_cexpression (cparam.name));
+ carg_map.set (get_param_pos (get_ccode_array_length_pos (param) + 0.01 * dim), get_variable_cexpression (cparam.name));
}
}
}
diff --git a/codegen/valaccodeassignmentmodule.vala b/codegen/valaccodeassignmentmodule.vala
index e2bc0ce..47985a1 100644
--- a/codegen/valaccodeassignmentmodule.vala
+++ b/codegen/valaccodeassignmentmodule.vala
@@ -101,7 +101,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 4f8c1e9..0feed1b 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -309,6 +309,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public Map<string,string> variable_name_map { get { return emit_context.variable_name_map; } }
+ public static int ccode_attribute_cache_index = CodeNode.get_attribute_cache_index ();
+
public CCodeBaseModule () {
predefined_marshal_set = new HashSet<string> (str_hash, str_equal);
predefined_marshal_set.add ("VOID:VOID");
@@ -574,7 +576,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
if (sym.external_package || (!decl_space.is_header && CodeContext.get ().use_header && !sym.is_internal_symbol ())) {
// add appropriate include file
- foreach (string header_filename in sym.get_cheader_filenames ()) {
+ foreach (string header_filename in get_ccode_header_filenames (sym).split (",")) {
decl_space.add_include (header_filename, !sym.external_package);
}
// declaration complete
@@ -588,7 +590,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public CCodeIdentifier get_value_setter_function (DataType type_reference) {
var array_type = type_reference as ArrayType;
if (type_reference.data_type != null) {
- return new CCodeIdentifier (type_reference.data_type.get_set_value_function ());
+ return new CCodeIdentifier (get_ccode_set_value_function (type_reference.data_type));
} else if (array_type != null && array_type.element_type.data_type == string_type.data_type) {
// G_TYPE_STRV
return new CCodeIdentifier ("g_value_set_boxed");
@@ -600,7 +602,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public CCodeIdentifier get_value_taker_function (DataType type_reference) {
var array_type = type_reference as ArrayType;
if (type_reference.data_type != null) {
- return new CCodeIdentifier (type_reference.data_type.get_take_value_function ());
+ return new CCodeIdentifier (get_ccode_take_value_function (type_reference.data_type));
} else if (array_type != null && array_type.element_type.data_type == string_type.data_type) {
// G_TYPE_STRV
return new CCodeIdentifier ("g_value_take_boxed");
@@ -612,7 +614,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
CCodeIdentifier get_value_getter_function (DataType type_reference) {
var array_type = type_reference as ArrayType;
if (type_reference.data_type != null) {
- return new CCodeIdentifier (type_reference.data_type.get_get_value_function ());
+ return new CCodeIdentifier (get_ccode_get_value_function (type_reference.data_type));
} else if (array_type != null && array_type.element_type.data_type == string_type.data_type) {
// G_TYPE_STRV
return new CCodeIdentifier ("g_value_get_boxed");
@@ -696,11 +698,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;
@@ -708,14 +710,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);
@@ -724,16 +726,16 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
decl_space.add_type_definition (cenum);
decl_space.add_type_definition (new CCodeNewline ());
- if (!en.has_type_id) {
+ if (!get_ccode_has_type_id (en)) {
return true;
}
decl_space.add_type_declaration (new CCodeNewline ());
- var macro = "(%s_get_type ())".printf (en.get_lower_case_cname (null));
- decl_space.add_type_declaration (new CCodeMacroReplacement (en.get_type_id (), macro));
+ var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (en, null));
+ decl_space.add_type_declaration (new CCodeMacroReplacement (get_ccode_type_id (en), macro));
- var fun_name = "%s_get_type".printf (en.get_lower_case_cname (null));
+ var fun_name = "%s_get_type".printf (get_ccode_lower_case_name (en, null));
var regfun = new CCodeFunction (fun_name, "GType");
regfun.attributes = "G_GNUC_CONST";
@@ -783,15 +785,15 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
} else if (m.is_class_member ()) {
TypeSymbol parent = (TypeSymbol)m.parent_symbol;
- var get_class_private_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf(parent.get_upper_case_cname ())));
+ var get_class_private_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf(get_ccode_upper_case_name (parent))));
get_class_private_call.add_argument (new CCodeIdentifier ("klass"));
l = new CCodeMemberAccess.pointer (get_class_private_call, get_symbol_lock_name (m.name));
} else {
- l = new CCodeIdentifier (get_symbol_lock_name ("%s_%s".printf(m.parent_symbol.get_lower_case_cname (), m.name)));
+ l = new CCodeIdentifier (get_symbol_lock_name ("%s_%s".printf(get_ccode_lower_case_name (m.parent_symbol), m.name)));
}
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 ();
@@ -812,7 +814,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;
}
@@ -823,7 +825,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var initializer_list = c.value as InitializerList;
if (initializer_list != null) {
- var cdecl = new CCodeDeclaration (c.type_reference.get_const_cname ());
+ var cdecl = new CCodeDeclaration (get_ccode_const_name (c.type_reference));
var arr = "";
if (c.type_reference is ArrayType) {
arr = "[%d]".printf (initializer_list.size);
@@ -836,7 +838,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 {
@@ -845,7 +847,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);
}
}
@@ -861,7 +863,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
c.value.emit (this);
- string type_name = c.type_reference.get_const_cname ();
+ string type_name = get_ccode_const_name (c.type_reference);
string arr = "";
if (c.type_reference is ArrayType) {
arr = "[]";
@@ -874,7 +876,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);
} else {
generate_constant_declaration (c, cfile, true);
@@ -890,19 +892,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 {
@@ -915,8 +917,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 ()) {
@@ -927,15 +929,15 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
decl_space.add_type_member_declaration (flock);
}
- if (f.variable_type is ArrayType && !f.no_array_length) {
+ if (f.variable_type is ArrayType && get_ccode_array_length (f)) {
var array_type = (ArrayType) f.variable_type;
if (!array_type.fixed_length) {
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 {
@@ -950,7 +952,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 {
@@ -960,7 +962,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 {
@@ -983,16 +985,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) {
@@ -1004,7 +1006,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ccode.add_assignment (lhs, rhs);
- if (f.variable_type is ArrayType && !f.no_array_length &&
+ if (f.variable_type is ArrayType && get_ccode_array_length (f) &&
f.initializer is ArrayCreationExpression) {
var array_type = (ArrayType) f.variable_type;
var field_value = get_field_cvalue (f, load_this_parameter ((TypeSymbol) f.parent_symbol));
@@ -1045,11 +1047,11 @@ 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 ())));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf (get_ccode_upper_case_name (cl))));
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) {
@@ -1079,9 +1081,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) {
@@ -1109,15 +1111,15 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
cfile.add_type_member_declaration (var_def);
/* add array length fields where necessary */
- if (f.variable_type is ArrayType && !f.no_array_length) {
+ if (f.variable_type is ArrayType && get_ccode_array_length (f)) {
var array_type = (ArrayType) f.variable_type;
if (!array_type.fixed_length) {
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 {
@@ -1129,8 +1131,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);
}
@@ -1141,7 +1143,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 {
@@ -1151,7 +1153,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 {
@@ -1172,7 +1174,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);
@@ -1182,7 +1184,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ccode.add_assignment (lhs, rhs);
}
- if (f.variable_type is ArrayType && !f.no_array_length &&
+ if (f.variable_type is ArrayType && get_ccode_array_length (f) &&
f.initializer is ArrayCreationExpression) {
var array_type = (ArrayType) f.variable_type;
var field_value = get_field_cvalue (f, null);
@@ -1329,7 +1331,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;
}
@@ -1340,26 +1342,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 += "*";
}
@@ -1447,25 +1449,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) {
@@ -1501,11 +1503,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (prop.parent_symbol is Interface) {
var iface = (Interface) prop.parent_symbol;
- vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_INTERFACE".printf (iface.get_upper_case_cname (null))));
+ vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_INTERFACE".printf (get_ccode_upper_case_name (iface, null))));
} else {
var cl = (Class) prop.parent_symbol;
- vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (cl.get_upper_case_cname (null))));
+ vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (get_ccode_upper_case_name (cl, null))));
}
vcast.add_argument (new CCodeIdentifier ("self"));
@@ -1562,19 +1564,19 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
string cname;
if (is_virtual) {
if (acc.readable) {
- cname = "%s_real_get_%s".printf (t.get_lower_case_cname (null), prop.name);
+ cname = "%s_real_get_%s".printf (get_ccode_lower_case_name (t, null), prop.name);
} else {
- cname = "%s_real_set_%s".printf (t.get_lower_case_cname (null), prop.name);
+ cname = "%s_real_set_%s".printf (get_ccode_lower_case_name (t, 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;
@@ -1586,7 +1588,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);
}
@@ -1633,12 +1635,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"), true), this_type, acc)));
}
@@ -1650,11 +1652,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
// notify on property changes
if (is_gobject_property (prop) &&
- prop.notify &&
+ get_ccode_notify (prop) &&
(acc.writable || acc.construction)) {
var notify_call = new CCodeFunctionCall (new CCodeIdentifier ("g_object_notify"));
notify_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("self"), "GObject *"));
- notify_call.add_argument (prop.get_canonical_cconstant ());
+ notify_call.add_argument (get_property_canonical_cconstant (prop));
ccode.add_expression (notify_call);
}
@@ -1687,7 +1689,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 +1704,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var array_type = param.variable_type as ArrayType;
var deleg_type = param.variable_type as DelegateType;
- if (array_type != null && !param.no_array_length) {
+ if (array_type != null && get_ccode_array_length (param)) {
for (int dim = 1; dim <= array_type.rank; dim++) {
data.add_field ("gint", get_parameter_array_length_cname (param, dim));
}
@@ -1744,7 +1746,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) {
@@ -1767,7 +1769,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;
@@ -2069,7 +2071,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 {
@@ -2095,7 +2097,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 ());
@@ -2106,7 +2108,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) {
@@ -2241,7 +2243,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var cexpr = get_cvalue (expr);
- string ctype = field.get_ctype ();
+ string ctype = get_ccode_type (field);
if (ctype != null) {
cexpr = new CCodeCastExpression (cexpr, ctype);
}
@@ -2249,7 +2251,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
clist.append (cexpr);
var array_type = field.variable_type as ArrayType;
- if (array_type != null && !field.no_array_length && !field.array_null_terminated) {
+ if (array_type != null && get_ccode_array_length (field) && !get_ccode_array_null_terminated (field)) {
for (int dim = 1; dim <= array_type.rank; dim++) {
clist.append (get_array_length_cvalue (expr.target_value, dim));
}
@@ -2326,8 +2328,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return get_variable_cexpression (var_name);
}
} else {
- string type_id = type.get_type_id ();
- if (type_id == null) {
+ string type_id = get_ccode_type_id (type);
+ if (type_id == "") {
type_id = "G_TYPE_INVALID";
} else {
generate_type_declaration (type, cfile);
@@ -2342,26 +2344,26 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
} else if (type.data_type != null) {
string dup_function;
var cl = type.data_type as Class;
- if (type.data_type.is_reference_counting ()) {
- dup_function = type.data_type.get_ref_function ();
+ if (is_reference_counting (type.data_type)) {
+ dup_function = get_ccode_ref_function ((ObjectTypeSymbol) type.data_type);
if (type.data_type is Interface && dup_function == null) {
Report.error (source_reference, "missing class prerequisite for interface `%s', add GLib.Object to interface declaration if unsure".printf (type.data_type.get_full_name ()));
return null;
}
} else if (cl != null && cl.is_immutable) {
// allow duplicates of immutable instances as for example strings
- dup_function = type.data_type.get_dup_function ();
+ dup_function = get_ccode_dup_function (type.data_type);
if (dup_function == null) {
dup_function = "";
}
- } else if (cl != null && cl.is_gboxed) {
+ } else if (cl != null && get_ccode_is_gboxed (cl)) {
// allow duplicates of gboxed instances
dup_function = generate_dup_func_wrapper (type);
if (dup_function == null) {
dup_function = "";
}
} else if (type is ValueType) {
- dup_function = type.data_type.get_dup_function ();
+ dup_function = get_ccode_dup_function (type.data_type);
if (dup_function == null && type.nullable) {
dup_function = generate_struct_dup_wrapper ((ValueType) type);
} else if (dup_function == null) {
@@ -2447,7 +2449,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
private string generate_struct_equal_function (Struct st) {
- string equal_func = "_%sequal".printf (st.get_lower_case_cprefix ());
+ string equal_func = "_%sequal".printf (get_ccode_lower_case_prefix (st));
if (!add_wrapper (equal_func)) {
// wrapper already defined
@@ -2457,8 +2459,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);
@@ -2536,7 +2538,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
private string generate_numeric_equal_function (TypeSymbol sym) {
- string equal_func = "_%sequal".printf (sym.get_lower_case_cprefix ());
+ string equal_func = "_%sequal".printf (get_ccode_lower_case_prefix (sym));
if (!add_wrapper (equal_func)) {
// wrapper already defined
@@ -2546,8 +2548,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);
@@ -2585,17 +2587,17 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
private string generate_struct_dup_wrapper (ValueType value_type) {
- string dup_func = "_%sdup".printf (value_type.type_symbol.get_lower_case_cprefix ());
+ string dup_func = "_%sdup".printf (get_ccode_lower_case_prefix (value_type.type_symbol));
if (!add_wrapper (dup_func)) {
// wrapper already defined
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);
@@ -2606,20 +2608,20 @@ 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);
var st = value_type.data_type as Struct;
if (st != null && st.is_disposable ()) {
- if (!st.has_copy_function) {
+ if (!get_ccode_has_copy_function (st)) {
generate_struct_copy_function (st);
}
- var copy_call = new CCodeFunctionCall (new CCodeIdentifier (st.get_copy_function ()));
+ var copy_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_copy_function (st)));
copy_call.add_argument (new CCodeIdentifier ("self"));
copy_call.add_argument (new CCodeIdentifier ("dup"));
ccode.add_expression (copy_call);
@@ -2627,7 +2629,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"));
@@ -2648,24 +2650,24 @@ 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);
var cl = type.data_type as Class;
- assert (cl != null && cl.is_gboxed);
+ assert (cl != null && get_ccode_is_gboxed (cl));
var free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_boxed_copy"));
- free_call.add_argument (new CCodeIdentifier (cl.get_type_id ()));
+ free_call.add_argument (new CCodeIdentifier (get_ccode_type_id (cl)));
free_call.add_argument (new CCodeIdentifier ("self"));
ccode.add_return (free_call);
@@ -2679,7 +2681,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
@@ -2688,32 +2690,25 @@ 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);
var cl = type.data_type as Class;
- if (cl != null && cl.is_gboxed) {
+ if (cl != null && get_ccode_is_gboxed (cl)) {
var free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_boxed_free"));
- free_call.add_argument (new CCodeIdentifier (cl.get_type_id ()));
+ free_call.add_argument (new CCodeIdentifier (get_ccode_type_id (cl)));
free_call.add_argument (new CCodeIdentifier ("self"));
ccode.add_expression (free_call);
- } else if (cl != null) {
- assert (cl.free_function_address_of);
-
- var free_call = new CCodeFunctionCall (new CCodeIdentifier (type.data_type.get_free_function ()));
- free_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("self")));
-
- ccode.add_expression (free_call);
} else {
var st = type.data_type as Struct;
if (st != null && st.is_disposable ()) {
- if (!st.has_destroy_function) {
+ if (!get_ccode_has_destroy_function (st)) {
generate_struct_destroy_function (st);
}
- var destroy_call = new CCodeFunctionCall (new CCodeIdentifier (st.get_destroy_function ()));
+ var destroy_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_destroy_function (st)));
destroy_call.add_argument (new CCodeIdentifier ("self"));
ccode.add_expression (destroy_call);
}
@@ -2778,30 +2773,30 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (elements_require_free && element_destroy_func_expression is CCodeIdentifier) {
return new CCodeIdentifier (generate_collection_free_wrapper (type, (CCodeIdentifier) element_destroy_func_expression));
} else {
- return new CCodeIdentifier (type.data_type.get_free_function ());
+ return new CCodeIdentifier (get_ccode_free_function (type.data_type));
}
} else if (type is ErrorType) {
return new CCodeIdentifier ("g_error_free");
} else if (type.data_type != null) {
string unref_function;
if (type is ReferenceType) {
- if (type.data_type.is_reference_counting ()) {
- unref_function = type.data_type.get_unref_function ();
+ if (is_reference_counting (type.data_type)) {
+ unref_function = get_ccode_unref_function ((ObjectTypeSymbol) type.data_type);
if (type.data_type is Interface && unref_function == null) {
Report.error (type.source_reference, "missing class prerequisite for interface `%s', add GLib.Object to interface declaration if unsure".printf (type.data_type.get_full_name ()));
return null;
}
} else {
var cl = type.data_type as Class;
- if (cl != null && (cl.free_function_address_of || cl.is_gboxed)) {
+ if (cl != null && get_ccode_is_gboxed (cl)) {
unref_function = generate_free_func_wrapper (type);
} else {
- unref_function = type.data_type.get_free_function ();
+ unref_function = get_ccode_free_function (type.data_type);
}
}
} else {
if (type.nullable) {
- unref_function = type.data_type.get_free_function ();
+ unref_function = get_ccode_free_function (type.data_type);
if (unref_function == null) {
if (type.data_type is Struct && ((Struct) type.data_type).is_disposable ()) {
unref_function = generate_free_func_wrapper (type);
@@ -2811,10 +2806,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
} else {
var st = (Struct) type.data_type;
- if (!st.has_destroy_function) {
+ if (!get_ccode_has_destroy_function (st)) {
generate_struct_destroy_function (st);
}
- unref_function = st.get_destroy_function ();
+ unref_function = get_ccode_destroy_function (st);
}
}
if (unref_function == null) {
@@ -2846,7 +2841,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
private string generate_collection_free_wrapper (DataType collection_type, CCodeIdentifier element_destroy_func_expression) {
- string destroy_func = "_%s_%s".printf (collection_type.data_type.get_free_function (), element_destroy_func_expression.name);
+ string destroy_func = "_%s_%s".printf (get_ccode_free_function (collection_type.data_type), element_destroy_func_expression.name);
if (!add_wrapper (destroy_func)) {
// wrapper already defined
@@ -2856,7 +2851,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);
@@ -2866,7 +2861,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);
@@ -2901,7 +2896,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ccode.add_expression (element_free_call);
- var cfreecall = new CCodeFunctionCall (new CCodeIdentifier (collection_type.data_type.get_free_function ()));
+ var cfreecall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_free_function (collection_type.data_type)));
cfreecall.add_argument (new CCodeIdentifier ("self"));
ccode.add_expression (cfreecall);
@@ -3027,7 +3022,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var ccomma = new CCodeCommaExpression ();
if (context.profile == Profile.GOBJECT) {
- if (type.data_type != null && !type.data_type.is_reference_counting () &&
+ if (type.data_type != null && !is_reference_counting (type.data_type) &&
(type.data_type == gstringbuilder_type
|| type.data_type == garray_type
|| type.data_type == gbytearray_type
@@ -3073,7 +3068,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var cassign = new CCodeAssignment (cvar, ccomma);
// g_free (NULL) is allowed
- bool uses_gfree = (type.data_type != null && !type.data_type.is_reference_counting () && type.data_type.get_free_function () == "g_free");
+ bool uses_gfree = (type.data_type != null && !is_reference_counting (type.data_type) && get_ccode_free_function (type.data_type) == "g_free");
uses_gfree = uses_gfree || type is ArrayType;
if (uses_gfree) {
return cassign;
@@ -3110,7 +3105,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public void emit_temp_var (LocalVariable local) {
var init = !(local.name.has_prefix ("*") || local.no_init);
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
@@ -3122,7 +3117,7 @@ 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 {
ccode.add_assignment (get_variable_cexpression (local.name), initializer);
@@ -3134,7 +3129,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
cvar.initializer = default_value_for_type (local.variable_type, true);
cvar.init0 = true;
}
- ccode.add_declaration (local.variable_type.get_cname (), cvar);
+ ccode.add_declaration (get_ccode_name (local.variable_type), cvar);
}
}
@@ -3264,7 +3259,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ccode.close ();
var array_type = param.variable_type as ArrayType;
- if (array_type != null && !array_type.fixed_length && !param.no_array_length) {
+ if (array_type != null && !array_type.fixed_length && get_ccode_array_length (param)) {
for (int dim = 1; dim <= array_type.rank; dim++) {
ccode.open_if (get_variable_cexpression (get_parameter_array_length_cname (param, dim)));
ccode.add_assignment (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, get_variable_cexpression (get_parameter_array_length_cname (param, dim))), get_array_length_cvalue (value, dim));
@@ -3290,7 +3285,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
// return array length if appropriate
- if (((current_method != null && !current_method.no_array_length) || current_property_accessor != null) && current_return_type is ArrayType) {
+ if (((current_method != null && get_ccode_array_length (current_method)) || current_property_accessor != null) && current_return_type is ArrayType) {
var temp_value = store_temp_value (stmt.return_expression.target_value, stmt);
var array_type = (ArrayType) current_return_type;
@@ -3420,11 +3415,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
klass = new CCodeIdentifier ("klass");
}
- var get_class_private_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf(parent.get_upper_case_cname ())));
+ var get_class_private_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf(get_ccode_upper_case_name (parent))));
get_class_private_call.add_argument (klass);
l = new CCodeMemberAccess.pointer (get_class_private_call, get_symbol_lock_name (resource.symbol_reference.name));
} else {
- string lock_name = "%s_%s".printf(parent.get_lower_case_cname (), resource.symbol_reference.name);
+ string lock_name = "%s_%s".printf(get_ccode_lower_case_name (parent), resource.symbol_reference.name);
l = new CCodeIdentifier (get_symbol_lock_name (lock_name));
}
return l;
@@ -3433,7 +3428,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);
@@ -3442,7 +3437,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);
@@ -3465,7 +3460,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));
}
@@ -3536,7 +3531,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));
@@ -3729,8 +3724,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
var cl = type.data_type as Class;
- if (cl != null && cl.is_reference_counting ()
- && cl.get_ref_function () == "") {
+ if (cl != null && is_reference_counting (cl)
+ && get_ccode_ref_function (cl) == "") {
// empty ref_function => no ref necessary
return false;
}
@@ -3755,8 +3750,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
var cl = type.data_type as Class;
- if (cl != null && cl.is_reference_counting ()
- && cl.get_unref_function () == "") {
+ if (cl != null && is_reference_counting (cl)
+ && get_ccode_unref_function (cl) == "") {
// empty unref_function => no unref necessary
return false;
}
@@ -3772,8 +3767,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
bool is_ref_function_void (DataType type) {
var cl = type.data_type as Class;
- if (cl != null && cl.ref_function_void) {
- return true;
+ if (cl != null) {
+ return get_ccode_ref_function_void (cl);
} else {
return false;
}
@@ -3801,11 +3796,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var vt = (ValueType) type;
var st = (Struct) vt.type_symbol;
- var copy_call = new CCodeFunctionCall (new CCodeIdentifier (st.get_copy_function ()));
+ var copy_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_copy_function (st)));
copy_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cexpr));
copy_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, ctemp));
- if (!st.has_copy_function) {
+ if (!get_ccode_has_copy_function (st)) {
generate_struct_copy_function (st);
}
@@ -4056,7 +4051,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;
}
}
@@ -4105,7 +4100,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;
@@ -4125,7 +4120,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;
}
@@ -4143,19 +4138,19 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var cl = expr.type_reference.data_type as Class;
- if (!m.has_new_function) {
+ if (!get_ccode_has_new_function (m)) {
// use construct function directly
- creation_call = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname ()));
- creation_call.add_argument (new CCodeIdentifier (cl.get_type_id ()));
+ creation_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_real_name (m)));
+ creation_call.add_argument (new CCodeIdentifier (get_ccode_type_id (cl)));
} 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)) {
+ if ((st != null && !st.is_simple_type ()) && !(get_ccode_instance_pos (m) < 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) {
@@ -4173,7 +4168,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (cl != null && !cl.is_compact) {
add_generic_type_arguments (carg_map, expr.type_reference.get_type_arguments (), expr);
- } else if (cl != null && m.simple_generics) {
+ } else if (cl != null && get_ccode_simple_generics (m)) {
int type_param_index = 0;
foreach (var type_arg in expr.type_reference.get_type_arguments ()) {
if (requires_copy (type_arg)) {
@@ -4200,14 +4195,14 @@ 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;
}
- if (!param.no_array_length && param.variable_type is ArrayType) {
+ if (get_ccode_array_length (param) && param.variable_type is ArrayType) {
var array_type = (ArrayType) param.variable_type;
for (int dim = 1; dim <= array_type.rank; dim++) {
- carg_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), get_array_length_cexpression (arg, dim));
+ carg_map.set (get_param_pos (get_ccode_array_length_pos (param) + 0.01 * dim), get_array_length_cexpression (arg, dim));
}
} else if (param.variable_type is DelegateType) {
var deleg_type = (DelegateType) param.variable_type;
@@ -4215,23 +4210,23 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (d.has_target) {
CCodeExpression delegate_target_destroy_notify;
var delegate_target = get_delegate_target_cexpression (arg, out delegate_target_destroy_notify);
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), delegate_target);
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), delegate_target);
if (deleg_type.value_owned) {
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position + 0.01), delegate_target_destroy_notify);
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param) + 0.01), delegate_target_destroy_notify);
}
}
}
cexpr = handle_struct_argument (param, arg, cexpr);
- if (param.ctype != null) {
- cexpr = new CCodeCastExpression (cexpr, param.ctype);
+ if (get_ccode_type (param) != null) {
+ cexpr = new CCodeCastExpression (cexpr, get_ccode_type (param));
}
} else {
cexpr = handle_struct_argument (null, arg, cexpr);
}
- arg_pos = get_param_pos (param.cparameter_position, ellipsis);
+ arg_pos = get_param_pos (get_ccode_pos (param), ellipsis);
} else {
// default argument position
cexpr = handle_struct_argument (null, arg, cexpr);
@@ -4260,7 +4255,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
* parameter yet */
param.initializer.emit (this);
- carg_map.set (get_param_pos (param.cparameter_position), get_cvalue (param.initializer));
+ carg_map.set (get_param_pos (get_ccode_pos (param)), get_cvalue (param.initializer));
i++;
}
@@ -4281,7 +4276,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
last_pos = min_pos;
}
- if ((st != null && !st.is_simple_type ()) && m.cinstance_parameter_position < 0) {
+ if ((st != null && !st.is_simple_type ()) && get_ccode_instance_pos (m) < 0) {
// instance parameter is at the end in a struct creation method
creation_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, instance));
}
@@ -4295,8 +4290,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (ellipsis) {
/* ensure variable argument list ends with NULL
* except when using printf-style arguments */
- if (!m.printf_format && !m.scanf_format && m.sentinel != "") {
- creation_call.add_argument (new CCodeConstant (m.sentinel));
+ if (!m.printf_format && !m.scanf_format && get_ccode_sentinel (m) != "") {
+ creation_call.add_argument (new CCodeConstant (get_ccode_sentinel (m)));
}
}
@@ -4304,8 +4299,8 @@ 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 ());
+ if (get_ccode_type (m) != null) {
+ 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;
@@ -4320,8 +4315,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
} else {
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_upper_case_name (edomain)));
+ 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));
@@ -4410,7 +4405,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);
}
@@ -4462,7 +4457,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
public CCodeExpression? try_cast_value_to_type (CCodeExpression ccodeexpr, DataType from, DataType to, Expression? expr = null) {
- if (from == null || gvalue_type == null || from.data_type != gvalue_type || to.get_type_id () == null) {
+ if (from == null || gvalue_type == null || from.data_type != gvalue_type || get_ccode_type_id (to) == "") {
return null;
}
@@ -4488,10 +4483,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var temp_value = create_temp_value (to, true, node, true);
var ctemp = get_cvalue_ (temp_value);
- 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 ()));
+ holds.add_argument (new CCodeIdentifier (get_ccode_type_id (to)));
var cond = new CCodeBinaryExpression (CCodeBinaryOperator.AND, holds, ccall);
var warn = new CCodeFunctionCall (new CCodeIdentifier ("g_warning"));
warn.add_argument (new CCodeConstant ("\"Invalid GValue unboxing (wrong type or NULL)\""));
@@ -4521,12 +4516,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;
@@ -4583,7 +4578,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (expr.is_silent_cast) {
var cexpr = get_cvalue (expr.inner);
var ccheck = create_type_check (cexpr, expr.type_reference);
- var ccast = new CCodeCastExpression (cexpr, expr.type_reference.get_cname ());
+ var ccast = new CCodeCastExpression (cexpr, get_ccode_name (expr.type_reference));
var cnull = new CCodeConstant ("NULL");
set_cvalue (expr, new CCodeConditionalExpression (ccheck, ccast, cnull));
@@ -4617,7 +4612,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) {
@@ -4656,7 +4651,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
creation_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_cvalue (expr.inner)));
creation_call.add_argument (new CCodeConstant ("0"));
- creation_call.add_argument (new CCodeIdentifier ("sizeof (%s)".printf (expr.inner.value_type.get_cname ())));
+ creation_call.add_argument (new CCodeIdentifier ("sizeof (%s)".printf (get_ccode_name (expr.inner.value_type))));
ccode.add_expression (creation_call);
} else if (expr.value_type is DelegateType) {
var target_destroy_notify = get_delegate_target_destroy_notify_cvalue (expr.inner.target_value);
@@ -4867,32 +4862,21 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
}
- public string? get_type_check_function (TypeSymbol type) {
- var cl = type as Class;
- if (cl != null && cl.type_check_function != null) {
- return cl.type_check_function;
- } else if ((cl != null && cl.is_compact) || type is Struct || type is Enum || type is Delegate) {
- return null;
- } else {
- return type.get_upper_case_cname ("IS_");
- }
- }
-
CCodeExpression? create_type_check (CCodeNode ccodenode, DataType type) {
var et = type as ErrorType;
if (et != null && et.error_code != null) {
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_upper_case_name (et.error_domain)));
+ 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");
- var type_domain = new CCodeIdentifier (et.error_domain.get_upper_case_cname ());
+ var type_domain = new CCodeIdentifier (get_ccode_upper_case_name (et.error_domain));
return new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, instance_domain, type_domain);
} else {
- string type_check_func = get_type_check_function (type.data_type);
- if (type_check_func == null) {
+ string type_check_func = get_ccode_type_check_function (type.data_type);
+ if (type_check_func == "") {
return new CCodeInvalidExpression ();
}
var ccheck = new CCodeFunctionCall (new CCodeIdentifier (type_check_func));
@@ -4902,7 +4886,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
string generate_array_contains_wrapper (ArrayType array_type) {
- string array_contains_func = "_vala_%s_array_contains".printf (array_type.element_type.get_lower_case_cname ());
+ string array_contains_func = "_vala_%s_array_contains".printf (get_ccode_lower_case_name (array_type.element_type));
if (!add_wrapper (array_contains_func)) {
return array_contains_func;
@@ -4911,12 +4895,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);
@@ -4972,15 +4956,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
public override void visit_lambda_expression (LambdaExpression lambda) {
- // use instance position from delegate
- var dt = (DelegateType) lambda.target_type;
- lambda.method.cinstance_parameter_position = dt.delegate_symbol.cinstance_parameter_position;
-
lambda.accept_children (this);
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) {
@@ -5023,7 +5003,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);
@@ -5062,9 +5042,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
/* floating reference, sink it.
*/
var cl = type.data_type as ObjectTypeSymbol;
- var sink_func = (cl != null) ? cl.get_ref_sink_function () : null;
+ var sink_func = (cl != null) ? get_ccode_ref_sink_function (cl) : "";
- if (sink_func != null) {
+ if (sink_func != "") {
var csink = new CCodeFunctionCall (new CCodeIdentifier (sink_func));
csink.add_argument (result.cvalue);
@@ -5084,7 +5064,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
&& target_type != null
&& target_type.data_type == gvalue_type
&& !(type is NullType)
- && type.get_type_id () != "G_TYPE_VALUE");
+ && get_ccode_type_id (type) != "G_TYPE_VALUE");
bool gvariant_boxing = (context.profile == Profile.GOBJECT
&& target_type != null
&& target_type.data_type == gvariant_type
@@ -5136,7 +5116,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
} else {
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_cvalue_ (temp_value)));
}
- ccall.add_argument (new CCodeIdentifier (type.get_type_id ()));
+ var type_id = get_ccode_type_id (type);
+ if (type_id == "") {
+ Report.error (node.source_reference, "GValue boxing of type `%s' is not supported".printf (type.to_string ()));
+ }
+ ccall.add_argument (new CCodeIdentifier (type_id));
ccode.add_expression (ccall);
if (requires_destroy (type)) {
@@ -5168,7 +5152,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
@@ -5251,11 +5235,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;
}
@@ -5268,8 +5252,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (instance is BaseAccess) {
if (prop.base_property != null) {
var base_class = (Class) prop.base_property.parent_symbol;
- var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (base_class.get_upper_case_cname (null))));
- vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
+ var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (get_ccode_upper_case_name (base_class, null))));
+ vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (current_class, null))));
var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, "set_%s".printf (prop.name)));
ccall.add_argument ((CCodeExpression) get_ccodenode (instance));
@@ -5278,7 +5262,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ccode.add_expression (ccall);
} else if (prop.base_interface_property != null) {
var base_iface = (Interface) prop.base_interface_property.parent_symbol;
- string parent_iface_var = "%s_%s_parent_iface".printf (current_class.get_lower_case_cname (null), base_iface.get_lower_case_cname (null));
+ string parent_iface_var = "%s_%s_parent_iface".printf (get_ccode_lower_case_name (current_class), get_ccode_lower_case_name (base_iface));
var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), "set_%s".printf (prop.name)));
ccall.add_argument ((CCodeExpression) get_ccodenode (instance));
@@ -5292,7 +5276,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var set_func = "g_object_set";
var base_property = prop;
- if (!prop.no_accessor_method) {
+ if (!get_ccode_no_accessor_method (prop)) {
if (prop.base_property != null) {
base_property = prop.base_property;
} else if (prop.base_interface_property != null) {
@@ -5303,7 +5287,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
@@ -5333,9 +5317,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ccall.add_argument (cinstance);
}
- if (prop.no_accessor_method) {
+ if (get_ccode_no_accessor_method (prop)) {
/* property name is second argument of g_object_set */
- ccall.add_argument (prop.get_canonical_cconstant ());
+ ccall.add_argument (get_property_canonical_cconstant (prop));
}
var cexpr = get_cvalue_ (value);
@@ -5348,7 +5332,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ccall.add_argument (cexpr);
- if (array_type != null && !prop.no_array_length) {
+ if (array_type != null && get_ccode_array_length (prop)) {
for (int dim = 1; dim <= array_type.rank; dim++) {
ccall.add_argument (get_array_length_cvalue (value, dim));
}
@@ -5362,7 +5346,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
}
- if (prop.no_accessor_method) {
+ if (get_ccode_no_accessor_method (prop)) {
ccall.add_argument (new CCodeConstant ("NULL"));
}
@@ -5425,8 +5409,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
|| type is PointerType || type is DelegateType
|| (array_type != null && !array_type.fixed_length)) {
return new CCodeConstant ("NULL");
- } else if (type.data_type != null && type.data_type.get_default_value () != null) {
- return new CCodeConstant (type.data_type.get_default_value ());
+ } else if (type.data_type != null && get_ccode_default_value (type.data_type) != "") {
+ return new CCodeConstant (get_ccode_default_value (type.data_type));
} else if (type.type_parameter != null) {
return new CCodeConstant ("NULL");
} else if (type is ErrorType) {
@@ -5449,7 +5433,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (!context.assert) {
return;
} else if (context.checking && ((t is Class && !((Class) t).is_compact) || t is Interface)) {
- var ctype_check = new CCodeFunctionCall (new CCodeIdentifier (get_type_check_function (t)));
+ var ctype_check = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_check_function (t)));
ctype_check.add_argument (new CCodeIdentifier (var_name));
CCodeExpression cexpr = ctype_check;
@@ -5519,14 +5503,356 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return false;
}
if (type.data_type != null) {
- var a = type.data_type.get_attribute ("CCode");
- if (a != null && a.has_argument ("lvalue_access")) {
- return a.get_bool ("lvalue_access");
- }
+ return type.data_type.get_attribute_bool ("CCode", "lvalue_access", true);
}
return true;
}
+ public static CCodeAttribute get_ccode_attribute (CodeNode node) {
+ var attr = node.get_attribute_cache (ccode_attribute_cache_index);
+ if (attr == null) {
+ attr = new CCodeAttribute (node);
+ node.set_attribute_cache (ccode_attribute_cache_index, attr);
+ }
+ return (CCodeAttribute) attr;
+ }
+
+ public static string get_ccode_name (CodeNode node) {
+ return get_ccode_attribute(node).name;
+ }
+
+ public static string get_ccode_const_name (CodeNode node) {
+ return get_ccode_attribute(node).const_name;
+ }
+
+ public static string get_ccode_type_name (Interface iface) {
+ return get_ccode_attribute(iface).type_name;
+ }
+
+ public static string get_ccode_lower_case_name (CodeNode node, string? infix = null) {
+ var sym = node as Symbol;
+ if (sym != null) {
+ if (infix == null) {
+ infix = "";
+ }
+ if (sym is Delegate) {
+ return "%s%s%s".printf (get_ccode_lower_case_prefix (sym.parent_symbol), infix, Symbol.camel_case_to_lower_case (sym.name));
+ } else if (sym is ErrorCode) {
+ return get_ccode_name (sym).down ();
+ } else {
+ return "%s%s%s".printf (get_ccode_lower_case_prefix (sym.parent_symbol), infix, get_ccode_lower_case_suffix (sym));
+ }
+ } else if (node is ErrorType) {
+ var type = (ErrorType) node;
+ if (type.error_domain == null) {
+ if (infix == null) {
+ return "g_error";
+ } else {
+ return "g_%s_error".printf (infix);
+ }
+ } else if (type.error_code == null) {
+ return get_ccode_lower_case_name (type.error_domain, infix);
+ } else {
+ return get_ccode_lower_case_name (type.error_code, infix);
+ }
+ } else {
+ var type = (DataType) node;
+ return get_ccode_lower_case_name (type.data_type, infix);
+ }
+ }
+
+ public static string get_ccode_upper_case_name (Symbol sym, string? infix = null) {
+ if (sym is Property) {
+ return "%s_%s".printf (get_ccode_lower_case_name (sym.parent_symbol), Symbol.camel_case_to_lower_case (sym.name)).up ();
+ } else {
+ return get_ccode_lower_case_name (sym, infix).up ();
+ }
+ }
+
+ public static string get_ccode_header_filenames (Symbol sym) {
+ return get_ccode_attribute(sym).header_filenames;
+ }
+
+ public static string get_ccode_prefix (Symbol sym) {
+ return get_ccode_attribute(sym).prefix;
+ }
+
+ public static string get_ccode_lower_case_prefix (Symbol sym) {
+ return get_ccode_attribute(sym).lower_case_prefix;
+ }
+
+ public static string get_ccode_lower_case_suffix (Symbol sym) {
+ return get_ccode_attribute(sym).lower_case_suffix;
+ }
+
+ public static string get_ccode_ref_function (TypeSymbol sym) {
+ return get_ccode_attribute(sym).ref_function;
+ }
+
+ public static bool is_reference_counting (TypeSymbol sym) {
+ return get_ccode_ref_function (sym) != null;
+ }
+
+ public static bool get_ccode_ref_function_void (Class cl) {
+ return get_ccode_attribute(cl).ref_function_void;
+ }
+
+ public static string get_ccode_unref_function (ObjectTypeSymbol sym) {
+ return get_ccode_attribute(sym).unref_function;
+ }
+
+ public static string get_ccode_ref_sink_function (ObjectTypeSymbol sym) {
+ return get_ccode_attribute(sym).ref_sink_function;
+ }
+
+ public static string get_ccode_copy_function (TypeSymbol sym) {
+ return get_ccode_attribute(sym).copy_function;
+ }
+
+ public static string get_ccode_destroy_function (TypeSymbol sym) {
+ return get_ccode_attribute(sym).destroy_function;
+ }
+
+ public static string? get_ccode_dup_function (TypeSymbol sym) {
+ if (sym is Struct) {
+ if (sym.external_package) {
+ return null;
+ } else {
+ return get_ccode_lower_case_prefix (sym) + "dup";
+ }
+ }
+ return get_ccode_copy_function (sym);
+ }
+
+ public static string get_ccode_free_function (TypeSymbol sym) {
+ return get_ccode_attribute(sym).free_function;
+ }
+
+ public static bool get_ccode_is_gboxed (TypeSymbol sym) {
+ return get_ccode_free_function (sym) == "g_boxed_free";
+ }
+
+ public static string get_ccode_type_id (CodeNode node) {
+ if (node is DataType) {
+ var type = (DataType) node;
+ if (type.data_type != null) {
+ return get_ccode_type_id (type.data_type);
+ }
+ return "";
+ }
+ return get_ccode_attribute(node).type_id;
+ }
+
+ public static string get_ccode_marshaller_type_name (CodeNode node) {
+ return get_ccode_attribute(node).marshaller_type_name;
+ }
+
+ public static string get_ccode_get_value_function (CodeNode sym) {
+ return get_ccode_attribute(sym).get_value_function;
+ }
+
+ public static string get_ccode_set_value_function (CodeNode sym) {
+ return get_ccode_attribute(sym).set_value_function;
+ }
+
+ public static string get_ccode_take_value_function (CodeNode sym) {
+ return get_ccode_attribute(sym).take_value_function;
+ }
+
+ public static string get_ccode_param_spec_function (CodeNode sym) {
+ return get_ccode_attribute(sym).param_spec_function;
+ }
+
+ public static string get_ccode_type_check_function (TypeSymbol sym) {
+ var cl = sym as Class;
+ var a = sym.get_attribute_string ("CCode", "type_check_function");
+ if (cl != null && a != null) {
+ return a;
+ } else if ((cl != null && cl.is_compact) || sym is Struct || sym is Enum || sym is Delegate) {
+ return "";
+ } else {
+ return get_ccode_upper_case_name (sym, "IS_");
+ }
+ }
+
+ public static string get_ccode_default_value (TypeSymbol sym) {
+ return get_ccode_attribute(sym).default_value;
+ }
+
+ public static bool get_ccode_has_copy_function (Struct st) {
+ return st.get_attribute_bool ("CCode", "has_copy_function", true);
+ }
+
+ public static bool get_ccode_has_destroy_function (Struct st) {
+ return st.get_attribute_bool ("CCode", "has_destroy_function", true);
+ }
+
+ public static double get_ccode_instance_pos (CodeNode node) {
+ if (node is Delegate) {
+ return node.get_attribute_double ("CCode", "instance_pos", -2);
+ } else {
+ return node.get_attribute_double ("CCode", "instance_pos", 0);
+ }
+ }
+
+ public static bool get_ccode_array_length (CodeNode node) {
+ return get_ccode_attribute(node).array_length;
+ }
+
+ public static string? get_ccode_array_length_type (CodeNode node) {
+ return get_ccode_attribute(node).array_length_type;
+ }
+
+ public static bool get_ccode_array_null_terminated (CodeNode node) {
+ return get_ccode_attribute(node).array_null_terminated;
+ }
+
+ public static string? get_ccode_array_length_name (CodeNode node) {
+ return get_ccode_attribute(node).array_length_name;
+ }
+
+ public static string? get_ccode_array_length_expr (CodeNode node) {
+ return get_ccode_attribute(node).array_length_expr;
+ }
+
+ public static double get_ccode_array_length_pos (CodeNode node) {
+ var a = node.get_attribute ("CCode");
+ if (a != null && a.has_argument ("array_length_pos")) {
+ return a.get_double ("array_length_pos");
+ }
+ if (node is Parameter) {
+ var param = (Parameter) node;
+ return get_ccode_pos (param) + 0.1;
+ } else {
+ return -3;
+ }
+ }
+
+ public static double get_ccode_delegate_target_pos (CodeNode node) {
+ var a = node.get_attribute ("CCode");
+ if (a != null && a.has_argument ("delegate_target_pos")) {
+ return a.get_double ("delegate_target_pos");
+ }
+ if (node is Parameter) {
+ var param = (Parameter) node;
+ return get_ccode_pos (param) + 0.1;
+ } else {
+ return -3;
+ }
+ }
+
+ public static double get_ccode_destroy_notify_pos (CodeNode node) {
+ var a = node.get_attribute ("CCode");
+ if (a != null && a.has_argument ("destroy_notify_pos")) {
+ return a.get_double ("destroy_notify_pos");
+ }
+ if (node is Parameter) {
+ var param = (Parameter) node;
+ return get_ccode_pos (param) + 0.1;
+ } else {
+ return -3;
+ }
+ }
+
+ public static bool get_ccode_delegate_target (CodeNode node) {
+ return get_ccode_attribute(node).delegate_target;
+ }
+
+ public static double get_ccode_pos (Parameter param) {
+ return get_ccode_attribute(param).pos;
+ }
+
+ public static string? get_ccode_type (CodeNode node) {
+ return node.get_attribute_string ("CCode", "type");
+ }
+
+ public static bool get_ccode_simple_generics (Method m) {
+ return m.get_attribute_bool ("CCode", "simple_generics");
+ }
+
+ public static string get_ccode_real_name (Method m) {
+ return get_ccode_attribute(m).real_name;
+ }
+
+ public static string get_ccode_vfunc_name (Method m) {
+ return get_ccode_attribute(m).vfunc_name;
+ }
+
+ public static string get_ccode_finish_name (Method m) {
+ return get_ccode_attribute(m).finish_name;
+ }
+
+ public static string get_ccode_finish_vfunc_name (Method m) {
+ return get_ccode_attribute(m).finish_vfunc_name;
+ }
+
+ public static string get_ccode_finish_real_name (Method m) {
+ return get_ccode_attribute(m).finish_real_name;
+ }
+
+ public static bool get_ccode_no_accessor_method (Property p) {
+ return p.get_attribute ("NoAccessorMethod") != null;
+ }
+
+ public static bool get_ccode_has_type_id (TypeSymbol sym) {
+ return sym.get_attribute_bool ("CCode", "has_type_id", true);
+ }
+
+ public static bool get_ccode_has_new_function (Method m) {
+ return m.get_attribute_bool ("CCode", "has_new_function", true);
+ }
+
+ public static bool get_ccode_has_generic_type_parameter (Method m) {
+ var a = m.get_attribute ("CCode");
+ return a != null && a.has_argument ("generic_type_pos");
+ }
+
+ public static double get_ccode_generic_type_pos (Method m) {
+ return m.get_attribute_double ("CCode", "generic_type_pos");
+ }
+
+ public static string get_ccode_sentinel (Method m) {
+ return get_ccode_attribute(m).sentinel;
+ }
+
+ public static bool get_ccode_notify (Property prop) {
+ return prop.get_attribute_bool ("CCode", "notify", true);
+ }
+
+ public CCodeConstant get_signal_canonical_constant (Signal sig, string? detail = null) {
+ var str = new StringBuilder ("\"");
+
+ string i = get_ccode_name (sig);
+
+ while (i.length > 0) {
+ unichar c = i.get_char ();
+ if (c == '_') {
+ str.append_c ('-');
+ } else {
+ str.append_unichar (c);
+ }
+
+ i = i.next_char ();
+ }
+
+ if (detail != null) {
+ str.append ("::");
+ str.append (detail);
+ }
+
+ str.append_c ('"');
+
+ return new CCodeConstant (str.str);
+ }
+
+ public bool get_signal_has_emitter (Signal sig) {
+ return sig.get_attribute ("HasEmitter") != null;
+ }
+
+ public CCodeConstant get_property_canonical_cconstant (Property prop) {
+ return new CCodeConstant ("\"%s\"".printf (prop.name.replace ("_", "-")));
+ }
+
public override void visit_class (Class cl) {
}
@@ -5554,20 +5880,20 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
public CCodeFunctionCall generate_instance_cast (CCodeExpression expr, TypeSymbol type) {
- var result = new CCodeFunctionCall (new CCodeIdentifier (type.get_upper_case_cname (null)));
+ var result = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_upper_case_name (type, null)));
result.add_argument (expr);
return result;
}
void generate_struct_destroy_function (Struct st) {
- if (cfile.add_declaration (st.get_destroy_function ())) {
+ if (cfile.add_declaration (get_ccode_destroy_function (st))) {
// only generate function once per source file
return;
}
- var function = new CCodeFunction (st.get_destroy_function (), "void");
+ var function = new CCodeFunction (get_ccode_destroy_function (st), "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);
@@ -5589,15 +5915,15 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
void generate_struct_copy_function (Struct st) {
- if (cfile.add_declaration (st.get_copy_function ())) {
+ if (cfile.add_declaration (get_ccode_copy_function (st))) {
// only generate function once per source file
return;
}
- var function = new CCodeFunction (st.get_copy_function (), "void");
+ var function = new CCodeFunction (get_ccode_copy_function (st), "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);
@@ -5628,10 +5954,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ccode.add_return (default_value_for_type (return_type, false));
}
- public virtual string? get_custom_creturn_type (Method m) {
- return null;
- }
-
public virtual void generate_dynamic_method_wrapper (DynamicMethod method) {
}
diff --git a/codegen/valaccodecontrolflowmodule.vala b/codegen/valaccodecontrolflowmodule.vala
index d467398..faec8f4 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 = "_tmp%d_label%d".printf (label_temp_id, 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..6975e8e 100644
--- a/codegen/valaccodedelegatemodule.vala
+++ b/codegen/valaccodedelegatemodule.vala
@@ -28,32 +28,32 @@
*/
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);
cfundecl.add_parameter (cparam);
// handle array parameters
- if (!param.no_array_length && param.variable_type is ArrayType) {
+ if (get_ccode_array_length (param) && param.variable_type is ArrayType) {
var array_type = (ArrayType) param.variable_type;
var length_ctype = "int";
@@ -80,10 +80,10 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
}
}
}
- if (!d.no_array_length && d.return_type is ArrayType) {
+ if (get_ccode_array_length (d) && d.return_type is ArrayType) {
// return array length if appropriate
var array_type = (ArrayType) d.return_type;
- var array_length_type = d.array_length_type != null ? d.array_length_type : "int";
+ var array_length_type = get_ccode_array_length_type (d) != null ? get_ccode_array_length_type (d) : "int";
array_length_type += "*";
for (int dim = 1; dim <= array_type.rank; dim++) {
@@ -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 = get_ccode_lower_case_prefix (sig.parent_symbol) + 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
@@ -211,7 +211,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
if (d.has_target) {
var cparam = new CCodeParameter ("self", "gpointer");
- cparam_map.set (get_param_pos (d.cinstance_parameter_position), cparam);
+ cparam_map.set (get_param_pos (get_ccode_instance_pos (d)), cparam);
}
if (d.sender_type != null) {
@@ -225,21 +225,21 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
&& param.variable_type is ArrayType
&& ((ArrayType) param.variable_type).element_type.data_type == string_type.data_type) {
// use null-terminated string arrays for dynamic signals for compatibility reasons
- param.no_array_length = true;
- param.array_null_terminated = true;
+ param.set_attribute_bool ("CCode", "array_length", false);
+ param.set_attribute_bool ("CCode", "array_null_terminated", true);
}
generate_parameter (param, cfile, cparam_map, null);
}
- if (!d.no_array_length && d.return_type is ArrayType) {
+ if (get_ccode_array_length (d) && d.return_type is ArrayType) {
// return array length if appropriate
var array_type = (ArrayType) d.return_type;
- var array_length_type = d.array_length_type != null ? d.array_length_type : "int";
+ var array_length_type = get_ccode_array_length_type (d) != null ? get_ccode_array_length_type (d) : "int";
array_length_type += "*";
for (int dim = 1; dim <= array_type.rank; dim++) {
var cparam = new CCodeParameter (get_array_length_cname ("result", dim), array_length_type);
- cparam_map.set (get_param_pos (d.carray_length_parameter_position + 0.01 * dim), cparam);
+ cparam_map.set (get_param_pos (get_ccode_array_length_pos (d) + 0.01 * dim), cparam);
}
} else if (d.return_type is DelegateType) {
// return delegate target if appropriate
@@ -247,14 +247,14 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
if (deleg_type.delegate_symbol.has_target) {
var cparam = new CCodeParameter (get_delegate_target_cname ("result"), "void**");
- cparam_map.set (get_param_pos (d.cdelegate_target_parameter_position), cparam);
+ cparam_map.set (get_param_pos (get_ccode_delegate_target_pos (d)), cparam);
if (deleg_type.value_owned) {
cparam = new CCodeParameter (get_delegate_target_destroy_notify_cname ("result"), "GDestroyNotify*");
- cparam_map.set (get_param_pos (d.cdelegate_target_parameter_position + 0.01), cparam);
+ cparam_map.set (get_param_pos (get_ccode_delegate_target_pos (d) + 0.01), cparam);
}
}
} 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);
}
@@ -300,7 +300,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
i = 1;
}
}
- carg_map.set (get_param_pos (m.cinstance_parameter_position), arg);
+ carg_map.set (get_param_pos (get_ccode_instance_pos (m)), arg);
}
bool first = true;
@@ -308,7 +308,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
foreach (Parameter param in m.get_parameters ()) {
if (first && d.sender_type != null && m.get_parameters ().size == d.get_parameters ().size + 1) {
// sender parameter
- carg_map.set (get_param_pos (param.cparameter_position), new CCodeIdentifier ("_sender"));
+ carg_map.set (get_param_pos (get_ccode_pos (param)), new CCodeIdentifier ("_sender"));
first = false;
continue;
@@ -316,60 +316,60 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
CCodeExpression arg;
arg = new CCodeIdentifier (get_variable_cname (d_params.get (i).name));
- carg_map.set (get_param_pos (param.cparameter_position), arg);
+ carg_map.set (get_param_pos (get_ccode_pos (param)), arg);
// handle array arguments
- if (!param.no_array_length && param.variable_type is ArrayType) {
+ if (get_ccode_array_length (param) && param.variable_type is ArrayType) {
var array_type = (ArrayType) param.variable_type;
for (int dim = 1; dim <= array_type.rank; dim++) {
CCodeExpression clength;
- if (d_params.get (i).array_null_terminated) {
+ if (get_ccode_array_null_terminated (d_params.get (i))) {
requires_array_length = true;
var len_call = new CCodeFunctionCall (new CCodeIdentifier ("_vala_array_length"));
len_call.add_argument (new CCodeIdentifier (d_params.get (i).name));
clength = len_call;
- } else if (d_params.get (i).no_array_length) {
+ } else if (!get_ccode_array_length (d_params.get (i))) {
clength = new CCodeConstant ("-1");
} else {
clength = new CCodeIdentifier (get_parameter_array_length_cname (d_params.get (i), dim));
}
- carg_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), clength);
+ carg_map.set (get_param_pos (get_ccode_array_length_pos (param) + 0.01 * dim), clength);
}
} else if (param.variable_type is DelegateType) {
var deleg_type = (DelegateType) param.variable_type;
if (deleg_type.delegate_symbol.has_target) {
var ctarget = new CCodeIdentifier (get_delegate_target_cname (d_params.get (i).name));
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), ctarget);
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), ctarget);
if (deleg_type.value_owned) {
var ctarget_destroy_notify = new CCodeIdentifier (get_delegate_target_destroy_notify_cname (d_params.get (i).name));
- carg_map.set (get_param_pos (m.cdelegate_target_parameter_position + 0.01), ctarget_destroy_notify);
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (m) + 0.01), ctarget_destroy_notify);
}
}
}
i++;
}
- if (!m.no_array_length && m.return_type is ArrayType) {
+ if (get_ccode_array_length (m) && m.return_type is ArrayType) {
var array_type = (ArrayType) m.return_type;
for (int dim = 1; dim <= array_type.rank; dim++) {
CCodeExpression clength;
- if (d.no_array_length) {
+ if (!get_ccode_array_length (d)) {
clength = new CCodeConstant ("NULL");
} else {
clength = new CCodeIdentifier (get_array_length_cname ("result", dim));
}
- carg_map.set (get_param_pos (m.carray_length_parameter_position + 0.01 * dim), clength);
+ carg_map.set (get_param_pos (get_ccode_array_length_pos (m) + 0.01 * dim), clength);
}
} else if (m.return_type is DelegateType) {
var deleg_type = (DelegateType) m.return_type;
if (deleg_type.delegate_symbol.has_target) {
var ctarget = new CCodeIdentifier (get_delegate_target_cname ("result"));
- carg_map.set (get_param_pos (m.cdelegate_target_parameter_position), ctarget);
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (m)), ctarget);
if (deleg_type.value_owned) {
var ctarget_destroy_notify = new CCodeIdentifier (get_delegate_target_destroy_notify_cname ("result"));
- carg_map.set (get_param_pos (m.cdelegate_target_parameter_position + 0.01), ctarget_destroy_notify);
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (m) + 0.01), ctarget_destroy_notify);
}
}
} else if (m.return_type.is_real_non_null_struct_type ()) {
@@ -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;
@@ -414,7 +414,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
if (m.closure) {
int block_id = get_block_id (current_closure_block);
destroy_notify = new CCodeIdentifier ("block%d_data_unref".printf (block_id));
- } else if (get_this_type () != null && m.binding != MemberBinding.STATIC && !m.is_async_callback && m.this_parameter.variable_type.data_type.is_reference_counting ()) {
+ } else if (get_this_type () != null && m.binding != MemberBinding.STATIC && !m.is_async_callback && is_reference_counting (m.this_parameter.variable_type.data_type)) {
destroy_notify = get_destroy_func_expression (m.this_parameter.variable_type);
} else if (in_constructor) {
destroy_notify = new CCodeIdentifier ("g_object_unref");
@@ -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";
}
@@ -463,9 +463,9 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
var main_cparam = new CCodeParameter (get_variable_cname (param.name), ctypename);
- cparam_map.set (get_param_pos (param.cparameter_position), main_cparam);
+ cparam_map.set (get_param_pos (get_ccode_pos (param)), main_cparam);
if (carg_map != null) {
- carg_map.set (get_param_pos (param.cparameter_position), get_variable_cexpression (param.name));
+ carg_map.set (get_param_pos (get_ccode_pos (param)), get_variable_cexpression (param.name));
}
if (param.variable_type is DelegateType) {
@@ -476,23 +476,23 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
if (d.has_target) {
var cparam = new CCodeParameter (get_delegate_target_cname (get_variable_cname (param.name)), target_ctypename);
- cparam_map.set (get_param_pos (param.cdelegate_target_parameter_position), cparam);
+ cparam_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), cparam);
if (carg_map != null) {
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), get_variable_cexpression (cparam.name));
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), get_variable_cexpression (cparam.name));
}
if (deleg_type.value_owned) {
cparam = new CCodeParameter (get_delegate_target_destroy_notify_cname (get_variable_cname (param.name)), target_destroy_notify_ctypename);
- cparam_map.set (get_param_pos (param.cdelegate_target_parameter_position + 0.01), cparam);
+ cparam_map.set (get_param_pos (get_ccode_delegate_target_pos (param) + 0.01), cparam);
if (carg_map != null) {
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position + 0.01), get_variable_cexpression (cparam.name));
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param) + 0.01), get_variable_cexpression (cparam.name));
}
}
}
} else if (param.variable_type is MethodType) {
var cparam = new CCodeParameter (get_delegate_target_cname (get_variable_cname (param.name)), target_ctypename);
- cparam_map.set (get_param_pos (param.cdelegate_target_parameter_position), cparam);
+ cparam_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), cparam);
if (carg_map != null) {
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), get_variable_cexpression (cparam.name));
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), get_variable_cexpression (cparam.name));
}
}
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 10da2e8..6abce48 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -51,16 +51,16 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
if (expr.inner is BaseAccess) {
if (m.base_method != null) {
var base_class = (Class) m.base_method.parent_symbol;
- var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (base_class.get_upper_case_cname (null))));
- vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
+ var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (get_ccode_upper_case_name (base_class, null))));
+ vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (current_class, null))));
- set_cvalue (expr, new CCodeMemberAccess.pointer (vcast, m.vfunc_name));
+ set_cvalue (expr, new CCodeMemberAccess.pointer (vcast, get_ccode_vfunc_name (m)));
return;
} else if (m.base_interface_method != null) {
var base_iface = (Interface) m.base_interface_method.parent_symbol;
- string parent_iface_var = "%s_%s_parent_iface".printf (current_class.get_lower_case_cname (null), base_iface.get_lower_case_cname (null));
+ string parent_iface_var = "%s_%s_parent_iface".printf (get_ccode_lower_case_name (current_class), get_ccode_lower_case_name (base_iface));
- set_cvalue (expr, new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), m.vfunc_name));
+ set_cvalue (expr, new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), get_ccode_vfunc_name (m)));
return;
}
}
@@ -68,18 +68,18 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
if (m.base_method != null) {
if (!method_has_wrapper (m.base_method)) {
var base_class = (Class) m.base_method.parent_symbol;
- var vclass = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (base_class.get_upper_case_cname (null))));
+ var vclass = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (get_ccode_upper_case_name (base_class))));
vclass.add_argument (pub_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 ()));
+ set_cvalue (expr, new CCodeIdentifier (get_ccode_real_name (m)));
} 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"));
@@ -96,7 +96,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
// expr.inner is null in the special case of referencing the method in a constant initializer
var delegate_target = (CCodeExpression) get_ccodenode (expr.inner);
delegate_type = expr.target_type as DelegateType;
- if ((expr.value_type.value_owned || (delegate_type != null && delegate_type.is_called_once)) && expr.inner.value_type.data_type != null && expr.inner.value_type.data_type.is_reference_counting ()) {
+ if ((expr.value_type.value_owned || (delegate_type != null && delegate_type.is_called_once)) && expr.inner.value_type.data_type != null && is_reference_counting (expr.inner.value_type.data_type)) {
var ref_call = new CCodeFunctionCall (get_dup_func_expression (expr.inner.value_type, expr.source_reference));
ref_call.add_argument (delegate_target);
delegate_target = ref_call;
@@ -121,7 +121,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;
@@ -143,12 +143,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) {
@@ -169,15 +169,15 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
if (expr.inner is BaseAccess) {
if (prop.base_property != null) {
var base_class = (Class) prop.base_property.parent_symbol;
- var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (base_class.get_upper_case_cname (null))));
- vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
+ var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (get_ccode_upper_case_name (base_class, null))));
+ vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (current_class, null))));
var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, "get_%s".printf (prop.name)));
ccall.add_argument (get_cvalue (expr.inner));
set_cvalue (expr, ccall);
} else if (prop.base_interface_property != null) {
var base_iface = (Interface) prop.base_interface_property.parent_symbol;
- string parent_iface_var = "%s_%s_parent_iface".printf (current_class.get_lower_case_cname (null), base_iface.get_lower_case_cname (null));
+ string parent_iface_var = "%s_%s_parent_iface".printf (get_ccode_lower_case_name (current_class), get_ccode_lower_case_name (base_iface));
var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), "get_%s".printf (prop.name)));
ccall.add_argument (get_cvalue (expr.inner));
@@ -192,8 +192,8 @@ 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()));
- } else if (!prop.no_accessor_method) {
+ set_cvalue (expr, new CCodeMemberAccess.pointer (inst, get_ccode_name (prop.field)));
+ } else if (!get_ccode_no_accessor_method (prop)) {
var base_property = prop;
if (prop.base_property != null) {
base_property = prop.base_property;
@@ -204,7 +204,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));
@@ -234,7 +234,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
ccode.add_assignment (ctemp, ccall);
array_type = base_property.property_type as ArrayType;
- if (array_type != null && !base_property.no_array_length) {
+ if (array_type != null && get_ccode_array_length (base_property)) {
for (int dim = 1; dim <= array_type.rank; dim++) {
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_array_length_cvalue (temp_value, dim)));
}
@@ -250,7 +250,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
ccall.add_argument (pub_inst);
// property name is second argument of g_object_get
- ccall.add_argument (prop.get_canonical_cconstant ());
+ ccall.add_argument (get_property_canonical_cconstant (prop));
// g_object_get always returns owned values
// therefore, property getters of properties
@@ -381,11 +381,11 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
public override TargetValue get_parameter_cvalue (Parameter param) {
var result = new GLibValue (param.variable_type.copy ());
result.lvalue = true;
- result.array_null_terminated = param.array_null_terminated;
- if (param.has_array_length_cexpr) {
- result.array_length_cexpr = new CCodeConstant (param.get_array_length_cexpr ());
+ result.array_null_terminated = get_ccode_array_null_terminated (param);
+ if (get_ccode_array_length_expr (param) != null) {
+ result.array_length_cexpr = new CCodeConstant (get_ccode_array_length_expr (param));
}
- result.ctype = param.ctype;
+ result.ctype = get_ccode_type (param);
var array_type = result.value_type as ArrayType;
var delegate_type = result.value_type as DelegateType;
@@ -417,7 +417,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
block = ((Method) param.parent_symbol).body;
}
result.cvalue = new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_variable_cname (param.name));
- if (array_type != null && !param.no_array_length) {
+ if (array_type != null && get_ccode_array_length (param)) {
for (int dim = 1; dim <= array_type.rank; dim++) {
result.append_array_length_cvalue (new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_parameter_array_length_cname (param, dim)));
}
@@ -475,7 +475,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
}
}
if (!param.captured && array_type != null) {
- if (!param.no_array_length && !param.array_null_terminated) {
+ if (get_ccode_array_length (param) && !get_ccode_array_null_terminated (param)) {
for (int dim = 1; dim <= array_type.rank; dim++) {
CCodeExpression length_expr = get_variable_cexpression (get_parameter_array_length_cname (param, dim));
if (param.direction == ParameterDirection.OUT) {
@@ -502,11 +502,11 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
result.actual_value_type = field.variable_type.get_actual_type (instance.value_type, null, field);
}
result.lvalue = true;
- result.array_null_terminated = field.array_null_terminated;
- if (field.has_array_length_cexpr) {
- result.array_length_cexpr = new CCodeConstant (field.get_array_length_cexpr ());
+ result.array_null_terminated = get_ccode_array_null_terminated (field);
+ if (get_ccode_array_length_expr (field) != null) {
+ result.array_length_cexpr = new CCodeConstant (get_ccode_array_length_expr (field));
}
- result.ctype = field.get_ctype ();
+ result.ctype = get_ccode_type (field);
var array_type = result.value_type as ArrayType;
var delegate_type = result.value_type as DelegateType;
@@ -532,18 +532,18 @@ 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) {
+ if (array_type != null && get_ccode_array_length (field)) {
for (int dim = 1; dim <= array_type.rank; dim++) {
CCodeExpression length_expr = null;
string length_cname;
- if (field.has_array_length_cname) {
- length_cname = field.get_array_length_cname ();
+ if (get_ccode_array_length_name (field) != null) {
+ length_cname = get_ccode_array_length_name (field);
} else {
length_cname = get_array_length_cname (field.name, dim);
}
@@ -565,9 +565,9 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
set_array_size_cvalue (result, new CCodeMemberAccess (inst, size_cname));
}
}
- } 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 ());
+ } else if (delegate_type != null && delegate_type.delegate_symbol.has_target && get_ccode_delegate_target (field)) {
+ 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);
@@ -583,7 +583,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
}
} else if (field.binding == MemberBinding.CLASS) {
var cl = (Class) field.parent_symbol;
- var cast = new CCodeFunctionCall (new CCodeIdentifier (cl.get_upper_case_cname (null) + "_CLASS"));
+ var cast = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_upper_case_name (cl, null) + "_CLASS"));
CCodeExpression klass;
if (instance == null) {
@@ -605,36 +605,36 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
cast.add_argument (klass);
if (field.access == SymbolAccessibility.PRIVATE) {
- var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf (cl.get_upper_case_cname ())));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf (get_ccode_upper_case_name (cl))));
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) {
+ if (array_type != null && get_ccode_array_length (field)) {
for (int dim = 1; dim <= array_type.rank; dim++) {
string length_cname;
- if (field.has_array_length_cname) {
- length_cname = field.get_array_length_cname ();
+ if (get_ccode_array_length_name (field) != null) {
+ length_cname = get_ccode_array_length_name (field);
} 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 ()));
+ } else if (delegate_type != null && delegate_type.delegate_symbol.has_target && get_ccode_delegate_target (field)) {
+ 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)));
}
}
}
@@ -651,7 +651,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
result.array_length_cvalues = null;
result.append_array_length_cvalue (new CCodeConstant (array_type.length.to_string ()));
result.lvalue = false;
- } else if (variable.array_null_terminated) {
+ } else if (get_ccode_array_null_terminated (variable)) {
requires_array_length = true;
var len_call = new CCodeFunctionCall (new CCodeIdentifier ("_vala_array_length"));
len_call.add_argument (result.cvalue);
@@ -659,19 +659,19 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
result.array_length_cvalues = null;
result.append_array_length_cvalue (len_call);
result.lvalue = false;
- } else if (variable.has_array_length_cexpr) {
- var length_expr = new CCodeConstant (variable.get_array_length_cexpr ());
+ } else if (get_ccode_array_length_expr (variable) != null) {
+ var length_expr = new CCodeConstant (get_ccode_array_length_expr (variable));
result.array_length_cvalues = null;
result.append_array_length_cvalue (length_expr);
result.lvalue = false;
- } else if (variable.no_array_length) {
+ } else if (!get_ccode_array_length (variable)) {
result.array_length_cvalues = null;
for (int dim = 1; dim <= array_type.rank; dim++) {
result.append_array_length_cvalue (new CCodeConstant ("-1"));
}
result.lvalue = false;
- } else if (variable.array_length_type != null) {
+ } else if (get_ccode_array_length_type (variable) != null) {
for (int dim = 1; dim <= array_type.rank; dim++) {
// cast if variable does not use int for array length
result.array_length_cvalues[dim - 1] = new CCodeCastExpression (result.array_length_cvalues[dim - 1], "gint");
@@ -680,7 +680,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
}
result.array_size_cvalue = null;
} else if (delegate_type != null) {
- if (!delegate_type.delegate_symbol.has_target || variable.no_delegate_target) {
+ if (!delegate_type.delegate_symbol.has_target || !get_ccode_delegate_target (variable)) {
result.delegate_target_cvalue = new CCodeConstant ("NULL");
}
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index ce536bb..e9a6476 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -60,13 +60,13 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
var cl = (Class) ((ObjectType) itype).type_symbol;
m = cl.default_construction_method;
generate_method_declaration (m, cfile);
- ccall = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname ()));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_real_name (m)));
} else if (itype is StructValueType) {
// constructor
var st = (Struct) ((StructValueType) itype).type_symbol;
m = st.default_construction_method;
generate_method_declaration (m, cfile);
- ccall = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname ()));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_real_name (m)));
} else if (itype is DelegateType) {
deleg = ((DelegateType) itype).delegate_symbol;
}
@@ -77,23 +77,23 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
if (m != null && m.coroutine) {
// async call
- async_call = new CCodeFunctionCall (new CCodeIdentifier (m.get_cname ()));
- var finish_call = new CCodeFunctionCall (new CCodeIdentifier (m.get_finish_cname ()));
+ async_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (m)));
+ var finish_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_finish_name (m)));
if (ma.inner is BaseAccess) {
if (m.base_method != null) {
var base_class = (Class) m.base_method.parent_symbol;
- var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (base_class.get_upper_case_cname (null))));
- vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
+ var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (get_ccode_upper_case_name (base_class, null))));
+ vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (current_class, null))));
- async_call.call = new CCodeMemberAccess.pointer (vcast, m.vfunc_name);
- finish_call.call = new CCodeMemberAccess.pointer (vcast, m.get_finish_vfunc_name ());
+ async_call.call = new CCodeMemberAccess.pointer (vcast, get_ccode_vfunc_name (m));
+ finish_call.call = new CCodeMemberAccess.pointer (vcast, get_ccode_finish_vfunc_name (m));
} else if (m.base_interface_method != null) {
var base_iface = (Interface) m.base_interface_method.parent_symbol;
- string parent_iface_var = "%s_%s_parent_iface".printf (current_class.get_lower_case_cname (null), base_iface.get_lower_case_cname (null));
+ string parent_iface_var = "%s_%s_parent_iface".printf (get_ccode_lower_case_name (current_class), get_ccode_lower_case_name (base_iface));
- async_call.call = new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), m.vfunc_name);
- finish_call.call = new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), m.get_finish_vfunc_name ());
+ async_call.call = new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), get_ccode_vfunc_name (m));
+ finish_call.call = new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), get_ccode_finish_vfunc_name (m));
}
}
@@ -134,7 +134,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
foreach (DataType base_type in current_class.get_base_types ()) {
if (base_type.data_type is Class) {
List<TypeParameter> type_parameters = null;
- if (m.get_real_cname () == "g_object_new") {
+ if (get_ccode_real_name (m) == "g_object_new") {
// gobject-style chainup
type_parameters = ((Class) base_type.data_type).get_type_parameters ();
}
@@ -156,7 +156,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
}
} else if (m is CreationMethod && m.parent_symbol is Struct) {
ccall.add_argument (new CCodeIdentifier ("self"));
- } else if (m != null && m.get_type_parameters ().size > 0 && !m.has_generic_type_parameter && !m.simple_generics) {
+ } else if (m != null && m.get_type_parameters ().size > 0 && !get_ccode_has_generic_type_parameter (m) && !get_ccode_simple_generics (m)) {
// generic method
add_generic_type_arguments (in_arg_map, ma.get_type_arguments (), expr);
}
@@ -166,7 +166,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;
}
@@ -180,8 +180,8 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
instance = new CCodeIdentifier ("_data_");
}
- in_arg_map.set (get_param_pos (m.cinstance_parameter_position), instance);
- out_arg_map.set (get_param_pos (m.cinstance_parameter_position), instance);
+ in_arg_map.set (get_param_pos (get_ccode_instance_pos (m)), instance);
+ out_arg_map.set (get_param_pos (get_ccode_instance_pos (m)), instance);
} else if (m != null && m.binding == MemberBinding.INSTANCE && !(m is CreationMethod)) {
var instance_value = ma.inner.target_value;
if ((ma.member_name == "begin" || ma.member_name == "end") && ma.inner.symbol_reference == ma.symbol_reference) {
@@ -199,11 +199,11 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
instance = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_cvalue_ (instance_value));
}
- in_arg_map.set (get_param_pos (m.cinstance_parameter_position), instance);
- out_arg_map.set (get_param_pos (m.cinstance_parameter_position), instance);
+ in_arg_map.set (get_param_pos (get_ccode_instance_pos (m)), instance);
+ out_arg_map.set (get_param_pos (get_ccode_instance_pos (m)), instance);
} else if (m != null && m.binding == MemberBinding.CLASS) {
var cl = (Class) m.parent_symbol;
- var cast = new CCodeFunctionCall (new CCodeIdentifier (cl.get_upper_case_cname (null) + "_CLASS"));
+ var cast = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_upper_case_name (cl, null) + "_CLASS"));
CCodeExpression klass;
if (ma.inner == null) {
@@ -224,24 +224,24 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
}
cast.add_argument (klass);
- in_arg_map.set (get_param_pos (m.cinstance_parameter_position), cast);
- out_arg_map.set (get_param_pos (m.cinstance_parameter_position), cast);
+ in_arg_map.set (get_param_pos (get_ccode_instance_pos (m)), cast);
+ out_arg_map.set (get_param_pos (get_ccode_instance_pos (m)), cast);
}
- if (m != null && m.has_generic_type_parameter) {
+ if (m != null && get_ccode_has_generic_type_parameter (m)) {
// insert type argument for macros
if (m.get_type_parameters ().size > 0) {
// 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 (get_ccode_generic_type_pos (m) + 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 (get_ccode_generic_type_pos (m) + 0.01 * type_param_index), new CCodeIdentifier (get_ccode_name (type_arg)));
type_param_index++;
}
}
@@ -250,7 +250,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 ();
@@ -278,7 +278,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
@@ -329,16 +329,16 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
var unary = arg as UnaryExpression;
if (unary == null || unary.operator != UnaryOperator.OUT) {
- if (!param.no_array_length && param.variable_type is ArrayType) {
+ if (get_ccode_array_length (param) && param.variable_type is ArrayType) {
var array_type = (ArrayType) param.variable_type;
for (int dim = 1; dim <= array_type.rank; dim++) {
CCodeExpression? array_length_expr = null;
- if (param.array_length_type != null) {
- array_length_expr = new CCodeCastExpression (get_array_length_cexpression (arg, dim), param.array_length_type);
+ if (get_ccode_array_length_type (param) != null) {
+ array_length_expr = new CCodeCastExpression (get_array_length_cexpression (arg, dim), get_ccode_array_length_type (param));
} else {
array_length_expr = get_array_length_cexpression (arg, dim);
}
- carg_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), array_length_expr);
+ carg_map.set (get_param_pos (get_ccode_array_length_pos (param) + 0.01 * dim), array_length_expr);
}
} else if (param.variable_type is DelegateType) {
var deleg_type = (DelegateType) param.variable_type;
@@ -347,7 +347,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
CCodeExpression delegate_target_destroy_notify;
var delegate_target = get_delegate_target_cexpression (arg, out delegate_target_destroy_notify);
assert (delegate_target != null);
- if (param.ctype == "GClosure*") {
+ if (get_ccode_type (param) == "GClosure*") {
// one single GClosure parameter
var closure_new = new CCodeFunctionCall (new CCodeIdentifier ("g_cclosure_new"));
closure_new.add_argument (new CCodeCastExpression (cexpr, "GCallback"));
@@ -355,27 +355,27 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
closure_new.add_argument (delegate_target_destroy_notify);
cexpr = new CCodeConditionalExpression (new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, cexpr, new CCodeIdentifier ("NULL")), new CCodeIdentifier ("NULL"), closure_new);
} else {
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), delegate_target);
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), delegate_target);
if (deleg_type.value_owned) {
assert (delegate_target_destroy_notify != null);
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position + 0.01), delegate_target_destroy_notify);
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param) + 0.01), delegate_target_destroy_notify);
}
}
}
} else if (param.variable_type is MethodType) {
// callbacks in dynamic method calls
CCodeExpression delegate_target_destroy_notify;
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), get_delegate_target_cexpression (arg, out delegate_target_destroy_notify));
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), get_delegate_target_cexpression (arg, out delegate_target_destroy_notify));
} else if (param.variable_type is GenericType) {
- if (m != null && m.simple_generics) {
+ if (m != null && get_ccode_simple_generics (m)) {
var generic_type = (GenericType) param.variable_type;
int type_param_index = m.get_type_parameter_index (generic_type.type_parameter.name);
var type_arg = ma.get_type_arguments ().get (type_param_index);
if (param.variable_type.value_owned) {
if (requires_copy (type_arg)) {
- carg_map.set (get_param_pos (param.cdestroy_notify_parameter_position), get_destroy_func_expression (type_arg));
+ carg_map.set (get_param_pos (get_ccode_destroy_notify_pos (param)), get_destroy_func_expression (type_arg));
} else {
- carg_map.set (get_param_pos (param.cdestroy_notify_parameter_position), new CCodeConstant ("NULL"));
+ carg_map.set (get_param_pos (get_ccode_destroy_notify_pos (param)), new CCodeConstant ("NULL"));
}
}
}
@@ -392,17 +392,17 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
cexpr = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_cvalue (arg));
- if (!param.no_array_length && param.variable_type is ArrayType) {
+ if (get_ccode_array_length (param) && param.variable_type is ArrayType) {
var array_type = (ArrayType) param.variable_type;
var array_length_type = int_type;
- if (param.array_length_type != null) {
- array_length_type = new CType (param.array_length_type);
+ if (get_ccode_array_length_type (param) != null) {
+ array_length_type = new CType (get_ccode_array_length_type (param));
}
for (int dim = 1; dim <= array_type.rank; dim++) {
var temp_array_length = get_temp_variable (array_length_type);
emit_temp_var (temp_array_length);
append_array_length (arg, get_variable_cexpression (temp_array_length.name));
- carg_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_array_lengths (arg).get (dim - 1)));
+ carg_map.set (get_param_pos (get_ccode_array_length_pos (param) + 0.01 * dim), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_array_lengths (arg).get (dim - 1)));
}
} else if (param.variable_type is DelegateType) {
var deleg_type = (DelegateType) param.variable_type;
@@ -411,24 +411,24 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
temp_var = get_temp_variable (new PointerType (new VoidType ()));
emit_temp_var (temp_var);
set_delegate_target (arg, get_variable_cexpression (temp_var.name));
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_delegate_target (arg)));
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_delegate_target (arg)));
if (deleg_type.value_owned) {
temp_var = get_temp_variable (gdestroynotify_type);
emit_temp_var (temp_var);
set_delegate_target_destroy_notify (arg, get_variable_cexpression (temp_var.name));
- carg_map.set (get_param_pos (param.cdelegate_target_parameter_position + 0.01), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_delegate_target_destroy_notify (arg)));
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param) + 0.01), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_delegate_target_destroy_notify (arg)));
}
}
}
}
- if (param.ctype != null) {
- cexpr = new CCodeCastExpression (cexpr, param.ctype);
+ if (get_ccode_type (param) != null) {
+ cexpr = new CCodeCastExpression (cexpr, get_ccode_type (param));
}
} else {
cexpr = handle_struct_argument (null, arg, cexpr);
}
- arg_pos = get_param_pos (param.cparameter_position, ellipsis);
+ arg_pos = get_param_pos (get_ccode_pos (param), ellipsis);
} else {
// default argument position
cexpr = handle_struct_argument (null, arg, cexpr);
@@ -460,7 +460,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
if (m != null && m.return_type is ArrayType && async_call != ccall) {
var array_type = (ArrayType) m.return_type;
for (int dim = 1; dim <= array_type.rank; dim++) {
- if (m.array_null_terminated) {
+ if (get_ccode_array_null_terminated (m)) {
// handle calls to methods returning null-terminated arrays
var temp_var = get_temp_variable (itype.get_return_type (), true, null, false);
var temp_ref = get_variable_cexpression (temp_var.name);
@@ -474,19 +474,19 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
len_call.add_argument (temp_ref);
append_array_length (expr, len_call);
- } else if (!m.no_array_length) {
+ } else if (get_ccode_array_length (m)) {
LocalVariable temp_var;
- if (m.array_length_type == null) {
+ if (get_ccode_array_length_type (m) == null) {
temp_var = get_temp_variable (int_type);
} else {
- temp_var = get_temp_variable (new CType (m.array_length_type));
+ temp_var = get_temp_variable (new CType (get_ccode_array_length_type (m)));
}
var temp_ref = get_variable_cexpression (temp_var.name);
emit_temp_var (temp_var);
- out_arg_map.set (get_param_pos (m.carray_length_parameter_position + 0.01 * dim), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
+ out_arg_map.set (get_param_pos (get_ccode_array_length_pos (m) + 0.01 * dim), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
append_array_length (expr, temp_ref);
} else {
@@ -502,7 +502,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
emit_temp_var (temp_var);
- out_arg_map.set (get_param_pos (m.cdelegate_target_parameter_position), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
+ out_arg_map.set (get_param_pos (get_ccode_delegate_target_pos (m)), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
set_delegate_target (expr, temp_ref);
@@ -512,7 +512,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
emit_temp_var (temp_var);
- out_arg_map.set (get_param_pos (m.cdelegate_target_parameter_position + 0.01), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
+ out_arg_map.set (get_param_pos (get_ccode_delegate_target_pos (m) + 0.01), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
set_delegate_target_destroy_notify (expr, temp_ref);
} else {
@@ -528,7 +528,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
if (deleg != null && deleg.return_type is ArrayType) {
var array_type = (ArrayType) deleg.return_type;
for (int dim = 1; dim <= array_type.rank; dim++) {
- if (deleg.array_null_terminated) {
+ if (get_ccode_array_null_terminated (deleg)) {
// handle calls to methods returning null-terminated arrays
var temp_var = get_temp_variable (itype.get_return_type (), true, null, false);
var temp_ref = get_variable_cexpression (temp_var.name);
@@ -542,13 +542,13 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
len_call.add_argument (temp_ref);
append_array_length (expr, len_call);
- } else if (!deleg.no_array_length) {
+ } else if (get_ccode_array_length (deleg)) {
var temp_var = get_temp_variable (int_type);
var temp_ref = get_variable_cexpression (temp_var.name);
emit_temp_var (temp_var);
- out_arg_map.set (get_param_pos (deleg.carray_length_parameter_position + 0.01 * dim), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
+ out_arg_map.set (get_param_pos (get_ccode_array_length_pos (deleg) + 0.01 * dim), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
append_array_length (expr, temp_ref);
} else {
@@ -564,7 +564,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
emit_temp_var (temp_var);
- out_arg_map.set (get_param_pos (deleg.cdelegate_target_parameter_position), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
+ out_arg_map.set (get_param_pos (get_ccode_delegate_target_pos (deleg)), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
set_delegate_target (expr, temp_ref);
}
@@ -589,9 +589,9 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
/* ensure variable argument list ends with NULL
* except when using printf-style arguments */
if (m == null) {
- in_arg_map.set (get_param_pos (-1, true), new CCodeConstant (Method.DEFAULT_SENTINEL));
- } else if (!m.printf_format && !m.scanf_format && m.sentinel != "") {
- in_arg_map.set (get_param_pos (-1, true), new CCodeConstant (m.sentinel));
+ in_arg_map.set (get_param_pos (-1, true), new CCodeConstant ("NULL"));
+ } else if (!m.printf_format && !m.scanf_format && get_ccode_sentinel (m) != "") {
+ in_arg_map.set (get_param_pos (-1, true), new CCodeConstant (get_ccode_sentinel (m)));
}
}
@@ -600,8 +600,8 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
var d = deleg_type.delegate_symbol;
if (d.has_target) {
CCodeExpression delegate_target_destroy_notify;
- in_arg_map.set (get_param_pos (d.cinstance_parameter_position), get_delegate_target_cexpression (expr.call, out delegate_target_destroy_notify));
- out_arg_map.set (get_param_pos (d.cinstance_parameter_position), get_delegate_target_cexpression (expr.call, out delegate_target_destroy_notify));
+ in_arg_map.set (get_param_pos (get_ccode_instance_pos (d)), get_delegate_target_cexpression (expr.call, out delegate_target_destroy_notify));
+ out_arg_map.set (get_param_pos (get_ccode_instance_pos (d)), get_delegate_target_cexpression (expr.call, out delegate_target_destroy_notify));
}
}
@@ -614,7 +614,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
if (ma != null && ma.inner is BaseAccess && sig.is_virtual) {
// normal return value for base access
- } else if (!sig.has_emitter) {
+ } else if (!get_signal_has_emitter (sig)) {
return_result_via_out_param = true;
}
}
@@ -710,7 +710,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);
@@ -744,7 +744,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
@@ -787,7 +787,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
}
private string generate_enum_tostring_function (Enum en) {
- var to_string_func = "_%s_to_string".printf (en.get_lower_case_cname ());
+ var to_string_func = "_%s_to_string".printf (get_ccode_lower_case_name (en));
if (!add_wrapper (to_string_func)) {
// wrapper already defined
@@ -798,7 +798,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 ());
@@ -806,8 +806,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 7b675b9..9d8a802 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -31,12 +31,8 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
return (method.get_attribute ("NoWrapper") == null);
}
- public override string? get_custom_creturn_type (Method m) {
- return m.custom_return_type_cname;
- }
-
string get_creturn_type (Method m, string default_value) {
- string type = get_custom_creturn_type (m);
+ string type = get_ccode_type (m);
if (type == null) {
return default_value;
}
@@ -67,28 +63,28 @@ 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 ());
}
- } else if (!m.no_array_length && m.return_type is ArrayType) {
+ } else if (get_ccode_array_length (m) && m.return_type is ArrayType) {
// return array length if appropriate
var array_type = (ArrayType) m.return_type;
- var array_length_type = m.array_length_type != null ? m.array_length_type : "int";
+ var array_length_type = get_ccode_array_length_type (m) != null ? get_ccode_array_length_type (m) : "int";
array_length_type += "*";
for (int dim = 1; dim <= array_type.rank; dim++) {
var cparam = new CCodeParameter (get_array_length_cname ("result", dim), array_length_type);
- cparam_map.set (get_param_pos (m.carray_length_parameter_position + 0.01 * dim), cparam);
+ cparam_map.set (get_param_pos (get_ccode_array_length_pos (m) + 0.01 * dim), cparam);
if (carg_map != null) {
- carg_map.set (get_param_pos (m.carray_length_parameter_position + 0.01 * dim), get_variable_cexpression (cparam.name));
+ carg_map.set (get_param_pos (get_ccode_array_length_pos (m) + 0.01 * dim), get_variable_cexpression (cparam.name));
}
}
} else if (m.return_type is DelegateType) {
@@ -97,15 +93,15 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
var d = deleg_type.delegate_symbol;
if (d.has_target) {
var cparam = new CCodeParameter (get_delegate_target_cname ("result"), "void**");
- cparam_map.set (get_param_pos (m.cdelegate_target_parameter_position), cparam);
+ cparam_map.set (get_param_pos (get_ccode_delegate_target_pos (m)), cparam);
if (carg_map != null) {
- carg_map.set (get_param_pos (m.cdelegate_target_parameter_position), get_variable_cexpression (cparam.name));
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (m)), get_variable_cexpression (cparam.name));
}
if (deleg_type.value_owned) {
cparam = new CCodeParameter (get_delegate_target_destroy_notify_cname ("result"), "GDestroyNotify*");
- cparam_map.set (get_param_pos (m.cdelegate_target_parameter_position + 0.01), cparam);
+ cparam_map.set (get_param_pos (get_ccode_delegate_target_pos (m) + 0.01), cparam);
if (carg_map != null) {
- carg_map.set (get_param_pos (m.cdelegate_target_parameter_position + 0.01), get_variable_cexpression (cparam.name));
+ carg_map.set (get_param_pos (get_ccode_delegate_target_pos (m) + 0.01), get_variable_cexpression (cparam.name));
}
}
}
@@ -155,11 +151,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;
@@ -186,7 +182,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
if (m is CreationMethod && cl != null) {
// _construct function
- function = new CCodeFunction (m.get_real_cname ());
+ function = new CCodeFunction (get_ccode_real_name (m));
if (m.is_private_symbol ()) {
function.modifiers |= CCodeModifiers.STATIC;
@@ -248,7 +244,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
}
}
- var register_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_register_type".printf (type_symbol.get_lower_case_cname (null))));
+ var register_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_register_type".printf (get_ccode_lower_case_name (type_symbol, null))));
register_call.add_argument (new CCodeIdentifier (module_init_param_name));
ccode.add_expression (register_call);
}
@@ -262,6 +258,10 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
check_type (m.return_type);
+ if (m.get_attribute ("NoArrayLength") != null) {
+ Report.deprecated (m.source_reference, "NoArrayLength attribute is deprecated, use [CCode (array_length = false)] instead.");
+ }
+
if (m is CreationMethod) {
var cl = current_type_symbol as Class;
if (cl != null && !cl.is_compact) {
@@ -306,7 +306,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
}
CCodeFunction function;
- function = new CCodeFunction (m.get_real_cname ());
+ function = new CCodeFunction (get_ccode_real_name (m));
if (m.is_inline) {
function.modifiers |= CCodeModifiers.INLINE;
@@ -329,11 +329,10 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
}
} else {
if (m.body != null) {
- function = new CCodeFunction (m.get_real_cname () + "_co", "gboolean");
+ function = new CCodeFunction (get_ccode_real_name (m) + "_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_const_name (m)) + "Data*"));
function.modifiers |= CCodeModifiers.STATIC;
cfile.add_function_declaration (function);
}
@@ -397,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);
}
@@ -432,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"), true), 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)) {
@@ -453,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 ("_vala_" + 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
@@ -485,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 ()) {
@@ -522,18 +521,18 @@ 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);
}
if (cl.base_class == null) {
// derived compact classes do not have fields
- var cinitcall = new CCodeFunctionCall (new CCodeIdentifier ("%s_instance_init".printf (cl.get_lower_case_cname (null))));
+ var cinitcall = new CCodeFunctionCall (new CCodeIdentifier ("%s_instance_init".printf (get_ccode_lower_case_name (cl, null))));
cinitcall.add_argument (new CCodeIdentifier ("self"));
ccode.add_expression (cinitcall);
}
@@ -545,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);
}
}
@@ -622,8 +621,8 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
if (current_type_symbol is Class) {
CCodeExpression cresult = new CCodeIdentifier ("self");
- if (get_custom_creturn_type (m) != null) {
- cresult = new CCodeCastExpression (cresult, get_custom_creturn_type (m));
+ if (get_ccode_type (m) != null) {
+ cresult = new CCodeCastExpression (cresult, get_ccode_type (m));
}
ccode.add_return (cresult);
@@ -649,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));
@@ -728,7 +727,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);
@@ -755,9 +754,9 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
cparam = new CCodeParameter.with_ellipsis ();
}
- cparam_map.set (get_param_pos (param.cparameter_position, param.ellipsis), cparam);
+ cparam_map.set (get_param_pos (get_ccode_pos (param), param.ellipsis), cparam);
if (carg_map != null && !param.ellipsis) {
- carg_map.set (get_param_pos (param.cparameter_position, param.ellipsis), get_variable_cexpression (param.name));
+ carg_map.set (get_param_pos (get_ccode_pos (param), param.ellipsis), get_variable_cexpression (param.name));
}
return cparam;
@@ -768,11 +767,11 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
var closure_block = current_closure_block;
int block_id = get_block_id (closure_block);
var instance_param = new CCodeParameter ("_data%d_".printf (block_id), "Block%dData*".printf (block_id));
- cparam_map.set (get_param_pos (m.cinstance_parameter_position), instance_param);
+ cparam_map.set (get_param_pos (get_ccode_instance_pos (m)), instance_param);
} else if (m.parent_symbol is Class && m is CreationMethod) {
var cl = (Class) m.parent_symbol;
if (!cl.is_compact && vcall == null) {
- cparam_map.set (get_param_pos (m.cinstance_parameter_position), new CCodeParameter ("object_type", "GType"));
+ cparam_map.set (get_param_pos (get_ccode_instance_pos (m)), new CCodeParameter ("object_type", "GType"));
}
} else if (m.binding == MemberBinding.INSTANCE || (m.parent_symbol is Struct && m is CreationMethod)) {
TypeSymbol parent_type = find_parent_type (m);
@@ -794,24 +793,24 @@ 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);
+ cparam_map.set (get_param_pos (get_ccode_instance_pos (m)), instance_param);
} else if (m.binding == MemberBinding.CLASS) {
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 ());
- cparam_map.set (get_param_pos (m.cinstance_parameter_position), class_param);
+ var class_param = new CCodeParameter ("klass", get_ccode_name (this_type));
+ cparam_map.set (get_param_pos (get_ccode_instance_pos (m)), class_param);
}
if (is_gtypeinstance_creation_method (m)) {
@@ -894,7 +893,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);
}
@@ -904,20 +903,20 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
if (m.parent_symbol is Interface) {
var iface = (Interface) m.parent_symbol;
- vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_INTERFACE".printf (iface.get_upper_case_cname (null))));
+ vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_INTERFACE".printf (get_ccode_upper_case_name (iface))));
} else {
var cl = (Class) m.parent_symbol;
- vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (cl.get_upper_case_cname (null))));
+ vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (get_ccode_upper_case_name (cl))));
}
vcast.add_argument (new CCodeIdentifier ("self"));
- cname = m.vfunc_name;
+ cname = get_ccode_vfunc_name (m);
if (suffix == "_finish" && cname.has_suffix ("_async")) {
cname = cname.substring (0, cname.length - "_async".length);
}
var vcall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, cname + suffix));
- carg_map.set (get_param_pos (m.cinstance_parameter_position), new CCodeIdentifier ("self"));
+ carg_map.set (get_param_pos (get_ccode_instance_pos (m)), new CCodeIdentifier ("self"));
generate_cparameters (m, cfile, cparam_map, vfunc, null, carg_map, vcall, direction);
@@ -934,7 +933,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);
}
@@ -1013,15 +1012,15 @@ 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);
push_function (vfunc);
- var vcall = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname ()));
- vcall.add_argument (new CCodeIdentifier (current_class.get_type_id ()));
+ var vcall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_real_name (m)));
+ vcall.add_argument (new CCodeIdentifier (get_ccode_type_id (current_class)));
generate_cparameters (m, cfile, cparam_map, vfunc, null, carg_map, vcall);
ccode.add_return (vcall);
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index 6f5439a..4d2aaa1 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -26,31 +26,25 @@ 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;
}
if (st.is_boolean_type ()) {
// typedef for boolean types
decl_space.add_include ("stdbool.h");
- st.set_cname ("bool");
return;
} else if (st.is_integer_type ()) {
// typedef for integral types
decl_space.add_include ("stdint.h");
- st.set_cname ("%sint%d_t".printf (st.signed ? "" : "u", st.width));
- return;
- } else if (st.is_floating_type ()) {
- // typedef for floating types
- st.set_cname (st.width == 64 ? "double" : "float");
return;
}
if (context.profile == Profile.GOBJECT) {
- if (st.has_type_id) {
+ if (get_ccode_has_type_id (st)) {
decl_space.add_type_declaration (new CCodeNewline ());
- var macro = "(%s_get_type ())".printf (st.get_lower_case_cname (null));
- decl_space.add_type_declaration (new CCodeMacroReplacement (st.get_type_id (), macro));
+ var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (st, null));
+ decl_space.add_type_declaration (new CCodeMacroReplacement (get_ccode_type_id (st), macro));
var type_fun = new StructRegisterFunction (st, context);
type_fun.init_from_type (false, true);
@@ -58,11 +52,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,8 +64,8 @@ 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);
- if (f.variable_type is ArrayType && !f.no_array_length) {
+ 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 && get_ccode_array_length (f)) {
// create fields to store array dimensions
var array_type = (ArrayType) f.variable_type;
@@ -80,16 +74,16 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
for (int dim = 1; dim <= array_type.rank; dim++) {
string length_cname;
- if (f.has_array_length_cname) {
- length_cname = f.get_array_length_cname ();
+ if (get_ccode_array_length_name (f) != null) {
+ length_cname = get_ccode_array_length_name (f);
} 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,41 +100,41 @@ 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 (get_ccode_dup_function (st), 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");
+ function = new CCodeFunction (get_ccode_free_function (st), "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 ()) {
- function = new CCodeFunction (st.get_copy_function (), "void");
+ function = new CCodeFunction (get_ccode_copy_function (st), "void");
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");
+ function = new CCodeFunction (get_ccode_destroy_function (st), "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);
}
}
@@ -186,24 +180,24 @@ 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 (get_ccode_dup_function (st), 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);
if (st.is_disposable ()) {
- var copy_call = new CCodeFunctionCall (new CCodeIdentifier (st.get_copy_function ()));
+ var copy_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_copy_function (st)));
copy_call.add_argument (new CCodeIdentifier ("self"));
copy_call.add_argument (new CCodeIdentifier ("dup"));
ccode.add_expression (copy_call);
@@ -211,7 +205,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"));
@@ -228,17 +222,17 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
}
void add_struct_free_function (Struct st) {
- var function = new CCodeFunction (st.get_free_function (), "void");
+ var function = new CCodeFunction (get_ccode_free_function (st), "void");
if (st.access == SymbolAccessibility.PRIVATE) {
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);
if (st.is_disposable ()) {
- var destroy_call = new CCodeFunctionCall (new CCodeIdentifier (st.get_destroy_function ()));
+ var destroy_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_destroy_function (st)));
destroy_call.add_argument (new CCodeIdentifier ("self"));
ccode.add_expression (destroy_call);
}
@@ -253,13 +247,13 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
}
void add_struct_copy_function (Struct st) {
- var function = new CCodeFunction (st.get_copy_function (), "void");
+ var function = new CCodeFunction (get_ccode_copy_function (st), "void");
if (st.access == SymbolAccessibility.PRIVATE) {
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);
@@ -286,12 +280,12 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
void begin_struct_destroy_function (Struct st) {
push_context (instance_finalize_context);
- var function = new CCodeFunction (st.get_destroy_function (), "void");
+ var function = new CCodeFunction (get_ccode_destroy_function (st), "void");
if (st.access == SymbolAccessibility.PRIVATE) {
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..cc9b95e 100644
--- a/codegen/valaclassregisterfunction.vala
+++ b/codegen/valaclassregisterfunction.vala
@@ -47,12 +47,12 @@ 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 () {
if (class_reference.class_constructor != null || (!context.require_glib_version (2, 24) && class_reference.has_class_private_fields)) {
- return "%s_base_init".printf (class_reference.get_lower_case_cname (null));
+ return "%s_base_init".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null));
} else {
return "NULL";
}
@@ -60,7 +60,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
public override string get_class_finalize_func_name () {
if (class_reference.static_destructor != null) {
- return "%s_class_finalize".printf (class_reference.get_lower_case_cname (null));
+ return "%s_class_finalize".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null));
} else {
return "NULL";
}
@@ -68,26 +68,26 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
public override string get_base_finalize_func_name () {
if (class_reference.class_destructor != null || (!context.require_glib_version (2, 24) && class_reference.has_class_private_fields)) {
- return "%s_base_finalize".printf (class_reference.get_lower_case_cname (null));
+ return "%s_base_finalize".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null));
} else {
return "NULL";
}
}
public override string get_class_init_func_name () {
- return "%s_class_init".printf (class_reference.get_lower_case_cname (null));
+ return "%s_class_init".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null));
}
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 () {
- return "%s_instance_init".printf (class_reference.get_lower_case_cname (null));
+ return "%s_instance_init".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null));
}
public override string get_parent_type_name () {
- return class_reference.base_class.get_type_id ();
+ return CCodeBaseModule.get_ccode_type_id (class_reference.base_class);
}
public override string get_type_flags () {
@@ -105,7 +105,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
public override string? get_gtype_value_table_init_function_name () {
bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
if ( is_fundamental )
- return "%s_init".printf (class_reference.get_lower_case_cname ("value_"));
+ return "%s_init".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, "value_"));
return null;
}
@@ -113,7 +113,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
public override string? get_gtype_value_table_free_function_name () {
bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
if ( is_fundamental )
- return "%s_free_value".printf (class_reference.get_lower_case_cname ("value_"));
+ return "%s_free_value".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, "value_"));
return null;
}
@@ -121,7 +121,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
public override string? get_gtype_value_table_copy_function_name () {
bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
if ( is_fundamental )
- return "%s_copy_value".printf (class_reference.get_lower_case_cname ("value_"));
+ return "%s_copy_value".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, "value_"));
return null;
}
@@ -129,7 +129,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
public override string? get_gtype_value_table_peek_pointer_function_name () {
bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
if ( is_fundamental )
- return "%s_peek_pointer".printf (class_reference.get_lower_case_cname ("value_"));
+ return "%s_peek_pointer".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, "value_"));
return null;
}
@@ -137,7 +137,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
public override string? get_gtype_value_table_collect_value_function_name () {
bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
if ( is_fundamental )
- return "%s_collect_value".printf (class_reference.get_lower_case_cname ("value_"));
+ return "%s_collect_value".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, "value_"));
return null;
}
@@ -145,7 +145,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
public override string? get_gtype_value_table_lcopy_value_function_name () {
bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
if ( is_fundamental )
- return "%s_lcopy_value".printf (class_reference.get_lower_case_cname ("value_"));
+ return "%s_lcopy_value".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, "value_"));
return null;
}
@@ -160,11 +160,11 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
var iface = (Interface) base_type.data_type;
- var iface_info_name = "%s_info".printf (iface.get_lower_case_cname (null));
+ var iface_info_name = "%s_info".printf (CCodeBaseModule.get_ccode_lower_case_name (iface, null));
var ctypedecl = new CCodeDeclaration ("const GInterfaceInfo");
ctypedecl.modifiers = CCodeModifiers.STATIC;
- ctypedecl.add_declarator (new CCodeVariableDeclarator (iface_info_name, new CCodeConstant ("{ (GInterfaceInitFunc) %s_%s_interface_init, (GInterfaceFinalizeFunc) NULL, NULL}".printf (class_reference.get_lower_case_cname (null), iface.get_lower_case_cname (null)))));
+ ctypedecl.add_declarator (new CCodeVariableDeclarator (iface_info_name, new CCodeConstant ("{ (GInterfaceInitFunc) %s_%s_interface_init, (GInterfaceFinalizeFunc) NULL, NULL}".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference), CCodeBaseModule.get_ccode_lower_case_name (iface)))));
frag.append (ctypedecl);
}
@@ -179,18 +179,18 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
var iface = (Interface) base_type.data_type;
- var iface_info_name = "%s_info".printf (iface.get_lower_case_cname (null));
+ var iface_info_name = "%s_info".printf (CCodeBaseModule.get_ccode_lower_case_name (iface, null));
if (!plugin) {
var reg_call = new CCodeFunctionCall (new CCodeIdentifier ("g_type_add_interface_static"));
- reg_call.add_argument (new CCodeIdentifier ("%s_type_id".printf (class_reference.get_lower_case_cname (null))));
- reg_call.add_argument (new CCodeIdentifier (iface.get_type_id ()));
+ reg_call.add_argument (new CCodeIdentifier ("%s_type_id".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null))));
+ reg_call.add_argument (new CCodeIdentifier (CCodeBaseModule.get_ccode_type_id (iface)));
reg_call.add_argument (new CCodeIdentifier ("&%s".printf (iface_info_name)));
block.add_statement (new CCodeExpressionStatement (reg_call));
} else {
var reg_call = new CCodeFunctionCall (new CCodeIdentifier ("g_type_module_add_interface"));
reg_call.add_argument (new CCodeIdentifier ("module"));
- reg_call.add_argument (new CCodeIdentifier ("%s_type_id".printf (class_reference.get_lower_case_cname (null))));
- reg_call.add_argument (new CCodeIdentifier (iface.get_type_id ()));
+ reg_call.add_argument (new CCodeIdentifier ("%s_type_id".printf (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null))));
+ reg_call.add_argument (new CCodeIdentifier (CCodeBaseModule.get_ccode_type_id (iface)));
reg_call.add_argument (new CCodeIdentifier ("&%s".printf (iface_info_name)));
block.add_statement (new CCodeExpressionStatement (reg_call));
}
diff --git a/codegen/valactype.vala b/codegen/valactype.vala
index c29438c..1190299 100644
--- a/codegen/valactype.vala
+++ b/codegen/valactype.vala
@@ -36,8 +36,4 @@ public class Vala.CType : DataType {
public override DataType copy () {
return new CType (ctype_name);
}
-
- public override string? get_cname () {
- return ctype_name;
- }
}
diff --git a/codegen/valadovaarraymodule.vala b/codegen/valadovaarraymodule.vala
index 4a3150c..0246cf7 100644
--- a/codegen/valadovaarraymodule.vala
+++ b/codegen/valadovaarraymodule.vala
@@ -82,7 +82,7 @@ public class Vala.DovaArrayModule : DovaMethodCallModule {
var array_type = (ArrayType) expr.container.value_type;
var array = new CCodeFunctionCall (new CCodeIdentifier ("dova_array"));
- array.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeCastExpression (new CCodeMemberAccess (ccontainer, "data"), array_type.element_type.get_cname () + "*"), cstart));
+ array.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeCastExpression (new CCodeMemberAccess (ccontainer, "data"), get_ccode_name (array_type.element_type) + "*"), cstart));
array.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.MINUS, cstop, cstart));
set_cvalue (expr, array);
diff --git a/codegen/valadovaassignmentmodule.vala b/codegen/valadovaassignmentmodule.vala
index 857c30e..572b24c 100644
--- a/codegen/valadovaassignmentmodule.vala
+++ b/codegen/valadovaassignmentmodule.vala
@@ -93,7 +93,7 @@ public class Vala.DovaAssignmentModule : DovaMemberAccessModule {
// 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);
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index 1db5f99..87bff4a 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -333,7 +333,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
}
if (sym.external_package || (!decl_space.is_header && CodeContext.get ().use_header && !sym.is_internal_symbol ())) {
// add appropriate include file
- foreach (string header_filename in sym.get_cheader_filenames ()) {
+ foreach (string header_filename in CCodeBaseModule.get_ccode_header_filenames (sym).split (",")) {
decl_space.add_include (header_filename, !sym.external_package);
}
// declaration complete
@@ -364,18 +364,18 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
}
public void 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;
}
- var cenum = new CCodeEnum (en.get_cname ());
+ var cenum = new CCodeEnum (get_ccode_name (en));
foreach (EnumValue ev in en.get_values ()) {
if (ev.value == null) {
- cenum.add_value (new CCodeEnumValue (ev.get_cname ()));
+ cenum.add_value (new CCodeEnumValue (get_ccode_name (ev)));
} else {
ev.value.emit (this);
- cenum.add_value (new CCodeEnumValue (ev.get_cname (), get_cvalue (ev.value)));
+ cenum.add_value (new CCodeEnumValue (get_ccode_name (ev), get_cvalue (ev.value)));
}
}
@@ -394,7 +394,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
}
public void generate_constant_declaration (Constant c, CCodeFile decl_space) {
- if (add_symbol_declaration (decl_space, c, c.get_cname ())) {
+ if (add_symbol_declaration (decl_space, c, get_ccode_name (c))) {
return;
}
@@ -402,17 +402,17 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
c.value.emit (this);
if (c.value is InitializerList) {
- var cdecl = new CCodeDeclaration (c.type_reference.get_const_cname ());
+ var cdecl = new CCodeDeclaration (get_ccode_const_name (c.type_reference));
var arr = "";
if (c.type_reference is ArrayType) {
arr = "[]";
}
- cdecl.add_declarator (new CCodeVariableDeclarator ("%s%s".printf (c.get_cname (), arr), get_cvalue (c.value)));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("%s%s".printf (get_ccode_name (c), arr), get_cvalue (c.value)));
cdecl.modifiers = CCodeModifiers.STATIC;
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);
}
}
@@ -427,19 +427,19 @@ public abstract class Vala.DovaBaseModule : 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 ()));
+ cdecl.add_declarator (new CCodeVariableDeclarator (get_ccode_name (f)));
if (f.is_internal_symbol ()) {
cdecl.modifiers = CCodeModifiers.STATIC;
} else {
@@ -461,14 +461,14 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
generate_field_declaration (f, header_file);
}
- var var_decl = new CCodeVariableDeclarator (f.get_cname ());
+ var var_decl = new CCodeVariableDeclarator (get_ccode_name (f));
var_decl.initializer = default_value_for_type (f.variable_type, true);
if (f.initializer != null) {
static_fields.add (f);
}
- 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;
}
@@ -612,7 +612,7 @@ public abstract class Vala.DovaBaseModule : 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));
// create copy if necessary as captured variables may need to be kept alive
CCodeExpression cparam = get_variable_cexpression (param.name);
@@ -666,7 +666,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
free_block.add_statement (new CCodeExpressionStatement (unref_call));
} else if ((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_class.get_cname ()), "this");
+ data.add_field ("%s *".printf (get_ccode_name (current_class)), "this");
var ma = new MemberAccess.simple ("this");
ma.symbol_reference = current_class;
@@ -676,7 +676,7 @@ public abstract class Vala.DovaBaseModule : 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 ());
}
}
// free in reverse order
@@ -870,7 +870,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
} else {
var cvar = new CCodeVariableDeclarator (get_variable_cname (local.name), rhs, local.variable_type.get_cdeclarator_suffix ());
- var cdecl = new CCodeDeclaration (local.variable_type.get_cname ());
+ var cdecl = new CCodeDeclaration (get_ccode_name (local.variable_type));
cdecl.add_declarator (cvar);
ccode.add_statement (cdecl);
@@ -960,13 +960,13 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
public CCodeExpression get_type_private_from_type (ObjectTypeSymbol type_symbol, CCodeExpression type_expression) {
if (type_symbol is Class) {
// class
- return new CCodeCastExpression (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeCastExpression (type_expression, "char *"), new CCodeIdentifier ("_%s_type_offset".printf (((Class) type_symbol).get_lower_case_cname ()))), "%sTypePrivate *".printf (((Class) type_symbol).get_cname ()));
+ return new CCodeCastExpression (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeCastExpression (type_expression, "char *"), new CCodeIdentifier ("_%s_type_offset".printf (CCodeBaseModule.get_ccode_lower_case_name (type_symbol)))), "%sTypePrivate *".printf (get_ccode_name (type_symbol)));
} else {
// interface
var get_interface = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_get_interface"));
get_interface.add_argument (type_expression);
- get_interface.add_argument (new CCodeIdentifier ("%s_type".printf (((Interface) type_symbol).get_lower_case_cname ())));
- return new CCodeCastExpression (get_interface, "%sTypePrivate *".printf (((Interface) type_symbol).get_cname ()));
+ get_interface.add_argument (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (type_symbol))));
+ return new CCodeCastExpression (get_interface, "%sTypePrivate *".printf (CCodeBaseModule.get_ccode_name (type_symbol)));
}
}
@@ -979,7 +979,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
return new CCodeIdentifier (var_name);
}
} else {
- var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (type.data_type.get_lower_case_cname ())));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (CCodeBaseModule.get_ccode_lower_case_name (type.data_type))));
var object_type_symbol = type.data_type as ObjectTypeSymbol;
if (object_type_symbol != null) {
for (int i = 0; i < object_type_symbol.get_type_parameters ().size; i++) {
@@ -997,10 +997,10 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
public virtual CCodeExpression? get_dup_func_expression (DataType type, SourceReference? source_reference, bool is_chainup = false) {
if (type.data_type != null) {
string dup_function = "";
- if (type.data_type.is_reference_counting ()) {
- dup_function = type.data_type.get_ref_function ();
+ if (is_reference_counting (type.data_type)) {
+ dup_function = get_ccode_ref_function (type.data_type);
} else if (type is ValueType) {
- dup_function = type.data_type.get_dup_function ();
+ dup_function = get_ccode_dup_function (type.data_type);
if (dup_function == null) {
dup_function = "";
}
@@ -1025,20 +1025,20 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
if (type.data_type != null) {
string unref_function;
if (type is ReferenceType) {
- if (type.data_type.is_reference_counting ()) {
- unref_function = type.data_type.get_unref_function ();
+ if (is_reference_counting (type.data_type)) {
+ unref_function = get_ccode_unref_function ((ObjectTypeSymbol) type.data_type);
} else {
- unref_function = type.data_type.get_free_function ();
+ unref_function = get_ccode_free_function (type.data_type);
}
} else {
if (type.nullable) {
- unref_function = type.data_type.get_free_function ();
+ unref_function = get_ccode_free_function (type.data_type);
if (unref_function == null) {
unref_function = "free";
}
} else {
var st = (Struct) type.data_type;
- unref_function = st.get_copy_function ();
+ unref_function = get_ccode_copy_function (st);
}
}
if (unref_function == null) {
@@ -1149,7 +1149,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
}
public void emit_temp_var (LocalVariable local) {
- var cdecl = new CCodeDeclaration (local.variable_type.get_cname ());
+ var cdecl = new CCodeDeclaration (get_ccode_name (local.variable_type));
var vardecl = new CCodeVariableDeclarator (local.name, null, local.variable_type.get_cdeclarator_suffix ());
cdecl.add_declarator (vardecl);
@@ -1359,7 +1359,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
public override void visit_base_access (BaseAccess expr) {
generate_type_declaration (expr.value_type, cfile);
- set_cvalue (expr, new CCodeCastExpression (new CCodeIdentifier ("this"), expr.value_type.get_cname ()));
+ set_cvalue (expr, new CCodeCastExpression (new CCodeIdentifier ("this"), get_ccode_name (expr.value_type)));
}
public override void visit_postfix_expression (PostfixExpression expr) {
@@ -1407,8 +1407,8 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
}
var cl = type.data_type as Class;
- if (cl != null && cl.is_reference_counting ()
- && cl.get_ref_function () == "") {
+ if (cl != null && is_reference_counting (cl)
+ && get_ccode_ref_function (cl) == "") {
// empty ref_function => no ref necessary
return false;
}
@@ -1431,8 +1431,8 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
}
var cl = type.data_type as Class;
- if (cl != null && cl.is_reference_counting ()
- && cl.get_unref_function () == "") {
+ if (cl != null && is_reference_counting (cl)
+ && get_ccode_unref_function (cl) == "") {
// empty unref_function => no unref necessary
return false;
}
@@ -1446,7 +1446,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
bool is_ref_function_void (DataType type) {
var cl = type.data_type as Class;
- if (cl != null && cl.ref_function_void) {
+ if (cl != null && get_ccode_ref_function_void (cl)) {
return true;
} else {
return false;
@@ -1465,7 +1465,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
var vt = (ValueType) expression_type;
var st = (Struct) vt.type_symbol;
- var copy_call = new CCodeFunctionCall (new CCodeIdentifier (st.get_copy_function ()));
+ var copy_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_copy_function (st)));
copy_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, ctemp));
copy_call.add_argument (new CCodeConstant ("0"));
copy_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cexpr));
@@ -1533,7 +1533,7 @@ public abstract class Vala.DovaBaseModule : 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;
}
}
@@ -1575,7 +1575,7 @@ public abstract class Vala.DovaBaseModule : 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;
}
@@ -1589,15 +1589,15 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
var cl = expr.type_reference.data_type as Class;
- if (!m.has_new_function) {
+ if (!CCodeBaseModule.get_ccode_has_new_function (m)) {
// use construct function directly
- creation_call = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname ()));
- creation_call.add_argument (new CCodeIdentifier (cl.get_type_id ()));
+ creation_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_real_name (m)));
+ creation_call.add_argument (new CCodeIdentifier (CCodeBaseModule.get_ccode_type_id (cl)));
} else {
- creation_call = new CCodeFunctionCall (new CCodeIdentifier (m.get_cname ()));
+ creation_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (m)));
}
- if (struct_by_ref && !(m.cinstance_parameter_position < 0)) {
+ if (struct_by_ref && !(get_ccode_instance_pos (m) < 0)) {
creation_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, instance));
}
@@ -1648,7 +1648,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
i++;
}
- if (struct_by_ref && m.cinstance_parameter_position < 0) {
+ if (struct_by_ref && get_ccode_instance_pos (m) < 0) {
// instance parameter is at the end in a struct creation method
creation_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, instance));
}
@@ -1656,8 +1656,8 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
if (ellipsis) {
/* ensure variable argument list ends with NULL
* except when using printf-style arguments */
- if (!m.printf_format && !m.scanf_format && m.sentinel != "") {
- creation_call.add_argument (new CCodeConstant (m.sentinel));
+ if (!m.printf_format && !m.scanf_format && get_ccode_sentinel (m) != "") {
+ creation_call.add_argument (new CCodeConstant (get_ccode_sentinel (m)));
}
}
@@ -1666,7 +1666,7 @@ public abstract class Vala.DovaBaseModule : 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 {
assert (false);
@@ -1686,9 +1686,9 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
var typed_inst = transform_expression (instance, expr.type_reference, instance_target_type);
CCodeExpression lhs;
if (expr.type_reference.data_type is Struct) {
- lhs = new CCodeMemberAccess (typed_inst, f.get_cname ());
+ lhs = new CCodeMemberAccess (typed_inst, get_ccode_name (f));
} else {
- lhs = new CCodeMemberAccess.pointer (typed_inst, f.get_cname ());
+ lhs = new CCodeMemberAccess.pointer (typed_inst, get_ccode_name (f));
}
ccode.add_assignment (lhs, get_cvalue (init.initializer));
} else if (init.symbol_reference is Property) {
@@ -1743,7 +1743,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
public override void visit_sizeof_expression (SizeofExpression expr) {
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);
}
@@ -1786,7 +1786,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
var ctemp = get_variable_cexpression (temp_decl.name);
var cinit = new CCodeAssignment (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");
ccomma.append_expression (cinit);
@@ -1826,7 +1826,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
var ccomma = new CCodeCommaExpression ();
var sizeof_call = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- sizeof_call.add_argument (new CCodeIdentifier (expr.type_reference.get_cname ()));
+ sizeof_call.add_argument (new CCodeIdentifier (get_ccode_name (expr.type_reference)));
var to_any = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_value_from_any"));
to_any.add_argument (get_type_id_expression (expr.type_reference));
@@ -1853,9 +1853,9 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
if (expr.inner.value_type is GenericType && !(expr.type_reference is GenericType)) {
// generic types use an extra pointer, dereference that pointer
- set_cvalue (expr, new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeCastExpression (get_cvalue (expr.inner), expr.type_reference.get_cname () + "*")));
+ set_cvalue (expr, new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeCastExpression (get_cvalue (expr.inner), get_ccode_name (expr.type_reference) + "*")));
} else {
- set_cvalue (expr, new CCodeCastExpression (get_cvalue (expr.inner), expr.type_reference.get_cname ()));
+ set_cvalue (expr, new CCodeCastExpression (get_cvalue (expr.inner), get_ccode_name (expr.type_reference)));
}
}
@@ -1979,13 +1979,9 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
}
public override void visit_lambda_expression (LambdaExpression l) {
- // use instance position from delegate
- var dt = (DelegateType) l.target_type;
- l.method.cinstance_parameter_position = dt.delegate_symbol.cinstance_parameter_position;
-
l.accept_children (this);
- set_cvalue (l, new CCodeIdentifier (l.method.get_cname ()));
+ set_cvalue (l, new CCodeIdentifier (get_ccode_name (l.method)));
}
// manage memory and implicit casts
@@ -2117,9 +2113,9 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
foreach (Parameter param in d.get_parameters ()) {
method_param_iter.next ();
var method_param = method_param_iter.get ();
- string ctype = param.variable_type.get_cname ();
+ string ctype = get_ccode_name (param.variable_type);
if (param.variable_type is GenericType && !(method_param.variable_type is GenericType)) {
- ctype = method_param.variable_type.get_cname () + "*";
+ ctype = get_ccode_name (method_param.variable_type) + "*";
call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier (param.name)));
} else if (!(param.variable_type is GenericType) && method_param.variable_type is GenericType) {
call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (param.name)));
@@ -2136,11 +2132,11 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
} else {
var method_return_type = method_type.method_symbol.return_type;
if (d.return_type is GenericType && !(method_return_type is GenericType)) {
- wrapper.add_parameter (new CCodeParameter ("result", method_return_type.get_cname () + "*"));
+ wrapper.add_parameter (new CCodeParameter ("result", get_ccode_name (method_return_type) + "*"));
wrapper.block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("result")), call)));
} else if (!(d.return_type is GenericType) && method_return_type is GenericType) {
- wrapper.return_type = d.return_type.get_cname ();
- var cdecl = new CCodeDeclaration (d.return_type.get_cname ());
+ wrapper.return_type = get_ccode_name (d.return_type);
+ var cdecl = new CCodeDeclaration (get_ccode_name (d.return_type));
cdecl.add_declarator (new CCodeVariableDeclarator ("result"));
call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("result")));
wrapper.block.add_statement (new CCodeExpressionStatement (call));
@@ -2149,14 +2145,14 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
wrapper.add_parameter (new CCodeParameter ("result", "void *"));
wrapper.block.add_statement (new CCodeExpressionStatement (call));
} else {
- wrapper.return_type = d.return_type.get_cname ();
+ wrapper.return_type = get_ccode_name (d.return_type);
wrapper.block.add_statement (new CCodeReturnStatement (call));
}
}
cfile.add_function (wrapper);
- var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_new".printf (deleg_type.delegate_symbol.get_lower_case_cname ())));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_new".printf (get_ccode_lower_case_name (deleg_type.delegate_symbol))));
ccall.add_argument (delegate_target);
ccall.add_argument (new CCodeIdentifier (wrapper_name));
return ccall;
@@ -2167,11 +2163,11 @@ public abstract class Vala.DovaBaseModule : 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;
}
@@ -2191,7 +2187,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
}
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
@@ -2273,8 +2269,8 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
|| type.nullable
|| type is PointerType || type is DelegateType) {
return new CCodeConstant ("NULL");
- } else if (type.data_type != null && type.data_type.get_default_value () != null) {
- return new CCodeConstant (type.data_type.get_default_value ());
+ } else if (type.data_type != null && get_ccode_default_value (type.data_type) != "") {
+ return new CCodeConstant (get_ccode_default_value (type.data_type));
}
return null;
}
@@ -2286,6 +2282,74 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
return get_cvalue (node);
}
+ public string get_ccode_name (CodeNode node) {
+ return CCodeBaseModule.get_ccode_name (node);
+ }
+
+ public string get_ccode_const_name (CodeNode node) {
+ return CCodeBaseModule.get_ccode_const_name (node);
+ }
+
+ public string get_ccode_copy_function (TypeSymbol node) {
+ return CCodeBaseModule.get_ccode_copy_function (node);
+ }
+
+ public string get_ccode_dup_function (TypeSymbol node) {
+ return CCodeBaseModule.get_ccode_dup_function (node);
+ }
+
+ public string get_ccode_ref_function (TypeSymbol node) {
+ return CCodeBaseModule.get_ccode_ref_function (node);
+ }
+
+ public string get_ccode_unref_function (ObjectTypeSymbol node) {
+ return CCodeBaseModule.get_ccode_unref_function (node);
+ }
+
+ public string get_ccode_free_function (TypeSymbol node) {
+ return CCodeBaseModule.get_ccode_free_function (node);
+ }
+
+ public bool is_reference_counting (TypeSymbol node) {
+ return CCodeBaseModule.is_reference_counting (node);
+ }
+
+ public bool get_ccode_ref_function_void (Class node) {
+ return CCodeBaseModule.get_ccode_ref_function_void (node);
+ }
+
+ public string get_ccode_default_value (TypeSymbol node) {
+ return CCodeBaseModule.get_ccode_default_value (node);
+ }
+
+ public string get_ccode_real_name (Method node) {
+ return CCodeBaseModule.get_ccode_real_name (node);
+ }
+
+ public string get_ccode_lower_case_name (CodeNode node, string? infix = null) {
+ return CCodeBaseModule.get_ccode_lower_case_name (node, infix);
+ }
+
+ public string get_ccode_upper_case_name (Symbol node, string? infix = null) {
+ return CCodeBaseModule.get_ccode_upper_case_name (node, infix);
+ }
+
+ public string get_ccode_lower_case_prefix (Symbol node) {
+ return CCodeBaseModule.get_ccode_lower_case_prefix (node);
+ }
+
+ public double get_ccode_instance_pos (CodeNode node) {
+ return CCodeBaseModule.get_ccode_instance_pos (node);
+ }
+
+ public string get_ccode_vfunc_name (Method node) {
+ return CCodeBaseModule.get_ccode_vfunc_name (node);
+ }
+
+ public string get_ccode_sentinel (Method m) {
+ return CCodeBaseModule.get_ccode_sentinel (m);
+ }
+
public DataType? get_this_type () {
if (current_method != null && current_method.binding == MemberBinding.INSTANCE) {
return current_method.this_parameter.variable_type;
@@ -2296,7 +2360,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
}
public CCodeExpression generate_instance_cast (CCodeExpression expr, TypeSymbol type) {
- return new CCodeCastExpression (expr, type.get_cname () + "*");
+ return new CCodeCastExpression (expr, get_ccode_name (type) + "*");
}
public virtual string? get_custom_creturn_type (Method m) {
diff --git a/codegen/valadovadelegatemodule.vala b/codegen/valadovadelegatemodule.vala
index a96f34e..5cb0439 100644
--- a/codegen/valadovadelegatemodule.vala
+++ b/codegen/valadovadelegatemodule.vala
@@ -26,23 +26,23 @@
*/
public class Vala.DovaDelegateModule : DovaValueModule {
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;
}
- decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (d.get_cname ()), new CCodeVariableDeclarator (d.get_cname ())));
+ decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (get_ccode_name (d)), new CCodeVariableDeclarator (get_ccode_name (d))));
generate_class_declaration (type_class, decl_space);
generate_method_declaration ((Method) object_class.scope.lookup ("ref"), decl_space);
generate_method_declaration ((Method) object_class.scope.lookup ("unref"), decl_space);
- var type_fun = new CCodeFunction ("%s_type_get".printf (d.get_lower_case_cname ()), "DovaType *");
+ var type_fun = new CCodeFunction ("%s_type_get".printf (get_ccode_lower_case_name (d)), "DovaType *");
if (d.is_internal_symbol ()) {
type_fun.modifiers = CCodeModifiers.STATIC;
}
decl_space.add_function_declaration (type_fun);
- var type_init_fun = new CCodeFunction ("%s_type_init".printf (d.get_lower_case_cname ()));
+ var type_init_fun = new CCodeFunction ("%s_type_init".printf (get_ccode_lower_case_name (d)));
if (d.is_internal_symbol ()) {
type_init_fun.modifiers = CCodeModifiers.STATIC;
}
@@ -61,7 +61,7 @@ public class Vala.DovaDelegateModule : DovaValueModule {
}
CCodeFunction generate_new_function (Delegate d, CCodeFile decl_space) {
- var function = new CCodeFunction ("%s_new".printf (d.get_lower_case_cname ()), "%s*".printf (d.get_cname ()));
+ var function = new CCodeFunction ("%s_new".printf (get_ccode_lower_case_name (d)), "%s*".printf (get_ccode_name (d)));
if (d.is_internal_symbol ()) {
function.modifiers |= CCodeModifiers.STATIC;
}
@@ -72,9 +72,9 @@ public class Vala.DovaDelegateModule : DovaValueModule {
function.block = new CCodeBlock ();
var alloc_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_object_alloc"));
- alloc_call.add_argument (new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (d.get_lower_case_cname ()))));
+ alloc_call.add_argument (new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (get_ccode_lower_case_name (d)))));
- var cdecl = new CCodeDeclaration ("%s*".printf (d.get_cname ()));
+ var cdecl = new CCodeDeclaration ("%s*".printf (get_ccode_name (d)));
cdecl.add_declarator (new CCodeVariableDeclarator ("this", alloc_call));
function.block.add_statement (cdecl);
@@ -83,7 +83,7 @@ public class Vala.DovaDelegateModule : DovaValueModule {
init_call.add_argument (new CCodeIdentifier ("target"));
function.block.add_statement (new CCodeExpressionStatement (init_call));
- var priv = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (d.get_upper_case_cname ())));
+ var priv = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (get_ccode_upper_case_name (d))));
priv.add_argument (new CCodeIdentifier ("this"));
var assignment = new CCodeAssignment (new CCodeMemberAccess.pointer (priv, "method"), new CCodeIdentifier ("method"));
function.block.add_statement (new CCodeExpressionStatement (assignment));
@@ -94,25 +94,25 @@ public class Vala.DovaDelegateModule : DovaValueModule {
}
CCodeFunction generate_invoke_function (Delegate d, CCodeFile decl_space) {
- var function = new CCodeFunction ("%s_invoke".printf (d.get_lower_case_cname ()));
+ var function = new CCodeFunction ("%s_invoke".printf (get_ccode_lower_case_name (d)));
if (d.is_internal_symbol ()) {
function.modifiers |= CCodeModifiers.STATIC;
}
- function.add_parameter (new CCodeParameter ("this", "%s*".printf (d.get_cname ())));
+ function.add_parameter (new CCodeParameter ("this", "%s*".printf (get_ccode_name (d))));
string param_list = "";
foreach (Parameter param in d.get_parameters ()) {
generate_type_declaration (param.variable_type, decl_space);
- function.add_parameter (new CCodeParameter (param.name, param.variable_type.get_cname ()));
+ function.add_parameter (new CCodeParameter (param.name, get_ccode_name (param.variable_type)));
if (param_list != "") {
param_list += ", ";
}
- param_list += param.variable_type.get_cname ();
+ param_list += get_ccode_name (param.variable_type);
}
if (d.return_type is GenericType) {
@@ -123,7 +123,7 @@ public class Vala.DovaDelegateModule : DovaValueModule {
}
param_list += "void *";
} else {
- function.return_type = d.return_type.get_cname ();
+ function.return_type = get_ccode_name (d.return_type);
}
function.block = new CCodeBlock ();
@@ -135,7 +135,7 @@ public class Vala.DovaDelegateModule : DovaValueModule {
cdecl.add_declarator (new CCodeVariableDeclarator ("target", get_target));
function.block.add_statement (cdecl);
- var priv = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (d.get_upper_case_cname ())));
+ var priv = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (get_ccode_upper_case_name (d))));
priv.add_argument (new CCodeIdentifier ("this"));
string instance_param_list = "(DovaObject *";
@@ -195,23 +195,23 @@ public class Vala.DovaDelegateModule : DovaValueModule {
generate_type_get_function (d, delegate_class);
- var instance_priv_struct = new CCodeStruct ("_%sPrivate".printf (d.get_cname ()));
+ var instance_priv_struct = new CCodeStruct ("_%sPrivate".printf (get_ccode_name (d)));
instance_priv_struct.add_field ("void", "(*method) (void)");
- cfile.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (instance_priv_struct.name), new CCodeVariableDeclarator ("%sPrivate".printf (d.get_cname ()))));
+ cfile.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (instance_priv_struct.name), new CCodeVariableDeclarator ("%sPrivate".printf (get_ccode_name (d)))));
cfile.add_type_definition (instance_priv_struct);
- string macro = "((%sPrivate *) (((char *) o) + _%s_object_offset))".printf (d.get_cname (), d.get_lower_case_cname ());
- cfile.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_PRIVATE(o)".printf (d.get_upper_case_cname (null)), macro));
+ string macro = "((%sPrivate *) (((char *) o) + _%s_object_offset))".printf (get_ccode_name (d), get_ccode_lower_case_name (d));
+ cfile.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_PRIVATE(o)".printf (get_ccode_upper_case_name (d, null)), macro));
var cdecl = new CCodeDeclaration ("intptr_t");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_%s_object_offset".printf (d.get_lower_case_cname ()), new CCodeConstant ("0")));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_%s_object_offset".printf (get_ccode_lower_case_name (d)), new CCodeConstant ("0")));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_type_member_declaration (cdecl);
cdecl = new CCodeDeclaration ("intptr_t");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_%s_type_offset".printf (d.get_lower_case_cname ()), new CCodeConstant ("0")));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_%s_type_offset".printf (get_ccode_lower_case_name (d)), new CCodeConstant ("0")));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_type_member_declaration (cdecl);
diff --git a/codegen/valadovaerrormodule.vala b/codegen/valadovaerrormodule.vala
index c0df425..68f7a86 100644
--- a/codegen/valadovaerrormodule.vala
+++ b/codegen/valadovaerrormodule.vala
@@ -41,7 +41,7 @@ public class Vala.DovaErrorModule : DovaDelegateModule {
if (current_method is CreationMethod && current_method.parent_symbol is Class) {
var cl = current_method.parent_symbol as Class;
- var unref_call = new CCodeFunctionCall (new CCodeIdentifier (cl.get_unref_function ()));
+ var unref_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_unref_function (cl)));
unref_call.add_argument (new CCodeIdentifier ("this"));
ccode.add_expression (unref_call);
ccode.add_return ();
@@ -125,7 +125,7 @@ public class Vala.DovaErrorModule : DovaDelegateModule {
var type_check = new CCodeFunctionCall (new CCodeIdentifier ("any_is_a"));
type_check.add_argument (new CCodeIdentifier ("dova_error"));
- type_check.add_argument (new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (catch_type.type_symbol.get_lower_case_cname ()))));
+ type_check.add_argument (new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (get_ccode_lower_case_name (catch_type.type_symbol)))));
ccode.open_if (type_check);
@@ -164,7 +164,7 @@ public class Vala.DovaErrorModule : DovaDelegateModule {
// Check the allowed error domains to propagate
var type_check = new CCodeFunctionCall (new CCodeIdentifier ("any_is_a"));
type_check.add_argument (new CCodeIdentifier ("dova_error"));
- type_check.add_argument (new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (error_class.get_lower_case_cname ()))));
+ type_check.add_argument (new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (get_ccode_lower_case_name (error_class)))));
if (ccond == null) {
ccond = type_check;
} else {
@@ -201,7 +201,7 @@ public class Vala.DovaErrorModule : DovaDelegateModule {
is_in_catch = true;
foreach (CatchClause clause in stmt.get_catch_clauses ()) {
- clause.clabel_name = "__catch%d_%s".printf (this_try_id, clause.error_type.get_lower_case_cname ());
+ clause.clabel_name = "__catch%d_%s".printf (this_try_id, get_ccode_lower_case_name (clause.error_type));
}
is_in_catch = false;
@@ -242,7 +242,7 @@ public class Vala.DovaErrorModule : DovaDelegateModule {
}
if (clause.variable_name != null) {
- var cdecl = new CCodeDeclaration (clause.error_type.get_cname ());
+ var cdecl = new CCodeDeclaration (get_ccode_name (clause.error_type));
cdecl.add_declarator (new CCodeVariableDeclarator (variable_name, new CCodeIdentifier ("dova_error")));
ccode.add_statement (cdecl);
} else {
diff --git a/codegen/valadovamemberaccessmodule.vala b/codegen/valadovamemberaccessmodule.vala
index 3a23548..44760f9 100644
--- a/codegen/valadovamemberaccessmodule.vala
+++ b/codegen/valadovamemberaccessmodule.vala
@@ -54,12 +54,12 @@ public abstract class Vala.DovaMemberAccessModule : DovaControlFlowModule {
if (m.base_method != null) {
var base_class = (Class) m.base_method.parent_symbol;
- set_cvalue (expr, new CCodeIdentifier ("%s_base_%s".printf (base_class.get_lower_case_cname (null), m.name)));
+ set_cvalue (expr, new CCodeIdentifier ("%s_base_%s".printf (get_ccode_lower_case_name (base_class, null), m.name)));
return;
} else if (m.base_interface_method != null) {
var base_iface = (Interface) m.base_interface_method.parent_symbol;
- set_cvalue (expr, new CCodeIdentifier ("%s_base_%s".printf (base_iface.get_lower_case_cname (null), m.name)));
+ set_cvalue (expr, new CCodeIdentifier ("%s_base_%s".printf (get_ccode_lower_case_name (base_iface, null), m.name)));
return;
}
}
@@ -77,18 +77,18 @@ public abstract class Vala.DovaMemberAccessModule : DovaControlFlowModule {
set_cvalue (expr.inner, ctemp);
}
var base_class = (Class) m.base_method.parent_symbol;
- var vclass = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (base_class.get_upper_case_cname (null))));
+ var vclass = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (get_ccode_upper_case_name (base_class, null))));
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 ()));
+ set_cvalue (expr, new CCodeIdentifier (get_ccode_real_name (m)));
} else {
- set_cvalue (expr, new CCodeIdentifier (m.get_cname ()));
+ set_cvalue (expr, new CCodeIdentifier (get_ccode_name (m)));
}
} else if (expr.symbol_reference is ArrayLengthField) {
var array_type = (ArrayType) expr.inner.value_type;
@@ -109,13 +109,13 @@ public abstract class Vala.DovaMemberAccessModule : DovaControlFlowModule {
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;
generate_constant_declaration (c, cfile);
- set_cvalue (expr, new CCodeIdentifier (c.get_cname ()));
+ set_cvalue (expr, new CCodeIdentifier (get_ccode_name (c)));
} else if (expr.symbol_reference is Property) {
var prop = (Property) expr.symbol_reference;
@@ -134,8 +134,8 @@ public abstract class Vala.DovaMemberAccessModule : DovaControlFlowModule {
if (expr.inner is BaseAccess) {
if (prop.base_property != null) {
var base_class = (Class) prop.base_property.parent_symbol;
- var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (base_class.get_upper_case_cname (null))));
- vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
+ var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (get_ccode_upper_case_name (base_class, null))));
+ vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (current_class, null))));
var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, "get_%s".printf (prop.name)));
ccall.add_argument (get_cvalue (expr.inner));
@@ -143,7 +143,7 @@ public abstract class Vala.DovaMemberAccessModule : DovaControlFlowModule {
return;
} else if (prop.base_interface_property != null) {
var base_iface = (Interface) prop.base_interface_property.parent_symbol;
- string parent_iface_var = "%s_%s_parent_iface".printf (current_class.get_lower_case_cname (null), base_iface.get_lower_case_cname (null));
+ string parent_iface_var = "%s_%s_parent_iface".printf (get_ccode_lower_case_name (current_class, null), get_ccode_lower_case_name (base_iface, null));
var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), "get_%s".printf (prop.name)));
ccall.add_argument (get_cvalue (expr.inner));
@@ -158,7 +158,7 @@ public abstract class Vala.DovaMemberAccessModule : DovaControlFlowModule {
} else if (prop.base_interface_property != null) {
base_property = prop.base_interface_property;
}
- string getter_cname = base_property.get_accessor.get_cname ();
+ string getter_cname = get_ccode_name (base_property.get_accessor);
var ccall = new CCodeFunctionCall (new CCodeIdentifier (getter_cname));
if (prop.binding == MemberBinding.INSTANCE) {
@@ -268,21 +268,21 @@ public abstract class Vala.DovaMemberAccessModule : DovaControlFlowModule {
CCodeExpression inst;
if (dova_priv) {
- var priv_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (cl.get_upper_case_cname (null))));
+ var priv_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (get_ccode_upper_case_name (cl, null))));
priv_call.add_argument (pub_inst);
inst = priv_call;
} else {
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, f.get_cname ());
+ result.cvalue = new CCodeMemberAccess.pointer (inst, get_ccode_name (f));
} else {
- result.cvalue = new CCodeMemberAccess (inst, f.get_cname ());
+ result.cvalue = new CCodeMemberAccess (inst, get_ccode_name (f));
}
} else {
generate_field_declaration (f, cfile);
- result.cvalue = new CCodeIdentifier (f.get_cname ());
+ result.cvalue = new CCodeIdentifier (get_ccode_name (f));
}
return result;
diff --git a/codegen/valadovamethodcallmodule.vala b/codegen/valadovamethodcallmodule.vala
index bb5d470..a829d61 100644
--- a/codegen/valadovamethodcallmodule.vala
+++ b/codegen/valadovamethodcallmodule.vala
@@ -42,10 +42,10 @@ public class Vala.DovaMethodCallModule : DovaAssignmentModule {
var cl = (Class) ((ObjectType) itype).type_symbol;
m = cl.default_construction_method;
generate_method_declaration (m, cfile);
- ccall = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname ()));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_real_name (m)));
} else if (itype is DelegateType) {
deleg = ((DelegateType) itype).delegate_symbol;
- ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_invoke".printf (deleg.get_lower_case_cname ())));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_invoke".printf (get_ccode_lower_case_name (deleg))));
ccall.add_argument (get_cvalue (expr.call));
}
@@ -55,7 +55,7 @@ public class Vala.DovaMethodCallModule : DovaAssignmentModule {
if (cl == current_class) {
ccall.add_argument (new CCodeIdentifier ("this"));
} else {
- ccall.add_argument (new CCodeCastExpression (new CCodeIdentifier ("this"), cl.get_cname () + "*"));
+ ccall.add_argument (new CCodeCastExpression (new CCodeIdentifier ("this"), get_ccode_name (cl) + "*"));
}
} else if (m != null) {
if (m.binding == MemberBinding.INSTANCE) {
@@ -90,7 +90,7 @@ public class Vala.DovaMethodCallModule : DovaAssignmentModule {
}
if (ma.inner is BaseAccess) {
- ccall.add_argument (new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (((Class) current_class.base_class).get_lower_case_cname ()))));
+ ccall.add_argument (new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (get_ccode_lower_case_name (current_class.base_class)))));
}
ccall.add_argument (instance);
}
@@ -178,8 +178,8 @@ public class Vala.DovaMethodCallModule : DovaAssignmentModule {
ccall_expr = ccomma;
}
- if (param.ctype != null) {
- cexpr = new CCodeCastExpression (cexpr, param.ctype);
+ if (CCodeBaseModule.get_ccode_type (param) != null) {
+ cexpr = new CCodeCastExpression (cexpr, CCodeBaseModule.get_ccode_type (param));
}
}
}
diff --git a/codegen/valadovaobjectmodule.vala b/codegen/valadovaobjectmodule.vala
index eec278f..b0ec8de 100644
--- a/codegen/valadovaobjectmodule.vala
+++ b/codegen/valadovaobjectmodule.vala
@@ -22,23 +22,23 @@
public class Vala.DovaObjectModule : DovaArrayModule {
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;
}
if (cl.base_class == null) {
- 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))));
} else if (cl == string_type.data_type) {
generate_class_declaration (cl.base_class, decl_space);
- decl_space.add_type_declaration (new CCodeTypeDefinition ("const uint8_t *", new CCodeVariableDeclarator (cl.get_cname ())));
+ decl_space.add_type_declaration (new CCodeTypeDefinition ("const uint8_t *", new CCodeVariableDeclarator (get_ccode_name (cl))));
} else {
// typedef to base class instead of dummy struct to avoid warnings/casts
generate_class_declaration (cl.base_class, decl_space);
- 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))));
}
if (cl.base_class == null) {
- var instance_struct = new CCodeStruct ("_%s".printf (cl.get_cname ()));
+ var instance_struct = new CCodeStruct ("_%s".printf (get_ccode_name (cl)));
instance_struct.add_field ("DovaType *", "type");
decl_space.add_type_definition (instance_struct);
} else if (cl == type_class) {
@@ -75,7 +75,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
generate_method_declaration ((Method) object_class.scope.lookup ("ref"), decl_space);
generate_method_declaration ((Method) object_class.scope.lookup ("unref"), decl_space);
- var type_fun = new CCodeFunction ("%s_type_get".printf (cl.get_lower_case_cname ()), "DovaType *");
+ var type_fun = new CCodeFunction ("%s_type_get".printf (get_ccode_lower_case_name (cl)), "DovaType *");
if (cl.is_internal_symbol ()) {
type_fun.modifiers = CCodeModifiers.STATIC;
}
@@ -84,7 +84,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
}
decl_space.add_function_declaration (type_fun);
- var type_init_fun = new CCodeFunction ("%s_type_init".printf (cl.get_lower_case_cname ()));
+ var type_init_fun = new CCodeFunction ("%s_type_init".printf (get_ccode_lower_case_name (cl)));
if (cl.is_internal_symbol ()) {
type_init_fun.modifiers = CCodeModifiers.STATIC;
}
@@ -101,11 +101,11 @@ public class Vala.DovaObjectModule : DovaArrayModule {
}
// add vfunc field to the type struct
- var vdeclarator = new CCodeFunctionDeclarator (m.vfunc_name);
+ var vdeclarator = new CCodeFunctionDeclarator (get_ccode_vfunc_name (m));
generate_cparameters (m, decl_space, new CCodeFunction ("fake"), vdeclarator);
- var vdecl = new CCodeDeclaration (m.return_type.get_cname ());
+ var vdecl = new CCodeDeclaration (get_ccode_name (m.return_type));
vdecl.add_declarator (vdeclarator);
type_struct.add_declaration (vdecl);
}
@@ -137,23 +137,23 @@ public class Vala.DovaObjectModule : DovaArrayModule {
}
void generate_class_private_declaration (Class cl, CCodeFile decl_space) {
- if (add_symbol_declaration (decl_space, cl, cl.get_cname () + "Private")) {
+ if (add_symbol_declaration (decl_space, cl, get_ccode_name (cl) + "Private")) {
return;
}
- var instance_priv_struct = new CCodeStruct ("_%sPrivate".printf (cl.get_cname ()));
- var type_priv_struct = new CCodeStruct ("_%sTypePrivate".printf (cl.get_cname ()));
+ var instance_priv_struct = new CCodeStruct ("_%sPrivate".printf (get_ccode_name (cl)));
+ var type_priv_struct = new CCodeStruct ("_%sTypePrivate".printf (get_ccode_name (cl)));
foreach (Field f in cl.get_fields ()) {
if (f.binding == MemberBinding.INSTANCE) {
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;
}
- 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 ());
}
}
@@ -223,13 +223,13 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var t = (ObjectTypeSymbol) prop.parent_symbol;
var this_type = new ObjectType (t);
- var cselfparam = new CCodeParameter ("this", this_type.get_cname ());
- var cvalueparam = new CCodeParameter ("value", prop.property_type.get_cname ());
+ var cselfparam = new CCodeParameter ("this", get_ccode_name (this_type));
+ var cvalueparam = new CCodeParameter ("value", get_ccode_name (prop.property_type));
if (prop.get_accessor != null) {
var vdeclarator = new CCodeFunctionDeclarator ("get_%s".printf (prop.name));
vdeclarator.add_parameter (cselfparam);
- string creturn_type = prop.property_type.get_cname ();
+ string creturn_type = get_ccode_name (prop.property_type);
var vdecl = new CCodeDeclaration (creturn_type);
vdecl.add_declarator (vdeclarator);
@@ -247,17 +247,17 @@ public class Vala.DovaObjectModule : DovaArrayModule {
}
if (!instance_priv_struct.is_empty) {
- decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (instance_priv_struct.name), new CCodeVariableDeclarator ("%sPrivate".printf (cl.get_cname ()))));
+ decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (instance_priv_struct.name), new CCodeVariableDeclarator ("%sPrivate".printf (get_ccode_name (cl)))));
decl_space.add_type_definition (instance_priv_struct);
}
if (!type_priv_struct.is_empty) {
- decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (type_priv_struct.name), new CCodeVariableDeclarator ("%sTypePrivate".printf (cl.get_cname ()))));
+ decl_space.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (type_priv_struct.name), new CCodeVariableDeclarator ("%sTypePrivate".printf (get_ccode_name (cl)))));
decl_space.add_type_definition (type_priv_struct);
}
var cdecl = new CCodeDeclaration ("intptr_t");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_%s_object_offset".printf (cl.get_lower_case_cname ()), new CCodeConstant ("0")));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_%s_object_offset".printf (get_ccode_lower_case_name (cl)), new CCodeConstant ("0")));
cdecl.modifiers = CCodeModifiers.STATIC;
decl_space.add_type_member_declaration (cdecl);
@@ -266,24 +266,24 @@ public class Vala.DovaObjectModule : DovaArrayModule {
string macro;
if (cl.base_class == null) {
// offset of any class is 0
- macro = "((%sPrivate *) o)".printf (cl.get_cname ());
+ macro = "((%sPrivate *) o)".printf (get_ccode_name (cl));
type_offset = new CCodeConstant ("sizeof (anyPrivate) + sizeof (DovaObjectPrivate) + sizeof (DovaTypePrivate)");
} else if (cl == object_class) {
- macro = "((%sPrivate *) (((char *) o) + sizeof (anyPrivate)))".printf (cl.get_cname ());
+ macro = "((%sPrivate *) (((char *) o) + sizeof (anyPrivate)))".printf (get_ccode_name (cl));
type_offset = new CCodeConstant ("sizeof (anyPrivate) + sizeof (DovaObjectPrivate) + sizeof (DovaTypePrivate) + sizeof (anyTypePrivate)");
} else if (cl == type_class) {
- macro = "((%sPrivate *) (((char *) o) + sizeof (anyPrivate) + sizeof (DovaObjectPrivate)))".printf (cl.get_cname ());
+ macro = "((%sPrivate *) (((char *) o) + sizeof (anyPrivate) + sizeof (DovaObjectPrivate)))".printf (get_ccode_name (cl));
type_offset = new CCodeConstant ("sizeof (anyPrivate) + sizeof (DovaObjectPrivate) + sizeof (DovaTypePrivate) + sizeof (anyTypePrivate) + sizeof (DovaObjectTypePrivate)");
} else {
- macro = "((%sPrivate *) (((char *) o) + _%s_object_offset))".printf (cl.get_cname (), cl.get_lower_case_cname ());
+ macro = "((%sPrivate *) (((char *) o) + _%s_object_offset))".printf (get_ccode_name (cl), get_ccode_lower_case_name (cl));
type_offset = new CCodeConstant ("0");
}
if (!instance_priv_struct.is_empty) {
- decl_space.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_PRIVATE(o)".printf (cl.get_upper_case_cname (null)), macro));
+ decl_space.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_PRIVATE(o)".printf (get_ccode_upper_case_name (cl, null)), macro));
}
cdecl = new CCodeDeclaration ("intptr_t");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_%s_type_offset".printf (cl.get_lower_case_cname ()), type_offset));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_%s_type_offset".printf (get_ccode_lower_case_name (cl)), type_offset));
cdecl.modifiers = CCodeModifiers.STATIC;
decl_space.add_type_member_declaration (cdecl);
}
@@ -420,11 +420,11 @@ public class Vala.DovaObjectModule : DovaArrayModule {
}
var cdecl = new CCodeDeclaration ("DovaType *");
- cdecl.add_declarator (new CCodeVariableDeclarator ("%s_type".printf (cl.get_lower_case_cname ()), new CCodeConstant ("NULL")));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("%s_type".printf (get_ccode_lower_case_name (cl)), new CCodeConstant ("NULL")));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_type_member_declaration (cdecl);
- var type_fun = new CCodeFunction ("%s_type_get".printf (cl.get_lower_case_cname ()), "DovaType *");
+ var type_fun = new CCodeFunction ("%s_type_get".printf (get_ccode_lower_case_name (cl)), "DovaType *");
if (cl.is_internal_symbol ()) {
type_fun.modifiers = CCodeModifiers.STATIC;
}
@@ -442,32 +442,32 @@ public class Vala.DovaObjectModule : DovaArrayModule {
if (base_class == null) {
var sizeof_call = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- sizeof_call.add_argument (new CCodeIdentifier ("%sPrivate".printf (cl.get_cname ())));
+ sizeof_call.add_argument (new CCodeIdentifier ("%sPrivate".printf (get_ccode_name (cl))));
var calloc_call = new CCodeFunctionCall (new CCodeIdentifier ("calloc"));
calloc_call.add_argument (new CCodeConstant ("1"));
calloc_call.add_argument (new CCodeConstant ("sizeof (anyPrivate) + sizeof (DovaObjectPrivate) + sizeof (DovaTypePrivate) + sizeof (anyTypePrivate)"));
- type_init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("%s_type".printf (cl.get_lower_case_cname ())), calloc_call)));
+ type_init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (cl))), calloc_call)));
var set_size = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_object_size"));
- set_size.add_argument (new CCodeIdentifier ("%s_type".printf (cl.get_lower_case_cname ())));
+ set_size.add_argument (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (cl))));
set_size.add_argument (sizeof_call);
type_init_block.add_statement (new CCodeExpressionStatement (set_size));
type_init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("_any_type_offset"), new CCodeConstant ("sizeof (any) + sizeof (DovaObjectPrivate) + sizeof (DovaTypePrivate)"))));
set_size = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_type_size"));
- set_size.add_argument (new CCodeIdentifier ("%s_type".printf (cl.get_lower_case_cname ())));
+ set_size.add_argument (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (cl))));
set_size.add_argument (new CCodeConstant ("sizeof (any) + sizeof (DovaObjectPrivate) + sizeof (DovaTypePrivate) + sizeof (anyTypePrivate)"));
type_init_block.add_statement (new CCodeExpressionStatement (set_size));
- type_init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("%s_type".printf (cl.get_lower_case_cname ())), "type"), new CCodeFunctionCall (new CCodeIdentifier ("dova_type_type_get")))));
+ type_init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (cl))), "type"), new CCodeFunctionCall (new CCodeIdentifier ("dova_type_type_get")))));
} else {
generate_method_declaration ((Method) object_class.scope.lookup ("alloc"), cfile);
generate_method_declaration ((Method) type_class.scope.lookup ("alloc"), cfile);
- var base_type = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (base_class.get_lower_case_cname ())));
+ var base_type = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (get_ccode_lower_case_name (base_class))));
for (int i = 0; i < base_class.get_type_parameters ().size; i++) {
base_type.add_argument (new CCodeConstant ("NULL"));
}
@@ -475,24 +475,24 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var alloc_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_alloc"));
alloc_call.add_argument (base_type);
if (!(cl is Class) || has_instance_struct ((Class) cl)) {
- alloc_call.add_argument (new CCodeConstant ("sizeof (%sPrivate)".printf (cl.get_cname ())));
+ alloc_call.add_argument (new CCodeConstant ("sizeof (%sPrivate)".printf (get_ccode_name (cl))));
} else {
alloc_call.add_argument (new CCodeConstant ("0"));
}
if ((!(cl is Class) || has_type_struct ((Class) cl)) && !(cl is Delegate)) {
- alloc_call.add_argument (new CCodeConstant ("sizeof (%sTypePrivate)".printf (cl.get_cname ())));
+ alloc_call.add_argument (new CCodeConstant ("sizeof (%sTypePrivate)".printf (get_ccode_name (cl))));
} else {
alloc_call.add_argument (new CCodeConstant ("0"));
}
- alloc_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("%s_type".printf (cl.get_lower_case_cname ()))));
- alloc_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_%s_object_offset".printf (cl.get_lower_case_cname ()))));
- alloc_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_%s_type_offset".printf (cl.get_lower_case_cname ()))));
+ alloc_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (cl)))));
+ alloc_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_%s_object_offset".printf (get_ccode_lower_case_name (cl)))));
+ alloc_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_%s_type_offset".printf (get_ccode_lower_case_name (cl)))));
type_init_block.add_statement (new CCodeExpressionStatement (alloc_call));
}
- var type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_init".printf (cl.get_lower_case_cname ())));
- type_init_call.add_argument (new CCodeIdentifier ("%s_type".printf (cl.get_lower_case_cname ())));
+ var type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_init".printf (get_ccode_lower_case_name (cl))));
+ type_init_call.add_argument (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (cl))));
if (object_type_symbol != null) {
for (int i = 0; i < object_type_symbol.get_type_parameters ().size; i++) {
@@ -502,7 +502,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
type_init_block.add_statement (new CCodeExpressionStatement (type_init_call));
- type_fun.block.add_statement (new CCodeIfStatement (new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, new CCodeIdentifier ("%s_type".printf (cl.get_lower_case_cname ()))), type_init_block));
+ type_fun.block.add_statement (new CCodeIfStatement (new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (cl)))), type_init_block));
if (object_type_symbol != null && object_type_symbol.get_type_parameters ().size > 0) {
// generics
@@ -512,7 +512,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
generate_method_declaration ((Method) type_class.scope.lookup ("insert_type"), cfile);
var first = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_get_next_type"));
- first.add_argument (new CCodeIdentifier ("%s_type".printf (cl.get_lower_case_cname ())));
+ first.add_argument (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (cl))));
cdecl = new CCodeDeclaration ("DovaType *");
cdecl.add_declarator (new CCodeVariableDeclarator ("result", first));
@@ -531,7 +531,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
generate_method_declaration ((Method) type_class.scope.lookup ("alloc"), cfile);
- var base_type = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (base_class.get_lower_case_cname ())));
+ var base_type = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (get_ccode_lower_case_name (base_class))));
if (base_class_type != null) {
foreach (var type_arg in base_class_type.get_type_arguments ()) {
base_type.add_argument (get_type_id_expression (type_arg, true));
@@ -541,22 +541,22 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var alloc_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_alloc"));
alloc_call.add_argument (base_type);
if (!(cl is Class) || has_instance_struct ((Class) cl)) {
- alloc_call.add_argument (new CCodeConstant ("sizeof (%sPrivate)".printf (cl.get_cname ())));
+ alloc_call.add_argument (new CCodeConstant ("sizeof (%sPrivate)".printf (get_ccode_name (cl))));
} else {
alloc_call.add_argument (new CCodeConstant ("0"));
}
if (!(cl is Class) || has_type_struct ((Class) cl)) {
- alloc_call.add_argument (new CCodeConstant ("sizeof (%sTypePrivate)".printf (cl.get_cname ())));
+ alloc_call.add_argument (new CCodeConstant ("sizeof (%sTypePrivate)".printf (get_ccode_name (cl))));
} else {
alloc_call.add_argument (new CCodeConstant ("0"));
}
alloc_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("result")));
- alloc_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_%s_object_offset".printf (cl.get_lower_case_cname ()))));
- alloc_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_%s_type_offset".printf (cl.get_lower_case_cname ()))));
+ alloc_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_%s_object_offset".printf (get_ccode_lower_case_name (cl)))));
+ alloc_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_%s_type_offset".printf (get_ccode_lower_case_name (cl)))));
specialized_type_init_block.add_statement (new CCodeExpressionStatement (alloc_call));
- type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_init".printf (cl.get_lower_case_cname ())));
+ type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_init".printf (get_ccode_lower_case_name (cl))));
type_init_call.add_argument (new CCodeIdentifier ("result"));
foreach (var type_param in object_type_symbol.get_type_parameters ()) {
@@ -566,7 +566,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
specialized_type_init_block.add_statement (new CCodeExpressionStatement (type_init_call));
var insert_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_insert_type"));
- insert_call.add_argument (new CCodeIdentifier ("%s_type".printf (cl.get_lower_case_cname ())));
+ insert_call.add_argument (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (cl))));
insert_call.add_argument (new CCodeIdentifier ("result"));
specialized_type_init_block.add_statement (new CCodeExpressionStatement (insert_call));
@@ -577,11 +577,11 @@ public class Vala.DovaObjectModule : DovaArrayModule {
type_fun.block.add_statement (new CCodeIfStatement (new CCodeIdentifier ("%s_type".printf (object_type_symbol.get_type_parameters ().get (0).name.down ())), specialized_type_get_block));
}
- type_fun.block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("%s_type".printf (cl.get_lower_case_cname ()))));
+ type_fun.block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (cl)))));
cfile.add_function (type_fun);
- var type_init_fun = new CCodeFunction ("%s_type_init".printf (cl.get_lower_case_cname ()));
+ var type_init_fun = new CCodeFunction ("%s_type_init".printf (get_ccode_lower_case_name (cl)));
if (cl.is_internal_symbol ()) {
type_init_fun.modifiers = CCodeModifiers.STATIC;
}
@@ -606,10 +606,10 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var value_copy_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_value_copy"));
value_copy_call.add_argument (new CCodeIdentifier ("type"));
- value_copy_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("%s_copy".printf (cl.get_lower_case_cname ())), "void (*)(void *, intptr_t, void *, intptr_t)"));
+ value_copy_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("%s_copy".printf (get_ccode_lower_case_name (cl))), "void (*)(void *, intptr_t, void *, intptr_t)"));
type_init_fun.block.add_statement (new CCodeExpressionStatement (value_copy_call));
- var function = new CCodeFunction ("%s_copy".printf (cl.get_lower_case_cname ()), "void");
+ var function = new CCodeFunction ("%s_copy".printf (get_ccode_lower_case_name (cl)), "void");
function.modifiers = CCodeModifiers.STATIC;
function.add_parameter (new CCodeParameter ("dest", "any **"));
function.add_parameter (new CCodeParameter ("dest_index", "intptr_t"));
@@ -623,14 +623,14 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var dest = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier ("dest"), new CCodeIdentifier ("dest_index"));
var src = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier ("src"), new CCodeIdentifier ("src_index"));
- var unref_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_unref".printf (cl.get_lower_case_cname ())));
+ var unref_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_unref".printf (get_ccode_lower_case_name (cl))));
unref_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, dest));
var unref_block = new CCodeBlock ();
unref_block.add_statement (new CCodeExpressionStatement (unref_call));
unref_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, dest), new CCodeConstant ("NULL"))));
function.block.add_statement (new CCodeIfStatement (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, dest), unref_block));
- var ref_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_ref".printf (cl.get_lower_case_cname ())));
+ var ref_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_ref".printf (get_ccode_lower_case_name (cl))));
ref_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, src));
var ref_block = new CCodeBlock ();
ref_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, dest), ref_call)));
@@ -639,11 +639,11 @@ public class Vala.DovaObjectModule : DovaArrayModule {
cfile.add_function (function);
{
- var value_equals_fun = new CCodeFunction ("%s_value_equals".printf (cl.get_lower_case_cname ()), "bool");
+ var value_equals_fun = new CCodeFunction ("%s_value_equals".printf (get_ccode_lower_case_name (cl)), "bool");
value_equals_fun.modifiers = CCodeModifiers.STATIC;
- value_equals_fun.add_parameter (new CCodeParameter ("value", cl.get_cname () + "**"));
+ value_equals_fun.add_parameter (new CCodeParameter ("value", get_ccode_name (cl) + "**"));
value_equals_fun.add_parameter (new CCodeParameter ("value_index", "intptr_t"));
- value_equals_fun.add_parameter (new CCodeParameter ("other", cl.get_cname () + "**"));
+ value_equals_fun.add_parameter (new CCodeParameter ("other", get_ccode_name (cl) + "**"));
value_equals_fun.add_parameter (new CCodeParameter ("other_index", "intptr_t"));
value_equals_fun.block = new CCodeBlock ();
var val = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier ("value"), new CCodeIdentifier ("value_index"));
@@ -658,14 +658,14 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var value_equals_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_value_equals"));
value_equals_call.add_argument (new CCodeIdentifier ("type"));
- value_equals_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("%s_value_equals".printf (cl.get_lower_case_cname ())), "bool (*)(void *, intptr_t, void *, intptr_t)"));
+ value_equals_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("%s_value_equals".printf (get_ccode_lower_case_name (cl))), "bool (*)(void *, intptr_t, void *, intptr_t)"));
type_init_fun.block.add_statement (new CCodeExpressionStatement (value_equals_call));
}
{
- var value_hash_fun = new CCodeFunction ("%s_value_hash".printf (cl.get_lower_case_cname ()), "uintptr_t");
+ var value_hash_fun = new CCodeFunction ("%s_value_hash".printf (get_ccode_lower_case_name (cl)), "uintptr_t");
value_hash_fun.modifiers = CCodeModifiers.STATIC;
- value_hash_fun.add_parameter (new CCodeParameter ("value", cl.get_cname () + "**"));
+ value_hash_fun.add_parameter (new CCodeParameter ("value", get_ccode_name (cl) + "**"));
value_hash_fun.add_parameter (new CCodeParameter ("value_index", "intptr_t"));
value_hash_fun.block = new CCodeBlock ();
var val = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier ("value"), new CCodeIdentifier ("value_index"));
@@ -678,18 +678,18 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var value_hash_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_value_hash"));
value_hash_call.add_argument (new CCodeIdentifier ("type"));
- value_hash_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("%s_value_hash".printf (cl.get_lower_case_cname ())), "uintptr_t (*)(void *, intptr_t)"));
+ value_hash_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("%s_value_hash".printf (get_ccode_lower_case_name (cl))), "uintptr_t (*)(void *, intptr_t)"));
type_init_fun.block.add_statement (new CCodeExpressionStatement (value_hash_call));
}
// generate method to box value
- var value_to_any_fun = new CCodeFunction ("%s_value_to_any".printf (cl.get_lower_case_cname ()), "any*");
+ var value_to_any_fun = new CCodeFunction ("%s_value_to_any".printf (get_ccode_lower_case_name (cl)), "any*");
value_to_any_fun.modifiers = CCodeModifiers.STATIC;
- value_to_any_fun.add_parameter (new CCodeParameter ("value", cl.get_cname () + "**"));
+ value_to_any_fun.add_parameter (new CCodeParameter ("value", get_ccode_name (cl) + "**"));
value_to_any_fun.add_parameter (new CCodeParameter ("value_index", "intptr_t"));
value_to_any_fun.block = new CCodeBlock ();
var val = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier ("value"), new CCodeIdentifier ("value_index"));
- string to_any_fun = "%s_ref".printf (cl.get_lower_case_cname ());
+ string to_any_fun = "%s_ref".printf (get_ccode_lower_case_name (cl));
if (cl == string_class) {
to_any_fun = "string_to_any";
}
@@ -702,17 +702,17 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var value_to_any_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_value_to_any"));
value_to_any_call.add_argument (new CCodeIdentifier ("type"));
- value_to_any_call.add_argument (new CCodeIdentifier ("%s_value_to_any".printf (cl.get_lower_case_cname ())));
+ value_to_any_call.add_argument (new CCodeIdentifier ("%s_value_to_any".printf (get_ccode_lower_case_name (cl))));
type_init_fun.block.add_statement (new CCodeExpressionStatement (value_to_any_call));
// generate method to unbox value
- var value_from_any_fun = new CCodeFunction ("%s_value_from_any".printf (cl.get_lower_case_cname ()));
+ var value_from_any_fun = new CCodeFunction ("%s_value_from_any".printf (get_ccode_lower_case_name (cl)));
value_from_any_fun.modifiers = CCodeModifiers.STATIC;
value_from_any_fun.add_parameter (new CCodeParameter ("any_", "any *"));
- value_from_any_fun.add_parameter (new CCodeParameter ("value", cl.get_cname () + "**"));
+ value_from_any_fun.add_parameter (new CCodeParameter ("value", get_ccode_name (cl) + "**"));
value_from_any_fun.add_parameter (new CCodeParameter ("value_index", "intptr_t"));
value_from_any_fun.block = new CCodeBlock ();
- string from_any_fun = "%s_ref".printf (cl.get_lower_case_cname ());
+ string from_any_fun = "%s_ref".printf (get_ccode_lower_case_name (cl));
if (cl == string_class) {
from_any_fun = "string_from_any";
}
@@ -726,10 +726,10 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var value_from_any_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_value_from_any"));
value_from_any_call.add_argument (new CCodeIdentifier ("type"));
- value_from_any_call.add_argument (new CCodeIdentifier ("%s_value_from_any".printf (cl.get_lower_case_cname ())));
+ value_from_any_call.add_argument (new CCodeIdentifier ("%s_value_from_any".printf (get_ccode_lower_case_name (cl))));
type_init_fun.block.add_statement (new CCodeExpressionStatement (value_from_any_call));
} else {
- type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_init".printf (base_class.get_lower_case_cname ())));
+ type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_init".printf (get_ccode_lower_case_name (base_class))));
type_init_call.add_argument (new CCodeIdentifier ("type"));
if (base_class_type != null) {
@@ -753,10 +753,10 @@ public class Vala.DovaObjectModule : DovaArrayModule {
}
void add_finalize_function (Class cl) {
- var function = new CCodeFunction ("%sfinalize".printf (cl.get_lower_case_cprefix ()), "void");
+ var function = new CCodeFunction ("%sfinalize".printf (get_ccode_lower_case_prefix (cl)), "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("this", cl.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("this", get_ccode_name (cl) + "*"));
push_function (function);
@@ -770,11 +770,11 @@ public class Vala.DovaObjectModule : DovaArrayModule {
if (f.binding == MemberBinding.INSTANCE) {
CCodeExpression lhs = null;
if (f.is_internal_symbol ()) {
- var priv_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (cl.get_upper_case_cname (null))));
+ var priv_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (get_ccode_upper_case_name (cl, null))));
priv_call.add_argument (new CCodeIdentifier ("this"));
- lhs = new CCodeMemberAccess.pointer (priv_call, f.get_cname ());
+ lhs = new CCodeMemberAccess.pointer (priv_call, get_ccode_name (f));
} else {
- lhs = new CCodeMemberAccess.pointer (new CCodeIdentifier ("this"), f.get_cname ());
+ lhs = new CCodeMemberAccess.pointer (new CCodeIdentifier ("this"), get_ccode_name (f));
}
if (requires_destroy (f.variable_type)) {
@@ -800,7 +800,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var object_type = (ObjectType) base_type;
if (object_type.type_symbol is Class) {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("dova_object_base_finalize"));
- var type_get_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (object_type.type_symbol.get_lower_case_cname ())));
+ var type_get_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (get_ccode_lower_case_name (object_type.type_symbol))));
foreach (var type_arg in base_type.get_type_arguments ()) {
type_get_call.add_argument (get_type_id_expression (type_arg, false));
}
@@ -834,7 +834,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
if (object_type.type_symbol is Interface) {
generate_interface_declaration ((Interface) object_type.type_symbol, cfile);
- var type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_init".printf (object_type.type_symbol.get_lower_case_cname ())));
+ var type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_init".printf (get_ccode_lower_case_name (object_type.type_symbol))));
type_init_call.add_argument (new CCodeIdentifier ("type"));
foreach (var type_arg in base_type.get_type_arguments ()) {
type_init_call.add_argument (get_type_id_expression (type_arg, true));
@@ -851,20 +851,20 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var override_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_object_override_finalize"));
override_call.add_argument (new CCodeIdentifier ("type"));
- override_call.add_argument (new CCodeIdentifier ("%sfinalize".printf (cl.get_lower_case_cprefix ())));
+ override_call.add_argument (new CCodeIdentifier ("%sfinalize".printf (get_ccode_lower_case_prefix (cl))));
type_init_block.add_statement (new CCodeExpressionStatement (override_call));
}
foreach (Method m in cl.get_methods ()) {
if (m.is_virtual || m.overrides) {
- var override_call = new CCodeFunctionCall (new CCodeIdentifier ("%soverride_%s".printf (m.base_method.parent_symbol.get_lower_case_cprefix (), m.name)));
+ var override_call = new CCodeFunctionCall (new CCodeIdentifier ("%soverride_%s".printf (get_ccode_lower_case_prefix (m.base_method.parent_symbol), m.name)));
override_call.add_argument (new CCodeIdentifier ("type"));
- override_call.add_argument (new CCodeIdentifier (m.get_real_cname ()));
+ override_call.add_argument (new CCodeIdentifier (get_ccode_real_name (m)));
type_init_block.add_statement (new CCodeExpressionStatement (override_call));
} else if (m.base_interface_method != null) {
- var override_call = new CCodeFunctionCall (new CCodeIdentifier ("%soverride_%s".printf (m.base_interface_method.parent_symbol.get_lower_case_cprefix (), m.name)));
+ var override_call = new CCodeFunctionCall (new CCodeIdentifier ("%soverride_%s".printf (get_ccode_lower_case_prefix (m.base_interface_method.parent_symbol), m.name)));
override_call.add_argument (new CCodeIdentifier ("type"));
- override_call.add_argument (new CCodeIdentifier (m.get_real_cname ()));
+ override_call.add_argument (new CCodeIdentifier (get_ccode_real_name (m)));
type_init_block.add_statement (new CCodeExpressionStatement (override_call));
}
}
@@ -872,15 +872,15 @@ public class Vala.DovaObjectModule : DovaArrayModule {
foreach (Property prop in cl.get_properties ()) {
if (prop.is_virtual || prop.overrides) {
if (prop.get_accessor != null) {
- var override_call = new CCodeFunctionCall (new CCodeIdentifier ("%soverride_get_%s".printf (prop.base_property.parent_symbol.get_lower_case_cprefix (), prop.name)));
+ var override_call = new CCodeFunctionCall (new CCodeIdentifier ("%soverride_get_%s".printf (get_ccode_lower_case_prefix (prop.base_property.parent_symbol), prop.name)));
override_call.add_argument (new CCodeIdentifier ("type"));
- override_call.add_argument (new CCodeIdentifier (prop.get_accessor.get_cname ()));
+ override_call.add_argument (new CCodeIdentifier (get_ccode_name (prop.get_accessor)));
type_init_block.add_statement (new CCodeExpressionStatement (override_call));
}
if (prop.set_accessor != null) {
- var override_call = new CCodeFunctionCall (new CCodeIdentifier ("%soverride_set_%s".printf (prop.base_property.parent_symbol.get_lower_case_cprefix (), prop.name)));
+ var override_call = new CCodeFunctionCall (new CCodeIdentifier ("%soverride_set_%s".printf (get_ccode_lower_case_prefix (prop.base_property.parent_symbol), prop.name)));
override_call.add_argument (new CCodeIdentifier ("type"));
- override_call.add_argument (new CCodeIdentifier (prop.set_accessor.get_cname ()));
+ override_call.add_argument (new CCodeIdentifier (get_ccode_name (prop.set_accessor)));
type_init_block.add_statement (new CCodeExpressionStatement (override_call));
}
}
@@ -999,7 +999,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
generate_interface_declaration (iface, cfile);
- var type_priv_struct = new CCodeStruct ("_%sTypePrivate".printf (iface.get_cname ()));
+ var type_priv_struct = new CCodeStruct ("_%sTypePrivate".printf (get_ccode_name (iface)));
foreach (var type_param in iface.get_type_parameters ()) {
var type_param_decl = new CCodeDeclaration ("DovaType *");
@@ -1012,16 +1012,16 @@ public class Vala.DovaObjectModule : DovaArrayModule {
}
if (!type_priv_struct.is_empty) {
- cfile.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (type_priv_struct.name), new CCodeVariableDeclarator ("%sTypePrivate".printf (iface.get_cname ()))));
+ cfile.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (type_priv_struct.name), new CCodeVariableDeclarator ("%sTypePrivate".printf (get_ccode_name (iface)))));
cfile.add_type_definition (type_priv_struct);
}
var cdecl = new CCodeDeclaration ("DovaType *");
- cdecl.add_declarator (new CCodeVariableDeclarator ("%s_type".printf (iface.get_lower_case_cname ()), new CCodeConstant ("NULL")));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("%s_type".printf (get_ccode_lower_case_name (iface)), new CCodeConstant ("NULL")));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_type_member_declaration (cdecl);
- var type_fun = new CCodeFunction ("%s_type_get".printf (iface.get_lower_case_cname ()), "DovaType *");
+ var type_fun = new CCodeFunction ("%s_type_get".printf (get_ccode_lower_case_name (iface)), "DovaType *");
if (iface.is_internal_symbol ()) {
type_fun.modifiers = CCodeModifiers.STATIC;
}
@@ -1036,32 +1036,32 @@ public class Vala.DovaObjectModule : DovaArrayModule {
calloc_call.add_argument (new CCodeConstant ("1"));
if (!type_priv_struct.is_empty) {
- calloc_call.add_argument (new CCodeConstant ("dova_type_get_type_size (dova_type_type_get ()) + sizeof (%sTypePrivate)".printf (iface.get_cname ())));
+ calloc_call.add_argument (new CCodeConstant ("dova_type_get_type_size (dova_type_type_get ()) + sizeof (%sTypePrivate)".printf (get_ccode_name (iface))));
} else {
calloc_call.add_argument (new CCodeConstant ("dova_type_get_type_size (dova_type_type_get ())"));
}
- type_init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("%s_type".printf (iface.get_lower_case_cname ())), calloc_call)));
+ type_init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (iface))), calloc_call)));
// call any_type_init to set value_copy and similar functions
var any_type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("any_type_init"));
- any_type_init_call.add_argument (new CCodeIdentifier ("%s_type".printf (iface.get_lower_case_cname ())));
+ any_type_init_call.add_argument (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (iface))));
type_init_block.add_statement (new CCodeExpressionStatement (any_type_init_call));
- var type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_init".printf (iface.get_lower_case_cname ())));
- type_init_call.add_argument (new CCodeIdentifier ("%s_type".printf (iface.get_lower_case_cname ())));
+ var type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_init".printf (get_ccode_lower_case_name (iface))));
+ type_init_call.add_argument (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (iface))));
foreach (var type_param in iface.get_type_parameters ()) {
type_init_call.add_argument (new CCodeIdentifier ("%s_type".printf (type_param.name.down ())));
}
type_init_block.add_statement (new CCodeExpressionStatement (type_init_call));
- type_fun.block.add_statement (new CCodeIfStatement (new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, new CCodeIdentifier ("%s_type".printf (iface.get_lower_case_cname ()))), type_init_block));
+ type_fun.block.add_statement (new CCodeIfStatement (new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (iface)))), type_init_block));
- type_fun.block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("%s_type".printf (iface.get_lower_case_cname ()))));
+ type_fun.block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (iface)))));
cfile.add_function (type_fun);
- var type_init_fun = new CCodeFunction ("%s_type_init".printf (iface.get_lower_case_cname ()));
+ var type_init_fun = new CCodeFunction ("%s_type_init".printf (get_ccode_lower_case_name (iface)));
if (iface.is_internal_symbol ()) {
type_init_fun.modifiers = CCodeModifiers.STATIC;
}
@@ -1074,7 +1074,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
foreach (DataType base_type in iface.get_prerequisites ()) {
var object_type = (ObjectType) base_type;
if (object_type.type_symbol is Interface) {
- type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_init".printf (object_type.type_symbol.get_lower_case_cname ())));
+ type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_init".printf (get_ccode_lower_case_name (object_type.type_symbol))));
type_init_call.add_argument (new CCodeIdentifier ("type"));
type_init_fun.block.add_statement (new CCodeExpressionStatement (type_init_call));
}
@@ -1082,9 +1082,9 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var vtable_alloc = new CCodeFunctionCall (new CCodeIdentifier ("calloc"));
vtable_alloc.add_argument (new CCodeConstant ("1"));
- vtable_alloc.add_argument (new CCodeConstant ("sizeof (%sTypePrivate)".printf (iface.get_cname ())));
+ vtable_alloc.add_argument (new CCodeConstant ("sizeof (%sTypePrivate)".printf (get_ccode_name (iface))));
- var type_get_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (iface.get_lower_case_cname ())));
+ var type_get_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (get_ccode_lower_case_name (iface))));
foreach (var type_param in iface.get_type_parameters ()) {
type_get_call.add_argument (new CCodeIdentifier ("%s_type".printf (type_param.name.down ())));
}
@@ -1105,7 +1105,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
}
public override void generate_property_accessor_declaration (PropertyAccessor acc, CCodeFile decl_space) {
- if (add_symbol_declaration (decl_space, acc.prop, acc.get_cname ())) {
+ if (add_symbol_declaration (decl_space, acc.prop, get_ccode_name (acc))) {
return;
}
@@ -1116,9 +1116,9 @@ public class Vala.DovaObjectModule : DovaArrayModule {
CCodeFunction function;
if (acc.readable) {
- 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) {
@@ -1132,13 +1132,13 @@ public class Vala.DovaObjectModule : DovaArrayModule {
}
generate_type_declaration (this_type, decl_space);
- var cselfparam = new CCodeParameter ("this", this_type.get_cname ());
+ var cselfparam = new CCodeParameter ("this", get_ccode_name (this_type));
function.add_parameter (cselfparam);
}
if (acc.writable) {
- var cvalueparam = new CCodeParameter ("value", acc.value_type.get_cname ());
+ var cvalueparam = new CCodeParameter ("value", get_ccode_name (acc.value_type));
function.add_parameter (cvalueparam);
}
@@ -1148,16 +1148,16 @@ public class Vala.DovaObjectModule : DovaArrayModule {
decl_space.add_function_declaration (function);
if (prop.is_abstract || prop.is_virtual) {
- string param_list = "(%s *this".printf (((ObjectTypeSymbol) prop.parent_symbol).get_cname ());
+ string param_list = "(%s *this".printf (get_ccode_name (prop.parent_symbol));
if (!acc.readable) {
param_list += ", ";
- param_list += acc.value_type.get_cname ();
+ param_list += get_ccode_name (acc.value_type);
}
param_list += ")";
- var override_func = new CCodeFunction ("%soverride_%s_%s".printf (prop.parent_symbol.get_lower_case_cprefix (), acc.readable ? "get" : "set", prop.name));
+ var override_func = new CCodeFunction ("%soverride_%s_%s".printf (get_ccode_lower_case_prefix (prop.parent_symbol), acc.readable ? "get" : "set", prop.name));
override_func.add_parameter (new CCodeParameter ("type", "DovaType *"));
- override_func.add_parameter (new CCodeParameter ("(*function) %s".printf (param_list), acc.readable ? acc.value_type.get_cname () : "void"));
+ override_func.add_parameter (new CCodeParameter ("(*function) %s".printf (param_list), acc.readable ? get_ccode_name (acc.value_type) : "void"));
decl_space.add_function_declaration (override_func);
}
@@ -1188,17 +1188,17 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var t = (ObjectTypeSymbol) prop.parent_symbol;
this_type = new ObjectType (t);
}
- var cselfparam = new CCodeParameter ("this", this_type.get_cname ());
- var cvalueparam = new CCodeParameter ("value", acc.value_type.get_cname ());
+ var cselfparam = new CCodeParameter ("this", get_ccode_name (this_type));
+ var cvalueparam = new CCodeParameter ("value", get_ccode_name (acc.value_type));
- string cname = acc.get_cname ();
+ string cname = get_ccode_name (acc);
if (prop.is_abstract || prop.is_virtual) {
CCodeFunction function;
if (acc.readable) {
- 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) {
@@ -1230,16 +1230,16 @@ public class Vala.DovaObjectModule : DovaArrayModule {
cfile.add_function (function);
- string param_list = "(%s *this".printf (((ObjectTypeSymbol) prop.parent_symbol).get_cname ());
+ string param_list = "(%s *this".printf (get_ccode_name (prop.parent_symbol));
if (!acc.readable) {
param_list += ", ";
- param_list += acc.value_type.get_cname ();
+ param_list += get_ccode_name (acc.value_type);
}
param_list += ")";
- var override_func = new CCodeFunction ("%soverride_%s_%s".printf (prop.parent_symbol.get_lower_case_cprefix (), acc.readable ? "get" : "set", prop.name));
+ var override_func = new CCodeFunction ("%soverride_%s_%s".printf (get_ccode_lower_case_prefix (prop.parent_symbol), acc.readable ? "get" : "set", prop.name));
override_func.add_parameter (new CCodeParameter ("type", "DovaType *"));
- override_func.add_parameter (new CCodeParameter ("(*function) %s".printf (param_list), acc.readable ? acc.value_type.get_cname () : "void"));
+ override_func.add_parameter (new CCodeParameter ("(*function) %s".printf (param_list), acc.readable ? get_ccode_name (acc.value_type) : "void"));
push_function (override_func);
@@ -1257,7 +1257,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
if (acc.writable) {
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));
}
if (prop.binding == MemberBinding.INSTANCE) {
@@ -1277,7 +1277,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
acc.body.emit (this);
if (acc.readable) {
- var cdecl = new CCodeDeclaration (acc.value_type.get_cname ());
+ var cdecl = new CCodeDeclaration (get_ccode_name (acc.value_type));
cdecl.add_declarator (new CCodeVariableDeclarator.zero ("result", default_value_for_type (acc.value_type, true)));
function.block.prepend_statement (cdecl);
@@ -1291,17 +1291,17 @@ public class Vala.DovaObjectModule : DovaArrayModule {
}
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;
}
// typedef to DovaObject instead of dummy struct to avoid warnings/casts
generate_class_declaration (object_class, decl_space);
- decl_space.add_type_declaration (new CCodeTypeDefinition ("DovaObject", new CCodeVariableDeclarator (iface.get_cname ())));
+ decl_space.add_type_declaration (new CCodeTypeDefinition ("DovaObject", new CCodeVariableDeclarator (get_ccode_name (iface))));
generate_class_declaration (type_class, decl_space);
- var type_fun = new CCodeFunction ("%s_type_get".printf (iface.get_lower_case_cname ()), "DovaType *");
+ var type_fun = new CCodeFunction ("%s_type_get".printf (get_ccode_lower_case_name (iface)), "DovaType *");
if (iface.is_internal_symbol ()) {
type_fun.modifiers = CCodeModifiers.STATIC;
}
@@ -1310,7 +1310,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
}
decl_space.add_function_declaration (type_fun);
- var type_init_fun = new CCodeFunction ("%s_type_init".printf (iface.get_lower_case_cname ()));
+ var type_init_fun = new CCodeFunction ("%s_type_init".printf (get_ccode_lower_case_name (iface)));
if (iface.is_internal_symbol ()) {
type_init_fun.modifiers = CCodeModifiers.STATIC;
}
@@ -1338,11 +1338,11 @@ public class Vala.DovaObjectModule : DovaArrayModule {
}
public override void generate_method_declaration (Method m, CCodeFile decl_space) {
- 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_internal_symbol ()) {
function.modifiers |= CCodeModifiers.STATIC;
@@ -1357,23 +1357,23 @@ public class Vala.DovaObjectModule : DovaArrayModule {
if (m.is_abstract || m.is_virtual) {
var base_func = function.copy ();
- base_func.name = "%sbase_%s".printf (m.parent_symbol.get_lower_case_cprefix (), m.name);
+ base_func.name = "%sbase_%s".printf (get_ccode_lower_case_prefix (m.parent_symbol), m.name);
base_func.insert_parameter (0, new CCodeParameter ("base_type", "DovaType *"));
decl_space.add_function_declaration (base_func);
- string param_list = "(%s *this".printf (((ObjectTypeSymbol) m.parent_symbol).get_cname ());
+ string param_list = "(%s *this".printf (get_ccode_name (m.parent_symbol));
foreach (var param in m.get_parameters ()) {
param_list += ", ";
- param_list += param.variable_type.get_cname ();
+ param_list += get_ccode_name (param.variable_type);
}
if (m.return_type is GenericType) {
param_list += ", void *";
}
param_list += ")";
- var override_func = new CCodeFunction ("%soverride_%s".printf (m.parent_symbol.get_lower_case_cprefix (), m.name));
+ var override_func = new CCodeFunction ("%soverride_%s".printf (get_ccode_lower_case_prefix (m.parent_symbol), m.name));
override_func.add_parameter (new CCodeParameter ("type", "DovaType *"));
- override_func.add_parameter (new CCodeParameter ("(*function) %s".printf (param_list), (m.return_type is GenericType) ? "void" : m.return_type.get_cname ()));
+ override_func.add_parameter (new CCodeParameter ("(*function) %s".printf (param_list), (m.return_type is GenericType) ? "void" : get_ccode_name (m.return_type)));
decl_space.add_function_declaration (override_func);
}
@@ -1381,7 +1381,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
generate_class_declaration ((Class) m.parent_symbol, decl_space);
// _init function
- function = new CCodeFunction (m.get_real_cname ());
+ function = new CCodeFunction (get_ccode_real_name (m));
if (m.is_internal_symbol ()) {
function.modifiers |= CCodeModifiers.STATIC;
@@ -1419,7 +1419,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
generate_method_declaration (m, header_file);
}
- var function = new CCodeFunction (m.get_real_cname ());
+ var function = new CCodeFunction (get_ccode_real_name (m));
generate_cparameters (m, cfile, function);
@@ -1466,7 +1466,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
// as closures have block data parameter
if (m.binding == MemberBinding.INSTANCE) {
var cself = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data%d_".printf (block_id)), "this");
- var cdecl = new CCodeDeclaration ("%s *".printf (current_class.get_cname ()));
+ var cdecl = new CCodeDeclaration ("%s *".printf (get_ccode_name (current_class)));
cdecl.add_declarator (new CCodeVariableDeclarator ("this", cself));
ccode.add_statement (cdecl);
@@ -1495,7 +1495,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
m.body.emit (this);
if (!(m.return_type is VoidType) && !(m.return_type is GenericType)) {
- var cdecl = new CCodeDeclaration (m.return_type.get_cname ());
+ var cdecl = new CCodeDeclaration (get_ccode_name (m.return_type));
cdecl.add_declarator (new CCodeVariableDeclarator.zero ("result", default_value_for_type (m.return_type, true)));
ccode.add_statement (cdecl);
@@ -1504,7 +1504,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var st = m.parent_symbol as Struct;
if (m is CreationMethod && st != null && (st.is_boolean_type () || st.is_integer_type () || st.is_floating_type ())) {
- var cdecl = new CCodeDeclaration (st.get_cname ());
+ var cdecl = new CCodeDeclaration (get_ccode_name (st));
cdecl.add_declarator (new CCodeVariableDeclarator ("this", new CCodeConstant ("0")));
ccode.add_statement (cdecl);
@@ -1518,15 +1518,15 @@ public class Vala.DovaObjectModule : DovaArrayModule {
if (m.is_abstract || m.is_virtual) {
generate_class_declaration ((Class) object_class, cfile);
- var vfunc = new CCodeFunction (m.get_cname (), (m.return_type is GenericType) ? "void" : m.return_type.get_cname ());
+ var vfunc = new CCodeFunction (get_ccode_name (m), (m.return_type is GenericType) ? "void" : get_ccode_name (m.return_type));
vfunc.block = new CCodeBlock ();
- vfunc.add_parameter (new CCodeParameter ("this", "%s *".printf (((ObjectTypeSymbol) m.parent_symbol).get_cname ())));
+ vfunc.add_parameter (new CCodeParameter ("this", "%s *".printf (get_ccode_name (m.parent_symbol))));
foreach (TypeParameter type_param in m.get_type_parameters ()) {
vfunc.add_parameter (new CCodeParameter ("%s_type".printf (type_param.name.down ()), "DovaType*"));
}
foreach (Parameter param in m.get_parameters ()) {
- string ctypename = param.variable_type.get_cname ();
+ string ctypename = get_ccode_name (param.variable_type);
if (param.direction != ParameterDirection.IN) {
ctypename += "*";
}
@@ -1557,7 +1557,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var vcast = get_type_private_from_type ((ObjectTypeSymbol) m.parent_symbol, get_type_from_instance (new CCodeIdentifier ("this")));
- var vcall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, m.vfunc_name));
+ var vcall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, get_ccode_vfunc_name (m)));
vcall.add_argument (new CCodeIdentifier ("this"));
foreach (TypeParameter type_param in m.get_type_parameters ()) {
vcall.add_argument (new CCodeIdentifier ("%s_type".printf (type_param.name.down ())));
@@ -1578,16 +1578,16 @@ public class Vala.DovaObjectModule : DovaArrayModule {
cfile.add_function (vfunc);
- vfunc = new CCodeFunction ("%sbase_%s".printf (m.parent_symbol.get_lower_case_cprefix (), m.name), (m.return_type is GenericType) ? "void" : m.return_type.get_cname ());
+ vfunc = new CCodeFunction ("%sbase_%s".printf (get_ccode_lower_case_prefix (m.parent_symbol), m.name), (m.return_type is GenericType) ? "void" : get_ccode_name (m.return_type));
vfunc.block = new CCodeBlock ();
vfunc.add_parameter (new CCodeParameter ("base_type", "DovaType *"));
- vfunc.add_parameter (new CCodeParameter ("this", "%s *".printf (((ObjectTypeSymbol) m.parent_symbol).get_cname ())));
+ vfunc.add_parameter (new CCodeParameter ("this", "%s *".printf (get_ccode_name (m.parent_symbol))));
foreach (TypeParameter type_param in m.get_type_parameters ()) {
vfunc.add_parameter (new CCodeParameter ("%s_type".printf (type_param.name.down ()), "DovaType*"));
}
foreach (Parameter param in m.get_parameters ()) {
- string ctypename = param.variable_type.get_cname ();
+ string ctypename = get_ccode_name (param.variable_type);
if (param.direction != ParameterDirection.IN) {
ctypename += "*";
}
@@ -1601,7 +1601,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
vcast = get_type_private_from_type ((ObjectTypeSymbol) m.parent_symbol, base_type);
- vcall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, m.vfunc_name));
+ vcall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, get_ccode_vfunc_name (m)));
vcall.add_argument (new CCodeIdentifier ("this"));
foreach (TypeParameter type_param in m.get_type_parameters ()) {
vcall.add_argument (new CCodeIdentifier ("%s_type".printf (type_param.name.down ())));
@@ -1622,19 +1622,19 @@ public class Vala.DovaObjectModule : DovaArrayModule {
cfile.add_function (vfunc);
- string param_list = "(%s *this".printf (((ObjectTypeSymbol) m.parent_symbol).get_cname ());
+ string param_list = "(%s *this".printf (get_ccode_name (m.parent_symbol));
foreach (var param in m.get_parameters ()) {
param_list += ", ";
- param_list += param.variable_type.get_cname ();
+ param_list += get_ccode_name (param.variable_type);
}
if (m.return_type is GenericType) {
param_list += ", void *";
}
param_list += ")";
- var override_func = new CCodeFunction ("%soverride_%s".printf (m.parent_symbol.get_lower_case_cprefix (), m.name));
+ var override_func = new CCodeFunction ("%soverride_%s".printf (get_ccode_lower_case_prefix (m.parent_symbol), m.name));
override_func.add_parameter (new CCodeParameter ("type", "DovaType *"));
- override_func.add_parameter (new CCodeParameter ("(*function) %s".printf (param_list), (m.return_type is GenericType) ? "void" : m.return_type.get_cname ()));
+ override_func.add_parameter (new CCodeParameter ("(*function) %s".printf (param_list), (m.return_type is GenericType) ? "void" : get_ccode_name (m.return_type)));
override_func.block = new CCodeBlock ();
vcast = get_type_private_from_type ((ObjectTypeSymbol) m.parent_symbol, new CCodeIdentifier ("type"));
@@ -1748,22 +1748,22 @@ public class Vala.DovaObjectModule : DovaArrayModule {
// do not generate _new functions for creation methods of abstract classes
if (current_type_symbol is Class && !current_class.is_abstract) {
- var vfunc = new CCodeFunction (m.get_cname ());
+ var vfunc = new CCodeFunction (get_ccode_name (m));
var vblock = new CCodeBlock ();
- var cdecl = new CCodeDeclaration ("%s *".printf (current_type_symbol.get_cname ()));
+ var cdecl = new CCodeDeclaration ("%s *".printf (get_ccode_name (current_type_symbol)));
cdecl.add_declarator (new CCodeVariableDeclarator ("this"));
vblock.add_statement (cdecl);
- var type_get = new CCodeFunctionCall (new CCodeIdentifier (current_class.get_lower_case_cname () + "_type_get"));
+ var type_get = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_lower_case_name (current_class) + "_type_get"));
foreach (var type_param in current_class.get_type_parameters ()) {
type_get.add_argument (new CCodeIdentifier ("%s_type".printf (type_param.name.down ())));
}
var alloc_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_object_alloc"));
alloc_call.add_argument (type_get);
- vblock.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("this"), new CCodeCastExpression (alloc_call, "%s *".printf (current_type_symbol.get_cname ())))));
+ vblock.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("this"), new CCodeCastExpression (alloc_call, "%s *".printf (get_ccode_name (current_type_symbol))))));
// allocate memory for fields of generic types
// this is only a temporary measure until this can be allocated inline at the end of the instance
@@ -1780,13 +1780,13 @@ public class Vala.DovaObjectModule : DovaArrayModule {
var calloc_call = new CCodeFunctionCall (new CCodeIdentifier ("calloc"));
calloc_call.add_argument (new CCodeConstant ("1"));
calloc_call.add_argument (type_get_value_size);
- var priv_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (current_class.get_upper_case_cname (null))));
+ var priv_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (get_ccode_upper_case_name (current_class, null))));
priv_call.add_argument (new CCodeIdentifier ("this"));
vblock.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (priv_call, f.name), calloc_call)));
}
- var vcall = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname ()));
+ var vcall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_real_name (m)));
vcall.add_argument (new CCodeIdentifier ("this"));
vblock.add_statement (new CCodeExpressionStatement (vcall));
@@ -1825,7 +1825,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
instance_param = new CCodeParameter ("_data%d_".printf (block_id), "Block%dData*".printf (block_id));
} else if (m.parent_symbol is Class && m is CreationMethod) {
if (vcall == null) {
- instance_param = new CCodeParameter ("this", ((Class) m.parent_symbol).get_cname () + "*");
+ instance_param = new CCodeParameter ("this", get_ccode_name (((Class) m.parent_symbol)) + "*");
}
} else if (m.binding == MemberBinding.INSTANCE || (m.parent_symbol is Struct && m is CreationMethod)) {
TypeSymbol parent_type = find_parent_type (m);
@@ -1835,21 +1835,21 @@ public class Vala.DovaObjectModule : DovaArrayModule {
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 ("this", base_type.get_cname ());
+ instance_param = new CCodeParameter ("this", get_ccode_name (base_type));
} else if (m.overrides) {
var base_type = new ObjectType ((Class) m.base_method.parent_symbol);
generate_type_declaration (base_type, decl_space);
- instance_param = new CCodeParameter ("this", base_type.get_cname ());
+ instance_param = new CCodeParameter ("this", get_ccode_name (base_type));
} else {
if (m.parent_symbol is Struct && m is CreationMethod) {
var st = (Struct) m.parent_symbol;
if (st.is_boolean_type () || st.is_integer_type () || st.is_floating_type ()) {
// use return value
} else {
- instance_param = new CCodeParameter ("*this", this_type.get_cname ());
+ instance_param = new CCodeParameter ("*this", get_ccode_name (this_type));
}
} else {
- instance_param = new CCodeParameter ("this", this_type.get_cname ());
+ instance_param = new CCodeParameter ("this", get_ccode_name (this_type));
}
}
}
@@ -1888,7 +1888,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
foreach (Parameter param in m.get_parameters ()) {
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);
@@ -1913,7 +1913,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
}
if (m.parent_symbol is Class && m is CreationMethod && vcall != null) {
- func.return_type = ((Class) m.parent_symbol).get_cname () + "*";
+ func.return_type = get_ccode_name (((Class) m.parent_symbol)) + "*";
} else {
if (m.return_type is GenericType) {
func.add_parameter (new CCodeParameter ("result", "void *"));
@@ -1923,9 +1923,9 @@ public class Vala.DovaObjectModule : DovaArrayModule {
} else {
var st = m.parent_symbol as Struct;
if (m is CreationMethod && st != null && (st.is_boolean_type () || st.is_integer_type () || st.is_floating_type ())) {
- func.return_type = st.get_cname ();
+ func.return_type = get_ccode_name (st);
} else {
- func.return_type = m.return_type.get_cname ();
+ func.return_type = get_ccode_name (m.return_type);
}
}
@@ -1963,7 +1963,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
value_size.add_argument (get_type_id_expression (array_type.element_type));
set_cvalue (expr, new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeCastExpression (ccontainer, "char*"), new CCodeBinaryExpression (CCodeBinaryOperator.MUL, value_size, cindex)));
} else {
- set_cvalue (expr, new CCodeElementAccess (new CCodeCastExpression (ccontainer, "%s*".printf (array_type.element_type.get_cname ())), cindex));
+ set_cvalue (expr, new CCodeElementAccess (new CCodeCastExpression (ccontainer, "%s*".printf (get_ccode_name (array_type.element_type))), cindex));
}
}
@@ -1976,7 +1976,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
foreach (var field in static_fields) {
field.initializer.emit (this);
- var lhs = new CCodeIdentifier (field.get_cname ());
+ var lhs = new CCodeIdentifier (get_ccode_name (field));
var rhs = get_cvalue (field.initializer);
ccode.add_assignment (lhs, rhs);
diff --git a/codegen/valadovastructmodule.vala b/codegen/valadovastructmodule.vala
index 94d7ef4..642519d 100644
--- a/codegen/valadovastructmodule.vala
+++ b/codegen/valadovastructmodule.vala
@@ -24,14 +24,14 @@ using GLib;
public abstract class Vala.DovaStructModule : DovaBaseModule {
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;
}
if (st.base_struct != null) {
generate_struct_declaration (st.base_struct, decl_space);
- 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))));
return;
}
@@ -49,10 +49,10 @@ public abstract class Vala.DovaStructModule : DovaBaseModule {
return;
}
- var instance_struct = new CCodeStruct ("_%s".printf (st.get_cname ()));
+ var instance_struct = new CCodeStruct ("_%s".printf (get_ccode_name (st)));
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;
}
@@ -60,11 +60,11 @@ public abstract class Vala.DovaStructModule : DovaBaseModule {
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 ());
}
}
- 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);
}
diff --git a/codegen/valadovavaluemodule.vala b/codegen/valadovavaluemodule.vala
index dee99af..f7ddd04 100644
--- a/codegen/valadovavaluemodule.vala
+++ b/codegen/valadovavaluemodule.vala
@@ -35,33 +35,33 @@ public class Vala.DovaValueModule : DovaObjectModule {
public override void generate_struct_declaration (Struct st, CCodeFile decl_space) {
base.generate_struct_declaration (st, decl_space);
- if (add_symbol_declaration (decl_space, st, st.get_copy_function ())) {
+ if (add_symbol_declaration (decl_space, st, get_ccode_copy_function (st))) {
return;
}
generate_class_declaration (type_class, decl_space);
- var type_fun = new CCodeFunction ("%s_type_get".printf (st.get_lower_case_cname ()), "DovaType *");
+ var type_fun = new CCodeFunction ("%s_type_get".printf (get_ccode_lower_case_name (st)), "DovaType *");
if (st.is_internal_symbol ()) {
type_fun.modifiers = CCodeModifiers.STATIC;
}
decl_space.add_function_declaration (type_fun);
- var type_init_fun = new CCodeFunction ("%s_type_init".printf (st.get_lower_case_cname ()));
+ var type_init_fun = new CCodeFunction ("%s_type_init".printf (get_ccode_lower_case_name (st)));
type_init_fun.add_parameter (new CCodeParameter ("type", "DovaType *"));
if (st.is_internal_symbol ()) {
type_init_fun.modifiers = CCodeModifiers.STATIC;
}
decl_space.add_function_declaration (type_init_fun);
- var function = new CCodeFunction (st.get_copy_function (), "void");
+ var function = new CCodeFunction (get_ccode_copy_function (st), "void");
if (st.is_internal_symbol ()) {
function.modifiers = CCodeModifiers.STATIC;
}
- function.add_parameter (new CCodeParameter ("dest", st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("dest", get_ccode_name (st) + "*"));
function.add_parameter (new CCodeParameter ("dest_index", "intptr_t"));
- function.add_parameter (new CCodeParameter ("src", st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("src", get_ccode_name (st) + "*"));
function.add_parameter (new CCodeParameter ("src_index", "intptr_t"));
decl_space.add_function_declaration (function);
@@ -71,20 +71,20 @@ public class Vala.DovaValueModule : DovaObjectModule {
base.visit_struct (st);
var cdecl = new CCodeDeclaration ("intptr_t");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_%s_object_offset".printf (st.get_lower_case_cname ()), new CCodeConstant ("0")));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_%s_object_offset".printf (get_ccode_lower_case_name (st)), new CCodeConstant ("0")));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_type_member_declaration (cdecl);
- string macro = "((%s *) (((char *) o) + _%s_object_offset))".printf (st.get_cname (), st.get_lower_case_cname ());
- cfile.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_PRIVATE(o)".printf (st.get_upper_case_cname (null)), macro));
+ string macro = "((%s *) (((char *) o) + _%s_object_offset))".printf (get_ccode_name (st), get_ccode_lower_case_name (st));
+ cfile.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_PRIVATE(o)".printf (get_ccode_upper_case_name (st, null)), macro));
cdecl = new CCodeDeclaration ("DovaType *");
- cdecl.add_declarator (new CCodeVariableDeclarator ("%s_type".printf (st.get_lower_case_cname ()), new CCodeConstant ("NULL")));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("%s_type".printf (get_ccode_lower_case_name (st)), new CCodeConstant ("NULL")));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_type_member_declaration (cdecl);
- var type_fun = new CCodeFunction ("%s_type_get".printf (st.get_lower_case_cname ()), "DovaType *");
+ var type_fun = new CCodeFunction ("%s_type_get".printf (get_ccode_lower_case_name (st)), "DovaType *");
type_fun.block = new CCodeBlock ();
var type_init_block = new CCodeBlock ();
@@ -109,56 +109,56 @@ public class Vala.DovaValueModule : DovaObjectModule {
calloc_call.add_argument (new CCodeConstant ("1"));
calloc_call.add_argument (base_type_size);
- type_init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("%s_type".printf (st.get_lower_case_cname ())), calloc_call)));
+ type_init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (st))), calloc_call)));
generate_class_declaration ((Class) object_class, cfile);
- type_init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (new CCodeCastExpression (new CCodeIdentifier ("%s_type".printf (st.get_lower_case_cname ())), "DovaObject *"), "type"), new CCodeFunctionCall (new CCodeIdentifier ("dova_type_type_get")))));
+ type_init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (new CCodeCastExpression (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (st))), "DovaObject *"), "type"), new CCodeFunctionCall (new CCodeIdentifier ("dova_type_type_get")))));
var set_base_type = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_base_type"));
- set_base_type.add_argument (new CCodeIdentifier ("%s_type".printf (st.get_lower_case_cname ())));
+ set_base_type.add_argument (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (st))));
set_base_type.add_argument (base_type);
type_init_block.add_statement (new CCodeExpressionStatement (set_base_type));
var base_size = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_get_object_size"));
base_size.add_argument (base_type);
- type_init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("_%s_object_offset".printf (st.get_lower_case_cname ())), base_size)));
+ type_init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("_%s_object_offset".printf (get_ccode_lower_case_name (st))), base_size)));
var sizeof_call = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
- sizeof_call.add_argument (new CCodeIdentifier (st.get_cname ()));
+ sizeof_call.add_argument (new CCodeIdentifier (get_ccode_name (st)));
var set_size = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_object_size"));
- set_size.add_argument (new CCodeIdentifier ("%s_type".printf (st.get_lower_case_cname ())));
+ set_size.add_argument (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (st))));
set_size.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, base_size, sizeof_call));
type_init_block.add_statement (new CCodeExpressionStatement (set_size));
set_size = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_value_size"));
- set_size.add_argument (new CCodeIdentifier ("%s_type".printf (st.get_lower_case_cname ())));
+ set_size.add_argument (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (st))));
set_size.add_argument (sizeof_call);
type_init_block.add_statement (new CCodeExpressionStatement (set_size));
set_size = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_type_size"));
- set_size.add_argument (new CCodeIdentifier ("%s_type".printf (st.get_lower_case_cname ())));
+ set_size.add_argument (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (st))));
set_size.add_argument (base_type_size);
type_init_block.add_statement (new CCodeExpressionStatement (set_size));
- var type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_init".printf (st.get_lower_case_cname ())));
- type_init_call.add_argument (new CCodeIdentifier ("%s_type".printf (st.get_lower_case_cname ())));
+ var type_init_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_type_init".printf (get_ccode_lower_case_name (st))));
+ type_init_call.add_argument (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (st))));
type_init_block.add_statement (new CCodeExpressionStatement (type_init_call));
// workaround: set value_size again as it is currently overwritten by dova_object_type_init
set_size = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_value_size"));
- set_size.add_argument (new CCodeIdentifier ("%s_type".printf (st.get_lower_case_cname ())));
+ set_size.add_argument (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (st))));
set_size.add_argument (sizeof_call);
type_init_block.add_statement (new CCodeExpressionStatement (set_size));
- type_fun.block.add_statement (new CCodeIfStatement (new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, new CCodeIdentifier ("%s_type".printf (st.get_lower_case_cname ()))), type_init_block));
+ type_fun.block.add_statement (new CCodeIfStatement (new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (st)))), type_init_block));
- type_fun.block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("%s_type".printf (st.get_lower_case_cname ()))));
+ type_fun.block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("%s_type".printf (get_ccode_lower_case_name (st)))));
cfile.add_function (type_fun);
- var type_init_fun = new CCodeFunction ("%s_type_init".printf (st.get_lower_case_cname ()));
+ var type_init_fun = new CCodeFunction ("%s_type_init".printf (get_ccode_lower_case_name (st)));
type_init_fun.add_parameter (new CCodeParameter ("type", "DovaType *"));
type_init_fun.block = new CCodeBlock ();
@@ -170,20 +170,20 @@ public class Vala.DovaValueModule : DovaObjectModule {
var value_copy_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_value_copy"));
value_copy_call.add_argument (new CCodeIdentifier ("type"));
- value_copy_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("%s_copy".printf (st.get_lower_case_cname ())), "void (*)(void *, intptr_t, void *, intptr_t)"));
+ value_copy_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("%s_copy".printf (get_ccode_lower_case_name (st))), "void (*)(void *, intptr_t, void *, intptr_t)"));
type_init_fun.block.add_statement (new CCodeExpressionStatement (value_copy_call));
if (st.scope.lookup ("equals") is Method) {
- var value_equals_fun = new CCodeFunction ("%s_value_equals".printf (st.get_lower_case_cname ()), "bool");
+ var value_equals_fun = new CCodeFunction ("%s_value_equals".printf (get_ccode_lower_case_name (st)), "bool");
value_equals_fun.modifiers = CCodeModifiers.STATIC;
- value_equals_fun.add_parameter (new CCodeParameter ("value", st.get_cname () + "*"));
+ value_equals_fun.add_parameter (new CCodeParameter ("value", get_ccode_name (st) + "*"));
value_equals_fun.add_parameter (new CCodeParameter ("value_index", "intptr_t"));
- value_equals_fun.add_parameter (new CCodeParameter ("other", st.get_cname () + "*"));
+ value_equals_fun.add_parameter (new CCodeParameter ("other", get_ccode_name (st) + "*"));
value_equals_fun.add_parameter (new CCodeParameter ("other_index", "intptr_t"));
value_equals_fun.block = new CCodeBlock ();
var val = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier ("value"), new CCodeIdentifier ("value_index"));
var other = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier ("other"), new CCodeIdentifier ("other_index"));
- var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_equals".printf (st.get_lower_case_cname ())));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_equals".printf (get_ccode_lower_case_name (st))));
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, val));
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, other));
value_equals_fun.block.add_statement (new CCodeReturnStatement (ccall));
@@ -193,18 +193,18 @@ public class Vala.DovaValueModule : DovaObjectModule {
var value_equals_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_value_equals"));
value_equals_call.add_argument (new CCodeIdentifier ("type"));
- value_equals_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("%s_value_equals".printf (st.get_lower_case_cname ())), "bool (*)(void *, intptr_t, void *, intptr_t)"));
+ value_equals_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("%s_value_equals".printf (get_ccode_lower_case_name (st))), "bool (*)(void *, intptr_t, void *, intptr_t)"));
type_init_fun.block.add_statement (new CCodeExpressionStatement (value_equals_call));
}
if (st.scope.lookup ("hash") is Method) {
- var value_hash_fun = new CCodeFunction ("%s_value_hash".printf (st.get_lower_case_cname ()), "uintptr_t");
+ var value_hash_fun = new CCodeFunction ("%s_value_hash".printf (get_ccode_lower_case_name (st)), "uintptr_t");
value_hash_fun.modifiers = CCodeModifiers.STATIC;
- value_hash_fun.add_parameter (new CCodeParameter ("value", st.get_cname () + "*"));
+ value_hash_fun.add_parameter (new CCodeParameter ("value", get_ccode_name (st) + "*"));
value_hash_fun.add_parameter (new CCodeParameter ("value_index", "intptr_t"));
value_hash_fun.block = new CCodeBlock ();
var val = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier ("value"), new CCodeIdentifier ("value_index"));
- var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_hash".printf (st.get_lower_case_cname ())));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_hash".printf (get_ccode_lower_case_name (st))));
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, val));
value_hash_fun.block.add_statement (new CCodeReturnStatement (ccall));
cfile.add_function (value_hash_fun);
@@ -213,24 +213,24 @@ public class Vala.DovaValueModule : DovaObjectModule {
var value_hash_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_value_hash"));
value_hash_call.add_argument (new CCodeIdentifier ("type"));
- value_hash_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("%s_value_hash".printf (st.get_lower_case_cname ())), "uintptr_t (*)(void *, intptr_t)"));
+ value_hash_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("%s_value_hash".printf (get_ccode_lower_case_name (st))), "uintptr_t (*)(void *, intptr_t)"));
type_init_fun.block.add_statement (new CCodeExpressionStatement (value_hash_call));
}
// generate method to box values
- var value_to_any_fun = new CCodeFunction ("%s_value_to_any".printf (st.get_lower_case_cname ()), "DovaObject*");
+ var value_to_any_fun = new CCodeFunction ("%s_value_to_any".printf (get_ccode_lower_case_name (st)), "DovaObject*");
value_to_any_fun.modifiers = CCodeModifiers.STATIC;
value_to_any_fun.add_parameter (new CCodeParameter ("value", "void *"));
value_to_any_fun.add_parameter (new CCodeParameter ("value_index", "intptr_t"));
value_to_any_fun.block = new CCodeBlock ();
var alloc_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_object_alloc"));
- alloc_call.add_argument (new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (st.get_lower_case_cname ()))));
+ alloc_call.add_argument (new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (get_ccode_lower_case_name (st)))));
cdecl = new CCodeDeclaration ("DovaObject *");
cdecl.add_declarator (new CCodeVariableDeclarator ("result", alloc_call));
value_to_any_fun.block.add_statement (cdecl);
- var priv_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (st.get_upper_case_cname (null))));
+ var priv_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (get_ccode_upper_case_name (st, null))));
priv_call.add_argument (new CCodeIdentifier ("result"));
- var copy_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_copy".printf (st.get_lower_case_cname ())));
+ var copy_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_copy".printf (get_ccode_lower_case_name (st))));
copy_call.add_argument (priv_call);
copy_call.add_argument (new CCodeConstant ("0"));
copy_call.add_argument (new CCodeIdentifier ("value"));
@@ -243,19 +243,19 @@ public class Vala.DovaValueModule : DovaObjectModule {
var value_to_any_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_value_to_any"));
value_to_any_call.add_argument (new CCodeIdentifier ("type"));
- value_to_any_call.add_argument (new CCodeIdentifier ("%s_value_to_any".printf (st.get_lower_case_cname ())));
+ value_to_any_call.add_argument (new CCodeIdentifier ("%s_value_to_any".printf (get_ccode_lower_case_name (st))));
type_init_fun.block.add_statement (new CCodeExpressionStatement (value_to_any_call));
// generate method to unbox values
- var value_from_any_fun = new CCodeFunction ("%s_value_from_any".printf (st.get_lower_case_cname ()));
+ var value_from_any_fun = new CCodeFunction ("%s_value_from_any".printf (get_ccode_lower_case_name (st)));
value_from_any_fun.modifiers = CCodeModifiers.STATIC;
value_from_any_fun.add_parameter (new CCodeParameter ("any_", "any *"));
- value_from_any_fun.add_parameter (new CCodeParameter ("value", st.get_cname () + "*"));
+ value_from_any_fun.add_parameter (new CCodeParameter ("value", get_ccode_name (st) + "*"));
value_from_any_fun.add_parameter (new CCodeParameter ("value_index", "intptr_t"));
value_from_any_fun.block = new CCodeBlock ();
- priv_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (st.get_upper_case_cname (null))));
+ priv_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (get_ccode_upper_case_name (st, null))));
priv_call.add_argument (new CCodeIdentifier ("any_"));
- copy_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_copy".printf (st.get_lower_case_cname ())));
+ copy_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_copy".printf (get_ccode_lower_case_name (st))));
copy_call.add_argument (new CCodeIdentifier ("value"));
copy_call.add_argument (new CCodeIdentifier ("value_index"));
copy_call.add_argument (priv_call);
@@ -267,7 +267,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
var value_from_any_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_set_value_from_any"));
value_from_any_call.add_argument (new CCodeIdentifier ("type"));
- value_from_any_call.add_argument (new CCodeIdentifier ("%s_value_from_any".printf (st.get_lower_case_cname ())));
+ value_from_any_call.add_argument (new CCodeIdentifier ("%s_value_from_any".printf (get_ccode_lower_case_name (st))));
type_init_fun.block.add_statement (new CCodeExpressionStatement (value_from_any_call));
cfile.add_function (type_init_fun);
@@ -276,14 +276,14 @@ public class Vala.DovaValueModule : DovaObjectModule {
}
void add_struct_copy_function (Struct st) {
- var function = new CCodeFunction (st.get_copy_function (), "void");
+ var function = new CCodeFunction (get_ccode_copy_function (st), "void");
if (st.is_internal_symbol ()) {
function.modifiers = CCodeModifiers.STATIC;
}
- function.add_parameter (new CCodeParameter ("dest", st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("dest", get_ccode_name (st) + "*"));
function.add_parameter (new CCodeParameter ("dest_index", "intptr_t"));
- function.add_parameter (new CCodeParameter ("src", st.get_cname () + "*"));
+ function.add_parameter (new CCodeParameter ("src", get_ccode_name (st) + "*"));
function.add_parameter (new CCodeParameter ("src_index", "intptr_t"));
var cblock = new CCodeBlock ();
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index e9820fb..a7c4af1 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,11 +46,11 @@ 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;
- if (!param.no_array_length) {
+ if (get_ccode_array_length (param)) {
for (int dim = 1; dim <= array_type.rank; dim++) {
data.add_field ("gint", get_parameter_array_length_cname (param, dim));
}
@@ -73,10 +73,10 @@ 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) {
+ if (get_ccode_array_length (m)) {
for (int dim = 1; dim <= array_type.rank; dim++) {
data.add_field ("gint", get_array_length_cname ("result", dim));
}
@@ -94,9 +94,9 @@ 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");
+ var freefunc = new CCodeFunction (get_ccode_real_name (m) + "_data_free", "void");
freefunc.modifiers = CCodeModifiers.STATIC;
freefunc.add_parameter (new CCodeParameter ("_data", "gpointer"));
@@ -156,8 +156,8 @@ 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 asyncfunc = new CCodeFunction (m.get_real_cname (), "void");
+ var dataname = Symbol.lower_case_to_camel_case (get_ccode_name (m)) + "Data";
+ var asyncfunc = new CCodeFunction (get_ccode_real_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"));
@@ -190,7 +190,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"), true), 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);
}
@@ -226,14 +226,14 @@ public class Vala.GAsyncModule : GSignalModule {
create_result.add_argument (new CCodeIdentifier ("_callback_"));
create_result.add_argument (new CCodeIdentifier ("_user_data_"));
- create_result.add_argument (new CCodeIdentifier (m.get_real_cname ()));
+ create_result.add_argument (new CCodeIdentifier (get_ccode_real_name (m)));
ccode.add_assignment (new CCodeMemberAccess.pointer (data_var, "_async_result"), create_result);
var set_op_res_call = new CCodeFunctionCall (new CCodeIdentifier ("g_simple_async_result_set_op_res_gpointer"));
set_op_res_call.add_argument (new CCodeMemberAccess.pointer (data_var, "_async_result"));
set_op_res_call.add_argument (data_var);
- set_op_res_call.add_argument (new CCodeIdentifier (m.get_real_cname () + "_data_free"));
+ set_op_res_call.add_argument (new CCodeIdentifier (get_ccode_real_name (m) + "_data_free"));
ccode.add_expression (set_op_res_call);
if (m.binding == MemberBinding.INSTANCE) {
@@ -286,7 +286,7 @@ public class Vala.GAsyncModule : GSignalModule {
ccode.add_assignment (new CCodeMemberAccess.pointer (data_var, destroy_func), new CCodeIdentifier (destroy_func));
}
- var ccall = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname () + "_co"));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_real_name (m) + "_co"));
ccall.add_argument (data_var);
ccode.add_expression (ccall);
@@ -304,11 +304,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"));
@@ -321,7 +321,7 @@ public class Vala.GAsyncModule : GSignalModule {
decl_space.add_function_declaration (asyncfunc);
- var finishfunc = new CCodeFunction (m.get_finish_cname ());
+ var finishfunc = new CCodeFunction (get_ccode_finish_name (m));
cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
cparam_map.set (get_param_pos (0.1), new CCodeParameter ("_res_", "GAsyncResult*"));
@@ -390,9 +390,9 @@ 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 ());
+ var finishfunc = new CCodeFunction (get_ccode_finish_real_name (m));
var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
@@ -408,7 +408,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_");
@@ -455,7 +455,7 @@ public class Vala.GAsyncModule : GSignalModule {
ccode.add_assignment (new CCodeIdentifier ("result"), new CCodeMemberAccess.pointer (data_var, "result"));
if (return_type is ArrayType) {
var array_type = (ArrayType) return_type;
- if (!m.no_array_length) {
+ if (get_ccode_array_length (m)) {
for (int dim = 1; dim <= array_type.rank; dim++) {
ccode.add_assignment (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier (get_array_length_cname ("result", dim))), new CCodeMemberAccess.pointer (data_var, get_array_length_cname ("result", dim)));
}
@@ -479,9 +479,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
@@ -499,7 +499,7 @@ public class Vala.GAsyncModule : GSignalModule {
ccode.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_source_object_"), new CCodeIdentifier ("source_object"));
ccode.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_res_"), new CCodeIdentifier ("_res_"));
- var ccall = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname () + "_co"));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_real_name (m) + "_co"));
ccall.add_argument (new CCodeIdentifier ("_data_"));
ccode.add_expression (ccall);
@@ -530,7 +530,7 @@ public class Vala.GAsyncModule : GSignalModule {
}
// add vfunc field to the type struct
- var vdeclarator = new CCodeFunctionDeclarator (m.vfunc_name);
+ var vdeclarator = new CCodeFunctionDeclarator (get_ccode_vfunc_name (m));
var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
generate_cparameters (m, decl_space, cparam_map, new CCodeFunction ("fake"), vdeclarator, null, null, 1);
@@ -540,12 +540,12 @@ public class Vala.GAsyncModule : GSignalModule {
type_struct.add_declaration (vdecl);
// add vfunc field to the type struct
- vdeclarator = new CCodeFunctionDeclarator (m.get_finish_vfunc_name ());
+ vdeclarator = new CCodeFunctionDeclarator (get_ccode_finish_vfunc_name (m));
cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
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 23ba1c3..695ccbc 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);
@@ -74,10 +74,10 @@ public class Vala.GDBusClientModule : GDBusModule {
}
}
- string lower_cname = main_iface.get_lower_case_cprefix () + "proxy";
+ string lower_cname = get_ccode_lower_case_prefix (main_iface) + "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*"));
+ var proxy_iface_init = new CCodeFunction (lower_cname + "_" + get_ccode_lower_case_prefix (iface) + "interface_init", "void");
+ proxy_iface_init.add_parameter (new CCodeParameter ("iface", get_ccode_name (iface) + "Iface*"));
push_function (proxy_iface_init);
@@ -86,12 +86,12 @@ public class Vala.GDBusClientModule : GDBusModule {
continue;
}
- var vfunc_entry = new CCodeMemberAccess.pointer (new CCodeIdentifier ("iface"), m.vfunc_name);
+ var vfunc_entry = new CCodeMemberAccess.pointer (new CCodeIdentifier ("iface"), get_ccode_vfunc_name (m));
if (!m.coroutine) {
ccode.add_assignment (vfunc_entry, new CCodeIdentifier (generate_dbus_proxy_method (main_iface, iface, m)));
} else {
ccode.add_assignment (vfunc_entry, new CCodeIdentifier (generate_async_dbus_proxy_method (main_iface, iface, m)));
- vfunc_entry = new CCodeMemberAccess.pointer (new CCodeIdentifier ("iface"), m.get_finish_vfunc_name ());
+ vfunc_entry = new CCodeMemberAccess.pointer (new CCodeIdentifier ("iface"), get_ccode_finish_vfunc_name (m));
ccode.add_assignment (vfunc_entry, new CCodeIdentifier (generate_finish_dbus_proxy_method (main_iface, iface, m)));
}
}
@@ -128,9 +128,9 @@ public class Vala.GDBusClientModule : GDBusModule {
}
result += "G_IMPLEMENT_INTERFACE (%s, %sproxy_%sinterface_init) ".printf (
- iface.get_upper_case_cname ("TYPE_"),
- main_iface.get_lower_case_cprefix (),
- iface.get_lower_case_cprefix ());
+ get_ccode_upper_case_name (iface, "TYPE_"),
+ get_ccode_lower_case_prefix (main_iface),
+ get_ccode_lower_case_prefix (iface));
return result;
}
@@ -142,7 +142,7 @@ public class Vala.GDBusClientModule : GDBusModule {
return;
}
- string get_type_name = "%sproxy_get_type".printf (iface.get_lower_case_cprefix ());
+ string get_type_name = "%sproxy_get_type".printf (get_ccode_lower_case_prefix (iface));
if (add_symbol_declaration (decl_space, iface, get_type_name)) {
return;
@@ -150,7 +150,7 @@ public class Vala.GDBusClientModule : GDBusModule {
decl_space.add_type_declaration (new CCodeNewline ());
var macro = "(%s ())".printf (get_type_name);
- decl_space.add_type_declaration (new CCodeMacroReplacement ("%s_PROXY".printf (iface.get_type_id ()), macro));
+ decl_space.add_type_declaration (new CCodeMacroReplacement ("%s_PROXY".printf (get_ccode_type_id (iface)), macro));
// declare proxy_get_type function
var proxy_get_type = new CCodeFunction (get_type_name, "GType");
@@ -169,8 +169,8 @@ public class Vala.GDBusClientModule : GDBusModule {
cfile.add_include ("gio/gio.h");
// create proxy class
- string cname = iface.get_cname () + "Proxy";
- string lower_cname = iface.get_lower_case_cprefix () + "proxy";
+ string cname = get_ccode_name (iface) + "Proxy";
+ string lower_cname = get_ccode_lower_case_prefix (iface) + "proxy";
cfile.add_type_declaration (new CCodeTypeDefinition ("GDBusProxy", new CCodeVariableDeclarator (cname)));
cfile.add_type_declaration (new CCodeTypeDefinition ("GDBusProxyClass", new CCodeVariableDeclarator (cname + "Class")));
@@ -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;
@@ -230,7 +230,7 @@ public class Vala.GDBusClientModule : GDBusModule {
return;
}
- proxy_type = new CCodeIdentifier ("%s_PROXY".printf (iface.get_type_id ()));
+ proxy_type = new CCodeIdentifier ("%s_PROXY".printf (get_ccode_type_id (iface)));
dbus_iface_name = new CCodeConstant ("\"%s\"".printf (get_dbus_name (iface)));
} else {
// use runtime type information for generic methods
@@ -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 (get_ccode_lower_case_name (sym), 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);
@@ -401,14 +401,14 @@ public class Vala.GDBusClientModule : GDBusModule {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_emit_by_name"));
ccall.add_argument (new CCodeIdentifier ("self"));
- ccall.add_argument (sig.get_canonical_cconstant ());
+ ccall.add_argument (get_signal_canonical_constant (sig));
foreach (Parameter param in sig.get_parameters ()) {
var param_name = get_variable_cname (param.name);
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 ()) {
@@ -453,7 +453,7 @@ public class Vala.GDBusClientModule : GDBusModule {
}
void generate_signal_handler_function (ObjectTypeSymbol sym) {
- var cfunc = new CCodeFunction (sym.get_lower_case_cprefix () + "proxy_g_signal", "void");
+ var cfunc = new CCodeFunction (get_ccode_lower_case_prefix (sym) + "proxy_g_signal", "void");
cfunc.add_parameter (new CCodeParameter ("proxy", "GDBusProxy*"));
cfunc.add_parameter (new CCodeParameter ("sender_name", "const gchar*"));
cfunc.add_parameter (new CCodeParameter ("signal_name", "const gchar*"));
@@ -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);
@@ -529,7 +529,7 @@ public class Vala.GDBusClientModule : GDBusModule {
foreach (var error_type in m.get_error_types ()) {
var errtype = (ErrorType) error_type;
if (errtype.error_domain != null) {
- ccode.add_expression (new CCodeIdentifier (errtype.error_domain.get_upper_case_cname ()));
+ ccode.add_expression (new CCodeIdentifier (get_ccode_upper_case_name (errtype.error_domain)));
}
}
@@ -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 ("_vala_" + param.name));
+ ccode.add_declaration (get_ccode_name (param.variable_type), new CCodeVariableDeclarator ("_vala_" + 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;
@@ -794,7 +794,7 @@ public class Vala.GDBusClientModule : GDBusModule {
}
string generate_dbus_proxy_method (Interface main_iface, Interface iface, Method m) {
- string proxy_name = "%sproxy_%s".printf (main_iface.get_lower_case_cprefix (), m.name);
+ string proxy_name = "%sproxy_%s".printf (get_ccode_lower_case_prefix (main_iface), m.name);
string dbus_iface_name = get_dbus_name (iface);
@@ -820,7 +820,7 @@ public class Vala.GDBusClientModule : GDBusModule {
}
string generate_async_dbus_proxy_method (Interface main_iface, Interface iface, Method m) {
- string proxy_name = "%sproxy_%s_async".printf (main_iface.get_lower_case_cprefix (), m.name);
+ string proxy_name = "%sproxy_%s_async".printf (get_ccode_lower_case_prefix (main_iface), m.name);
string dbus_iface_name = get_dbus_name (iface);
@@ -847,7 +847,7 @@ public class Vala.GDBusClientModule : GDBusModule {
}
string generate_finish_dbus_proxy_method (Interface main_iface, Interface iface, Method m) {
- string proxy_name = "%sproxy_%s_finish".printf (main_iface.get_lower_case_cprefix (), m.name);
+ string proxy_name = "%sproxy_%s_finish".printf (get_ccode_lower_case_prefix (main_iface), m.name);
var function = new CCodeFunction (proxy_name);
function.modifiers = CCodeModifiers.STATIC;
@@ -871,7 +871,7 @@ public class Vala.GDBusClientModule : GDBusModule {
}
string generate_dbus_proxy_property_get (Interface main_iface, Interface iface, Property prop) {
- string proxy_name = "%sdbus_proxy_get_%s".printf (main_iface.get_lower_case_cprefix (), prop.name);
+ string proxy_name = "%sdbus_proxy_get_%s".printf (get_ccode_lower_case_prefix (main_iface), prop.name);
string dbus_iface_name = get_dbus_name (iface);
@@ -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++) {
@@ -1002,7 +1002,7 @@ public class Vala.GDBusClientModule : GDBusModule {
}
string generate_dbus_proxy_property_set (Interface main_iface, Interface iface, Property prop) {
- string proxy_name = "%sdbus_proxy_set_%s".printf (main_iface.get_lower_case_cprefix (), prop.name);
+ string proxy_name = "%sdbus_proxy_set_%s".printf (get_ccode_lower_case_prefix (main_iface), prop.name);
string dbus_iface_name = get_dbus_name (iface);
@@ -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++) {
@@ -1103,10 +1103,10 @@ public class Vala.GDBusClientModule : GDBusModule {
var quark = new CCodeFunctionCall (new CCodeIdentifier ("g_quark_from_static_string"));
quark.add_argument (new CCodeConstant ("\"vala-dbus-proxy-type\""));
- var proxy_type = new CCodeIdentifier (sym.get_lower_case_cprefix () + "proxy_get_type");
+ var proxy_type = new CCodeIdentifier (get_ccode_lower_case_prefix (sym) + "proxy_get_type");
var set_qdata = new CCodeFunctionCall (new CCodeIdentifier ("g_type_set_qdata"));
- set_qdata.add_argument (new CCodeIdentifier ("%s_type_id".printf (sym.get_lower_case_cname (null))));
+ set_qdata.add_argument (new CCodeIdentifier ("%s_type_id".printf (get_ccode_lower_case_name (sym, null))));
set_qdata.add_argument (quark);
set_qdata.add_argument (new CCodeCastExpression (proxy_type, "void*"));
@@ -1116,7 +1116,7 @@ public class Vala.GDBusClientModule : GDBusModule {
quark.add_argument (new CCodeConstant ("\"vala-dbus-interface-name\""));
set_qdata = new CCodeFunctionCall (new CCodeIdentifier ("g_type_set_qdata"));
- set_qdata.add_argument (new CCodeIdentifier ("%s_type_id".printf (sym.get_lower_case_cname (null))));
+ set_qdata.add_argument (new CCodeIdentifier ("%s_type_id".printf (get_ccode_lower_case_name (sym, null))));
set_qdata.add_argument (quark);
set_qdata.add_argument (new CCodeConstant ("\"%s\"".printf (dbus_iface_name)));
diff --git a/codegen/valagdbusmodule.vala b/codegen/valagdbusmodule.vala
index d82b573..3604fa9 100644
--- a/codegen/valagdbusmodule.vala
+++ b/codegen/valagdbusmodule.vala
@@ -22,32 +22,20 @@
public class Vala.GDBusModule : GVariantModule {
public static string? get_dbus_name (TypeSymbol symbol) {
- var dbus = symbol.get_attribute ("DBus");
- if (dbus == null) {
- return null;
- }
-
- return dbus.get_string ("name");
+ return symbol.get_attribute_string ("DBus", "name");
}
public static string get_dbus_name_for_member (Symbol symbol) {
- var dbus = symbol.get_attribute ("DBus");
- if (dbus != null && dbus.has_argument ("name")) {
- return dbus.get_string ("name");
+ var dbus_name = symbol.get_attribute_string ("DBus", "name");
+ if (dbus_name != null) {
+ return dbus_name;
}
return Symbol.lower_case_to_camel_case (symbol.name);
}
public static bool is_dbus_no_reply (Method m) {
- var dbus_attribute = m.get_attribute ("DBus");
- if (dbus_attribute != null
- && dbus_attribute.has_argument ("no_reply")
- && dbus_attribute.get_bool ("no_reply")) {
- return true;
- }
-
- return false;
+ return m.get_attribute_bool ("DBus", "no_reply");
}
public override void visit_error_domain (ErrorDomain edomain) {
@@ -74,31 +62,31 @@ 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);
}
var cdecl = new CCodeDeclaration ("const GDBusErrorEntry");
- cdecl.add_declarator (new CCodeVariableDeclarator (edomain.get_lower_case_cname () + "_entries[]", error_entries));
+ cdecl.add_declarator (new CCodeVariableDeclarator (get_ccode_lower_case_name (edomain) + "_entries[]", error_entries));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_constant_declaration (cdecl);
- string quark_fun_name = edomain.get_lower_case_cprefix () + "quark";
+ string quark_fun_name = get_ccode_lower_case_prefix (edomain) + "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 ());
+ string quark_name = "%squark_volatile".printf (get_ccode_lower_case_prefix (edomain));
ccode.add_declaration ("gsize", new CCodeVariableDeclarator (quark_name, new CCodeConstant ("0")), CCodeModifiers.STATIC | CCodeModifiers.VOLATILE);
var register_call = new CCodeFunctionCall (new CCodeIdentifier ("g_dbus_error_register_error_domain"));
- register_call.add_argument (new CCodeConstant ("\"" + edomain.get_lower_case_cname () + "-quark\""));
+ register_call.add_argument (new CCodeConstant ("\"" + get_ccode_lower_case_name (edomain) + "-quark\""));
register_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (quark_name)));
- register_call.add_argument (new CCodeIdentifier (edomain.get_lower_case_cname () + "_entries"));
+ register_call.add_argument (new CCodeIdentifier (get_ccode_lower_case_name (edomain) + "_entries"));
var nentries = new CCodeFunctionCall (new CCodeIdentifier ("G_N_ELEMENTS"));
- nentries.add_argument (new CCodeIdentifier (edomain.get_lower_case_cname () + "_entries"));
+ nentries.add_argument (new CCodeIdentifier (get_ccode_lower_case_name (edomain) + "_entries"));
register_call.add_argument (nentries);
ccode.add_expression (register_call);
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index 7c5a753..b29b913 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -33,20 +33,16 @@ public class Vala.GDBusServerModule : GDBusClientModule {
}
public static string dbus_result_name (Method m) {
- var dbus_attribute = m.get_attribute ("DBus");
- if (dbus_attribute != null
- && dbus_attribute.has_argument ("result")) {
- var result_name = dbus_attribute.get_string ("result");
- if (result_name != null && result_name != "") {
- return result_name;
- }
+ var dbus_name = m.get_attribute_string ("DBus", "result");
+ if (dbus_name != null && dbus_name != "") {
+ return dbus_name;
}
return "result";
}
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 +59,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 +101,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 = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_finish_name (m)));
+ ccall.add_argument (new CCodeCastExpression (new CCodeIdentifier ("source_object"), get_ccode_name (sym) + "*"));
ccall.add_argument (new CCodeIdentifier ("_res_"));
}
@@ -136,7 +132,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 +288,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 +304,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 +314,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 +414,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 (get_ccode_lower_case_name (sym), get_ccode_name (sig));
var function = new CCodeFunction (wrapper_name, "void");
function.modifiers = CCodeModifiers.STATIC;
@@ -484,24 +480,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 +533,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 ()) {
@@ -605,7 +601,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
var connect = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_connect"));
connect.add_argument (new CCodeIdentifier ("object"));
- connect.add_argument (sig.get_canonical_cconstant ());
+ connect.add_argument (get_signal_canonical_constant (sig));
connect.add_argument (new CCodeCastExpression (new CCodeIdentifier (generate_dbus_signal_wrapper (sig, sym, dbus_iface_name)), "GCallback"));
connect.add_argument (new CCodeIdentifier ("data"));
ccode.add_expression (connect);
@@ -613,7 +609,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
}
void generate_interface_method_call_function (ObjectTypeSymbol sym) {
- var cfunc = new CCodeFunction (sym.get_lower_case_cprefix () + "dbus_interface_method_call", "void");
+ var cfunc = new CCodeFunction (get_ccode_lower_case_prefix (sym) + "dbus_interface_method_call", "void");
cfunc.add_parameter (new CCodeParameter ("connection", "GDBusConnection*"));
cfunc.add_parameter (new CCodeParameter ("sender", "const gchar*"));
cfunc.add_parameter (new CCodeParameter ("object_path", "const gchar*"));
@@ -680,7 +676,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
}
void generate_interface_get_property_function (ObjectTypeSymbol sym) {
- var cfunc = new CCodeFunction (sym.get_lower_case_cprefix () + "dbus_interface_get_property", "GVariant*");
+ var cfunc = new CCodeFunction (get_ccode_lower_case_prefix (sym) + "dbus_interface_get_property", "GVariant*");
cfunc.add_parameter (new CCodeParameter ("connection", "GDBusConnection*"));
cfunc.add_parameter (new CCodeParameter ("sender", "const gchar*"));
cfunc.add_parameter (new CCodeParameter ("object_path", "const gchar*"));
@@ -743,7 +739,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
}
void generate_interface_set_property_function (ObjectTypeSymbol sym) {
- var cfunc = new CCodeFunction (sym.get_lower_case_cprefix () + "dbus_interface_set_property", "gboolean");
+ var cfunc = new CCodeFunction (get_ccode_lower_case_prefix (sym) + "dbus_interface_set_property", "gboolean");
cfunc.add_parameter (new CCodeParameter ("connection", "GDBusConnection*"));
cfunc.add_parameter (new CCodeParameter ("sender", "const gchar*"));
cfunc.add_parameter (new CCodeParameter ("object_path", "const gchar*"));
@@ -836,14 +832,14 @@ 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_" + m.name + "_" + param.name, info));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_" + param.name, info));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_constant_declaration (cdecl);
if (param.direction == ParameterDirection.IN) {
- in_args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_" + param.name)));
+ in_args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_" + param.name)));
} else {
- out_args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_" + param.name)));
+ out_args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_" + param.name)));
}
}
@@ -854,48 +850,48 @@ public class Vala.GDBusServerModule : GDBusClientModule {
info.append (new CCodeConstant ("\"%s\"".printf (get_type_signature (m.return_type, m))));
var cdecl = new CCodeDeclaration ("const GDBusArgInfo");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_result", info));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_result", info));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_constant_declaration (cdecl);
- out_args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_result")));
+ out_args_info.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_result")));
}
in_args_info.append (new CCodeConstant ("NULL"));
out_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_" + m.name + "_in[]", in_args_info));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_in[]", in_args_info));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_constant_declaration (cdecl);
cdecl = new CCodeDeclaration ("const GDBusArgInfo * const");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_out[]", out_args_info));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_out[]", out_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 (m))));
- info.append (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_in")), "GDBusArgInfo **"));
- info.append (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_arg_info_" + m.name + "_out")), "GDBusArgInfo **"));
+ info.append (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_in")), "GDBusArgInfo **"));
+ info.append (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_arg_info_" + m.name + "_out")), "GDBusArgInfo **"));
cdecl = new CCodeDeclaration ("const GDBusMethodInfo");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_method_info_" + m.name, info));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_method_info_" + m.name, 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_method_info_" + m.name)));
+ infos.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_method_info_" + m.name)));
}
infos.append (new CCodeConstant ("NULL"));
var cdecl = new CCodeDeclaration ("const GDBusMethodInfo * const");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_method_info[]", infos));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_method_info[]", infos));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_constant_declaration (cdecl);
- return new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_method_info");
+ return new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_method_info");
}
CCodeExpression get_signal_info (ObjectTypeSymbol sym) {
@@ -918,41 +914,41 @@ 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 ("_" + get_ccode_lower_case_prefix (sym) + "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 ("_" + get_ccode_lower_case_prefix (sym) + "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 ("_" + get_ccode_lower_case_prefix (sym) + "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 ("_" + get_ccode_lower_case_prefix (sym) + "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 ("_" + get_ccode_lower_case_prefix (sym) + "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 ("_" + get_ccode_lower_case_prefix (sym) + "dbus_signal_info_" + get_ccode_name (sig))));
}
infos.append (new CCodeConstant ("NULL"));
var cdecl = new CCodeDeclaration ("const GDBusSignalInfo * const");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_signal_info[]", infos));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_signal_info[]", infos));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_constant_declaration (cdecl);
- return new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_signal_info");
+ return new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_signal_info");
}
CCodeExpression get_property_info (ObjectTypeSymbol sym) {
@@ -982,21 +978,21 @@ public class Vala.GDBusServerModule : GDBusClientModule {
}
var cdecl = new CCodeDeclaration ("const GDBusPropertyInfo");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_property_info_" + prop.name, info));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_property_info_" + prop.name, 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_property_info_" + prop.name)));
+ infos.append (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_property_info_" + prop.name)));
}
infos.append (new CCodeConstant ("NULL"));
var cdecl = new CCodeDeclaration ("const GDBusPropertyInfo * const");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_property_info[]", infos));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_property_info[]", infos));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_constant_declaration (cdecl);
- return new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_property_info");
+ return new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_property_info");
}
CCodeExpression get_interface_info (ObjectTypeSymbol sym) {
@@ -1008,29 +1004,29 @@ public class Vala.GDBusServerModule : GDBusClientModule {
info.append (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_property_info (sym)), "GDBusPropertyInfo **"));
var cdecl = new CCodeDeclaration ("const GDBusInterfaceInfo");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_interface_info", info));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_interface_info", info));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_constant_declaration (cdecl);
- return new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_interface_info");
+ return new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_interface_info");
}
CCodeExpression get_interface_vtable (ObjectTypeSymbol sym) {
var vtable = new CCodeInitializerList ();
- vtable.append (new CCodeIdentifier (sym.get_lower_case_cprefix () + "dbus_interface_method_call"));
- vtable.append (new CCodeIdentifier (sym.get_lower_case_cprefix () + "dbus_interface_get_property"));
- vtable.append (new CCodeIdentifier (sym.get_lower_case_cprefix () + "dbus_interface_set_property"));
+ vtable.append (new CCodeIdentifier (get_ccode_lower_case_prefix (sym) + "dbus_interface_method_call"));
+ vtable.append (new CCodeIdentifier (get_ccode_lower_case_prefix (sym) + "dbus_interface_get_property"));
+ vtable.append (new CCodeIdentifier (get_ccode_lower_case_prefix (sym) + "dbus_interface_set_property"));
generate_interface_method_call_function (sym);
generate_interface_get_property_function (sym);
generate_interface_set_property_function (sym);
var cdecl = new CCodeDeclaration ("const GDBusInterfaceVTable");
- cdecl.add_declarator (new CCodeVariableDeclarator ("_" + sym.get_lower_case_cprefix () + "dbus_interface_vtable", vtable));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_" + get_ccode_lower_case_prefix (sym) + "dbus_interface_vtable", vtable));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_constant_declaration (cdecl);
- return new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "dbus_interface_vtable");
+ return new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "dbus_interface_vtable");
}
string generate_register_object_function () {
@@ -1098,7 +1094,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;
}
@@ -1115,7 +1111,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
return;
}
- cregister = new CCodeFunctionCall (new CCodeIdentifier ("%sregister_object".printf (object_type.type_symbol.get_lower_case_cprefix ())));
+ cregister = new CCodeFunctionCall (new CCodeIdentifier ("%sregister_object".printf (get_ccode_lower_case_prefix (object_type.type_symbol))));
} else {
// use runtime type information for generic methods
cregister = new CCodeFunctionCall (new CCodeIdentifier (generate_register_object_function ()));
@@ -1177,7 +1173,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
return;
}
- string register_object_name = "%sregister_object".printf (sym.get_lower_case_cprefix ());
+ string register_object_name = "%sregister_object".printf (get_ccode_lower_case_prefix (sym));
if (add_symbol_declaration (decl_space, sym, register_object_name)) {
return;
@@ -1207,7 +1203,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
cfile.add_include ("gio/gio.h");
- var cfunc = new CCodeFunction (sym.get_lower_case_cprefix () + "register_object", "guint");
+ var cfunc = new CCodeFunction (get_ccode_lower_case_prefix (sym) + "register_object", "guint");
cfunc.add_parameter (new CCodeParameter ("object", "gpointer"));
cfunc.add_parameter (new CCodeParameter ("connection", "GDBusConnection*"));
cfunc.add_parameter (new CCodeParameter ("path", "const gchar*"));
@@ -1229,7 +1225,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
alloc_data.add_argument (new CCodeConstant ("3"));
ccode.add_assignment (new CCodeIdentifier ("data"), alloc_data);
- var ref_function = sym.get_ref_function ();
+ var ref_function = get_ccode_ref_function (sym);
if (sym is Interface && ref_function == null) {
Report.error (sym.source_reference, "missing class prerequisite for interface `%s', add GLib.Object to interface declaration if unsure".printf (sym.get_full_name ()));
return;
@@ -1256,7 +1252,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
cregister.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_interface_vtable (sym)));
cregister.add_argument (new CCodeIdentifier ("data"));
- cregister.add_argument (new CCodeIdentifier ("_" + sym.get_lower_case_cprefix () + "unregister_object"));
+ cregister.add_argument (new CCodeIdentifier ("_" + get_ccode_lower_case_prefix (sym) + "unregister_object"));
cregister.add_argument (new CCodeIdentifier ("error"));
ccode.add_assignment (new CCodeIdentifier ("result"), cregister);
@@ -1273,7 +1269,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
cfile.add_function (cfunc);
- cfunc = new CCodeFunction ("_" + sym.get_lower_case_cprefix () + "unregister_object");
+ cfunc = new CCodeFunction ("_" + get_ccode_lower_case_prefix (sym) + "unregister_object");
cfunc.add_parameter (new CCodeParameter ("user_data", "gpointer"));
cfunc.modifiers |= CCodeModifiers.STATIC;
@@ -1281,7 +1277,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
ccode.add_declaration ("gpointer*", new CCodeVariableDeclarator ("data", new CCodeIdentifier ("user_data")));
- var unref_object = new CCodeFunctionCall (new CCodeIdentifier (sym.get_unref_function ()));
+ var unref_object = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_unref_function (sym)));
unref_object.add_argument (new CCodeElementAccess (new CCodeIdentifier ("data"), new CCodeConstant ("0")));
ccode.add_expression (unref_object);
@@ -1314,9 +1310,9 @@ public class Vala.GDBusServerModule : GDBusClientModule {
quark.add_argument (new CCodeConstant ("\"vala-dbus-register-object\""));
var set_qdata = new CCodeFunctionCall (new CCodeIdentifier ("g_type_set_qdata"));
- set_qdata.add_argument (new CCodeIdentifier ("%s_type_id".printf (sym.get_lower_case_cname (null))));
+ set_qdata.add_argument (new CCodeIdentifier ("%s_type_id".printf (get_ccode_lower_case_name (sym, null))));
set_qdata.add_argument (quark);
- set_qdata.add_argument (new CCodeCastExpression (new CCodeIdentifier (sym.get_lower_case_cprefix () + "register_object"), "void*"));
+ set_qdata.add_argument (new CCodeCastExpression (new CCodeIdentifier (get_ccode_lower_case_prefix (sym) + "register_object"), "void*"));
block.add_statement (new CCodeExpressionStatement (set_qdata));
}
diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala
index e8ba641..10a080a 100644
--- a/codegen/valagerrormodule.vala
+++ b/codegen/valagerrormodule.vala
@@ -29,29 +29,29 @@ 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)));
}
}
decl_space.add_type_definition (cenum);
- string quark_fun_name = edomain.get_lower_case_cprefix () + "quark";
+ string quark_fun_name = get_ccode_lower_case_prefix (edomain) + "quark";
- var error_domain_define = new CCodeMacroReplacement (edomain.get_upper_case_cname (), quark_fun_name + " ()");
+ var error_domain_define = new CCodeMacroReplacement (get_ccode_upper_case_name (edomain), 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);
}
@@ -70,13 +70,13 @@ public class Vala.GErrorModule : CCodeDelegateModule {
generate_error_domain_declaration (edomain, internal_header_file);
}
- string quark_fun_name = edomain.get_lower_case_cprefix () + "quark";
+ string quark_fun_name = get_ccode_lower_case_prefix (edomain) + "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"));
- cquark_call.add_argument (new CCodeConstant ("\"" + edomain.get_lower_case_cname () + "-quark\""));
+ cquark_call.add_argument (new CCodeConstant ("\"" + get_ccode_lower_case_name (edomain) + "-quark\""));
ccode.add_return (cquark_call);
@@ -217,15 +217,15 @@ public class Vala.GErrorModule : CCodeDelegateModule {
/* catch clause specifies a specific error code */
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_upper_case_name (catch_type.data_type)));
+ error_match.add_argument (new CCodeIdentifier (get_ccode_name (catch_type.error_code)));
ccode.open_if (error_match);
} else {
/* catch clause specifies a full error domain */
var ccond = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY,
new CCodeMemberAccess.pointer (inner_error, "domain"), new CCodeIdentifier
- (clause.error_type.data_type.get_upper_case_cname ()));
+ (get_ccode_upper_case_name (clause.error_type.data_type)));
ccode.open_if (ccond);
}
@@ -265,7 +265,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
// Check the allowed error domains to propagate
var domain_check = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeMemberAccess.pointer
- (inner_error, "domain"), new CCodeIdentifier (error_type.data_type.get_upper_case_cname ()));
+ (inner_error, "domain"), new CCodeIdentifier (get_ccode_upper_case_name (error_type.data_type)));
if (ccond == null) {
ccond = domain_check;
} else {
@@ -304,7 +304,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
is_in_catch = true;
foreach (CatchClause clause in stmt.get_catch_clauses ()) {
- clause.clabel_name = "__catch%d_%s".printf (this_try_id, clause.error_type.get_lower_case_cname ());
+ clause.clabel_name = "__catch%d_%s".printf (this_try_id, get_ccode_lower_case_name (clause.error_type));
}
is_in_catch = false;
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index 8fe42c0..74e4d2d 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -53,24 +53,24 @@ public class Vala.GObjectModule : GTypeModule {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
ccall.add_argument (new CCodeIdentifier ("klass"));
if (class_has_readable_properties (cl) || cl.get_type_parameters ().size > 0) {
- ccode.add_assignment (new CCodeMemberAccess.pointer (ccall, "get_property"), new CCodeIdentifier ("_vala_%s_get_property".printf (cl.get_lower_case_cname (null))));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ccall, "get_property"), new CCodeIdentifier ("_vala_%s_get_property".printf (get_ccode_lower_case_name (cl, null))));
}
if (class_has_writable_properties (cl) || cl.get_type_parameters ().size > 0) {
- ccode.add_assignment (new CCodeMemberAccess.pointer (ccall, "set_property"), new CCodeIdentifier ("_vala_%s_set_property".printf (cl.get_lower_case_cname (null))));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ccall, "set_property"), new CCodeIdentifier ("_vala_%s_set_property".printf (get_ccode_lower_case_name (cl, null))));
}
/* set constructor */
if (cl.constructor != null) {
var ccast = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
ccast.add_argument (new CCodeIdentifier ("klass"));
- ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "constructor"), new CCodeIdentifier ("%s_constructor".printf (cl.get_lower_case_cname (null))));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "constructor"), new CCodeIdentifier ("%s_constructor".printf (get_ccode_lower_case_name (cl, null))));
}
/* set finalize function */
if (cl.get_fields ().size > 0 || cl.destructor != null) {
var ccast = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
ccast.add_argument (new CCodeIdentifier ("klass"));
- ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "finalize"), new CCodeIdentifier ("%s_finalize".printf (cl.get_lower_case_cname (null))));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "finalize"), new CCodeIdentifier ("%s_finalize".printf (get_ccode_lower_case_name (cl, null))));
}
/* create type, dup_func, and destroy_func properties for generic types */
@@ -81,7 +81,7 @@ public class Vala.GObjectModule : GTypeModule {
func_name = "%s_type".printf (type_param.name.down ());
func_name_constant = new CCodeConstant ("\"%s-type\"".printf (type_param.name.down ()));
- enum_value = "%s_%s".printf (cl.get_lower_case_cname (null), func_name).up ();
+ enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_install_property"));
cinst.add_argument (ccall);
cinst.add_argument (new CCodeConstant (enum_value));
@@ -98,7 +98,7 @@ public class Vala.GObjectModule : GTypeModule {
func_name = "%s_dup_func".printf (type_param.name.down ());
func_name_constant = new CCodeConstant ("\"%s-dup-func\"".printf (type_param.name.down ()));
- enum_value = "%s_%s".printf (cl.get_lower_case_cname (null), func_name).up ();
+ enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_install_property"));
cinst.add_argument (ccall);
cinst.add_argument (new CCodeConstant (enum_value));
@@ -114,7 +114,7 @@ public class Vala.GObjectModule : GTypeModule {
func_name = "%s_destroy_func".printf (type_param.name.down ());
func_name_constant = new CCodeConstant ("\"%s-destroy-func\"".printf (type_param.name.down ()));
- enum_value = "%s_%s".printf (cl.get_lower_case_cname (null), func_name).up ();
+ enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_install_property"));
cinst.add_argument (ccall);
cinst.add_argument (new CCodeConstant (enum_value));
@@ -142,14 +142,14 @@ public class Vala.GObjectModule : GTypeModule {
if (prop.overrides || prop.base_interface_property != null) {
var cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_override_property"));
cinst.add_argument (ccall);
- cinst.add_argument (new CCodeConstant (prop.get_upper_case_cname ()));
- cinst.add_argument (prop.get_canonical_cconstant ());
+ cinst.add_argument (new CCodeConstant (get_ccode_upper_case_name (prop)));
+ cinst.add_argument (get_property_canonical_cconstant (prop));
ccode.add_expression (cinst);
} else {
var cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_install_property"));
cinst.add_argument (ccall);
- cinst.add_argument (new CCodeConstant (prop.get_upper_case_cname ()));
+ cinst.add_argument (new CCodeConstant (get_ccode_upper_case_name (prop)));
cinst.add_argument (get_param_spec (prop));
ccode.add_expression (cinst);
@@ -176,7 +176,7 @@ public class Vala.GObjectModule : GTypeModule {
}
private void add_get_property_function (Class cl) {
- var get_prop = new CCodeFunction ("_vala_%s_get_property".printf (cl.get_lower_case_cname (null)), "void");
+ var get_prop = new CCodeFunction ("_vala_%s_get_property".printf (get_ccode_lower_case_name (cl, null)), "void");
get_prop.modifiers = CCodeModifiers.STATIC;
get_prop.add_parameter (new CCodeParameter ("object", "GObject *"));
get_prop.add_parameter (new CCodeParameter ("property_id", "guint"));
@@ -186,7 +186,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 ();
@@ -215,14 +215,14 @@ public class Vala.GObjectModule : GTypeModule {
generate_property_accessor_declaration (prop.base_interface_property.get_accessor, cfile);
}
- ccode.add_case (new CCodeIdentifier (prop.get_upper_case_cname ()));
+ ccode.add_case (new CCodeIdentifier (get_ccode_upper_case_name (prop)));
if (prop.property_type.is_real_struct_type ()) {
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);
@@ -239,7 +239,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) {
@@ -276,7 +276,7 @@ public class Vala.GObjectModule : GTypeModule {
}
private void add_set_property_function (Class cl) {
- var set_prop = new CCodeFunction ("_vala_%s_set_property".printf (cl.get_lower_case_cname (null)), "void");
+ var set_prop = new CCodeFunction ("_vala_%s_set_property".printf (get_ccode_lower_case_name (cl, null)), "void");
set_prop.modifiers = CCodeModifiers.STATIC;
set_prop.add_parameter (new CCodeParameter ("object", "GObject *"));
set_prop.add_parameter (new CCodeParameter ("property_id", "guint"));
@@ -286,7 +286,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 ();
@@ -314,8 +314,8 @@ public class Vala.GObjectModule : GTypeModule {
generate_property_accessor_declaration (prop.base_interface_property.set_accessor, cfile);
}
- ccode.add_case (new CCodeIdentifier (prop.get_upper_case_cname ()));
- ccall = new CCodeFunctionCall (new CCodeIdentifier (base_prop.set_accessor.get_cname ()));
+ ccode.add_case (new CCodeIdentifier (get_ccode_upper_case_name (prop)));
+ 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 ();
@@ -334,7 +334,7 @@ public class Vala.GObjectModule : GTypeModule {
} else {
var cgetcall = new CCodeFunctionCall ();
if (prop.property_type.data_type != null) {
- cgetcall.call = new CCodeIdentifier (prop.property_type.data_type.get_get_value_function ());
+ cgetcall.call = new CCodeIdentifier (get_ccode_get_value_function (prop.property_type.data_type));
} else {
cgetcall.call = new CCodeIdentifier ("g_value_get_pointer");
}
@@ -352,7 +352,7 @@ public class Vala.GObjectModule : GTypeModule {
CCodeFunctionCall cgetcall;
func_name = "%s_type".printf (type_param.name.down ());
- enum_value = "%s_%s".printf (cl.get_lower_case_cname (null), func_name).up ();
+ enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
ccode.add_case (new CCodeIdentifier (enum_value));
cfield = new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), "priv"), func_name);
cgetcall = new CCodeFunctionCall (new CCodeIdentifier ("g_value_get_gtype"));
@@ -361,7 +361,7 @@ public class Vala.GObjectModule : GTypeModule {
ccode.add_break ();
func_name = "%s_dup_func".printf (type_param.name.down ());
- enum_value = "%s_%s".printf (cl.get_lower_case_cname (null), func_name).up ();
+ enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
ccode.add_case (new CCodeIdentifier (enum_value));
cfield = new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), "priv"), func_name);
cgetcall = new CCodeFunctionCall (new CCodeIdentifier ("g_value_get_pointer"));
@@ -370,7 +370,7 @@ public class Vala.GObjectModule : GTypeModule {
ccode.add_break ();
func_name = "%s_destroy_func".printf (type_param.name.down ());
- enum_value = "%s_%s".printf (cl.get_lower_case_cname (null), func_name).up ();
+ enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
ccode.add_case (new CCodeIdentifier (enum_value));
cfield = new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), "priv"), func_name);
cgetcall = new CCodeFunctionCall (new CCodeIdentifier ("g_value_get_pointer"));
@@ -419,7 +419,7 @@ public class Vala.GObjectModule : GTypeModule {
push_context (new EmitContext (c));
- var function = new CCodeFunction ("%s_constructor".printf (cl.get_lower_case_cname (null)), "GObject *");
+ var function = new CCodeFunction ("%s_constructor".printf (get_ccode_lower_case_name (cl, null)), "GObject *");
function.modifiers = CCodeModifiers.STATIC;
function.add_parameter (new CCodeParameter ("type", "GType"));
@@ -434,7 +434,7 @@ public class Vala.GObjectModule : GTypeModule {
ccode.add_declaration ("GObjectClass *", new CCodeVariableDeclarator ("parent_class"));
var ccast = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
- ccast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (cl.get_lower_case_cname (null))));
+ ccast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (cl, null))));
ccode.add_assignment (new CCodeIdentifier ("parent_class"), ccast);
var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (new CCodeIdentifier ("parent_class"), "constructor"));
@@ -446,7 +446,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);
@@ -526,18 +526,18 @@ 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"));
- call.add_argument (prop.get_canonical_cconstant ());
+ call.add_argument (get_property_canonical_cconstant (prop));
call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("result")));
call.add_argument (new CCodeConstant ("NULL"));
@@ -564,14 +564,14 @@ 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);
var call = new CCodeFunctionCall (new CCodeIdentifier ("g_object_set"));
call.add_argument (new CCodeIdentifier ("obj"));
- call.add_argument (prop.get_canonical_cconstant ());
+ call.add_argument (get_property_canonical_cconstant (prop));
call.add_argument (new CCodeIdentifier ("value"));
call.add_argument (new CCodeConstant ("NULL"));
@@ -670,7 +670,7 @@ public class Vala.GObjectModule : GTypeModule {
base.visit_property (prop);
if (is_gobject_property (prop) && prop.parent_symbol is Class) {
- prop_enum.add_value (new CCodeEnumValue (prop.get_upper_case_cname ()));
+ prop_enum.add_value (new CCodeEnumValue (get_ccode_upper_case_name (prop)));
}
}
@@ -689,7 +689,7 @@ public class Vala.GObjectModule : GTypeModule {
}
var st = prop.property_type.data_type as Struct;
- if (st != null && (!st.has_type_id || prop.property_type.nullable)) {
+ if (st != null && (!get_ccode_has_type_id (st) || prop.property_type.nullable)) {
return false;
}
diff --git a/codegen/valagsignalmodule.vala b/codegen/valagsignalmodule.vala
index e527890..dceb8d2 100644
--- a/codegen/valagsignalmodule.vala
+++ b/codegen/valagsignalmodule.vala
@@ -24,35 +24,6 @@
public class Vala.GSignalModule : GObjectModule {
- private string get_marshaller_type_name (DataType t) {
- if (t is PointerType || t.type_parameter != null) {
- return ("POINTER");
- } else if (t is ErrorType) {
- return ("POINTER");
- } else if (t is ArrayType) {
- if (((ArrayType) t).element_type.data_type == string_type.data_type) {
- return ("BOXED,INT");
- } else {
- return ("POINTER,INT");
- }
- } else if (t is VoidType) {
- return ("VOID");
- } else if (t.data_type is Enum) {
- var en = (Enum) t.data_type;
- return en.get_marshaller_type_name ();
- } else {
- return t.data_type.get_marshaller_type_name ();
- }
- }
-
- private string get_marshaller_type_name_for_parameter (Parameter param) {
- if (param.direction != ParameterDirection.IN) {
- return ("POINTER");
- } else {
- return get_marshaller_type_name (param.variable_type);
- }
- }
-
string get_marshaller_function (List<Parameter> params, DataType return_type, string? prefix = null) {
var signature = get_marshaller_signature (params, return_type);
string ret;
@@ -65,13 +36,13 @@ public class Vala.GSignalModule : GObjectModule {
}
}
- ret = "%s_%s_".printf (prefix, get_marshaller_type_name (return_type));
+ ret = "%s_%s_".printf (prefix, get_ccode_marshaller_type_name (return_type));
if (params == null || params.size == 0) {
ret = ret + "_VOID";
} else {
foreach (Parameter p in params) {
- ret = "%s_%s".printf (ret, get_marshaller_type_name_for_parameter (p).replace (",", "_"));
+ ret = "%s_%s".printf (ret, get_ccode_marshaller_type_name (p).replace (",", "_"));
}
}
@@ -90,7 +61,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";
}
@@ -116,17 +87,17 @@ public class Vala.GSignalModule : GObjectModule {
private string get_marshaller_signature (List<Parameter> params, DataType return_type) {
string signature;
- signature = "%s:".printf (get_marshaller_type_name (return_type));
+ signature = "%s:".printf (get_ccode_marshaller_type_name (return_type));
if (params == null || params.size == 0) {
signature = signature + "VOID";
} else {
bool first = true;
foreach (Parameter p in params) {
if (first) {
- signature = signature + get_marshaller_type_name_for_parameter (p);
+ signature = signature + get_ccode_marshaller_type_name (p);
first = false;
} else {
- signature = "%s,%s".printf (signature, get_marshaller_type_name_for_parameter (p));
+ signature = "%s,%s".printf (signature, get_ccode_marshaller_type_name (p));
}
}
}
@@ -136,7 +107,7 @@ public class Vala.GSignalModule : GObjectModule {
private CCodeExpression? get_signal_name_cexpression (Signal sig, Expression? detail_expr, CodeNode node) {
if (detail_expr == null) {
- return sig.get_canonical_cconstant ();
+ return get_signal_canonical_constant (sig);
}
if (detail_expr.value_type is NullType || !detail_expr.value_type.compatible (string_type)) {
@@ -146,14 +117,14 @@ public class Vala.GSignalModule : GObjectModule {
}
if (detail_expr is StringLiteral) {
- return sig.get_canonical_cconstant (((StringLiteral) detail_expr).eval ());
+ return get_signal_canonical_constant (sig, ((StringLiteral) detail_expr).eval ());
}
var detail_value = create_temp_value (detail_expr.value_type, false, node, true);
temp_ref_values.insert (0, detail_value);
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_strconcat"));
- ccall.add_argument (sig.get_canonical_cconstant (""));
+ ccall.add_argument (get_signal_canonical_constant (sig, ""));
ccall.add_argument (get_cvalue (detail_expr));
ccall.add_argument (new CCodeConstant ("NULL"));
@@ -282,7 +253,7 @@ public class Vala.GSignalModule : GObjectModule {
} else if (p.variable_type is ErrorType) {
get_value_function = "g_value_get_pointer";
} else {
- get_value_function = p.variable_type.data_type.get_get_value_function ();
+ get_value_function = get_ccode_get_value_function (p.variable_type.data_type);
}
var inner_fc = new CCodeFunctionCall (new CCodeIdentifier (get_value_function));
inner_fc.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier ("param_values"), new CCodeIdentifier (i.to_string ())));
@@ -316,7 +287,7 @@ public class Vala.GSignalModule : GObjectModule {
} else if (return_type.data_type is Class || return_type.data_type is Interface) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_take_object"));
} else {
- set_fc = new CCodeFunctionCall (new CCodeIdentifier (return_type.data_type.get_set_value_function ()));
+ set_fc = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_set_value_function (return_type.data_type)));
}
set_fc.add_argument (new CCodeIdentifier ("return_value"));
set_fc.add_argument (new CCodeIdentifier ("v_return"));
@@ -335,29 +306,30 @@ 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 CCodeIdentifier (type.get_type_id ()));
+ csignew.add_argument (new CCodeConstant ("\"%s\"".printf (get_ccode_name (sig))));
+ csignew.add_argument (new CCodeIdentifier (get_ccode_type_id (type)));
string[] flags = new string[0];
- if (sig.run_type == "first") {
+ var run_type = sig.get_attribute_string ("Signal", "run");
+ if (run_type == "first") {
flags += "G_SIGNAL_RUN_FIRST";
- } else if (sig.run_type == "cleanup") {
+ } else if (run_type == "cleanup") {
flags += "G_SIGNAL_RUN_CLEANUP";
} else {
flags += "G_SIGNAL_RUN_LAST";
}
- if (sig.is_detailed) {
+ if (sig.get_attribute_bool ("Signal", "detailed")) {
flags += "G_SIGNAL_DETAILED";
}
- if (sig.no_recurse) {
+ if (sig.get_attribute_bool ("Signal", "no_recurse")) {
flags += "G_SIGNAL_NO_RECURSE";
}
- if (sig.is_action) {
+ if (sig.get_attribute_bool ("Signal", "action")) {
flags += "G_SIGNAL_ACTION";
}
- if (sig.no_hooks) {
+ if (sig.get_attribute_bool ("Signal", "no_hooks")) {
flags += "G_SIGNAL_NO_HOOKS";
}
@@ -368,12 +340,12 @@ 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 ()));
+ struct_offset.add_argument (new CCodeIdentifier (get_ccode_type_name ((Interface) type)));
}
- struct_offset.add_argument (new CCodeIdentifier (sig.default_handler.vfunc_name));
+ struct_offset.add_argument (new CCodeIdentifier (get_ccode_vfunc_name (sig.default_handler)));
csignew.add_argument (struct_offset);
}
csignew.add_argument (new CCodeConstant ("NULL"));
@@ -392,7 +364,7 @@ public class Vala.GSignalModule : GObjectModule {
} else if (sig.return_type.data_type == null) {
csignew.add_argument (new CCodeConstant ("G_TYPE_NONE"));
} else {
- csignew.add_argument (new CCodeConstant (sig.return_type.data_type.get_type_id ()));
+ csignew.add_argument (new CCodeConstant (get_ccode_type_id (sig.return_type.data_type)));
}
int params_len = 0;
@@ -417,7 +389,7 @@ public class Vala.GSignalModule : GObjectModule {
} else if (param.variable_type is ErrorType) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
} else {
- csignew.add_argument (new CCodeConstant (param.variable_type.data_type.get_type_id ()));
+ csignew.add_argument (new CCodeConstant (get_ccode_type_id (param.variable_type.data_type)));
}
}
@@ -504,15 +476,15 @@ public class Vala.GSignalModule : GObjectModule {
if (expr.inner is BaseAccess && sig.is_virtual) {
var m = sig.default_handler;
var base_class = (Class) m.parent_symbol;
- var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (base_class.get_upper_case_cname (null))));
- vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
+ var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (get_ccode_upper_case_name (base_class, null))));
+ vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (current_class))));
set_cvalue (expr, new CCodeMemberAccess.pointer (vcast, m.name));
return;
}
- if (sig.has_emitter) {
- var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_%s".printf (cl.get_lower_case_cname (null), sig.name)));
+ if (get_signal_has_emitter (sig)) {
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_%s".printf (get_ccode_lower_case_name (cl), sig.name)));
ccall.add_argument (pub_inst);
set_cvalue (expr, ccall);
@@ -520,7 +492,7 @@ public class Vala.GSignalModule : GObjectModule {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_emit_by_name"));
ccall.add_argument (pub_inst);
- ccall.add_argument (sig.get_canonical_cconstant ());
+ ccall.add_argument (get_signal_canonical_constant (sig));
set_cvalue (expr, ccall);
}
@@ -633,7 +605,7 @@ public class Vala.GSignalModule : GObjectModule {
var parse_call = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_parse_name"));
parse_call.add_argument (signal_name_cexpr);
var decl_type = (TypeSymbol) sig.parent_symbol;
- parse_call.add_argument (new CCodeIdentifier (decl_type.get_type_id ()));
+ parse_call.add_argument (new CCodeIdentifier (get_ccode_type_id (decl_type)));
parse_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_variable_cexpression (temp_decl.name)));
LocalVariable? detail_temp_decl = null;
if (!(signal_access is ElementAccess)) {
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 0c82c0d..7c0219a 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 += "*";
@@ -39,16 +39,16 @@ public class Vala.GTypeModule : GErrorModule {
var cparam = new CCodeParameter (get_variable_cname (param.name), ctypename);
- cparam_map.set (get_param_pos (param.cparameter_position), cparam);
+ cparam_map.set (get_param_pos (get_ccode_pos (param)), cparam);
if (carg_map != null) {
- carg_map.set (get_param_pos (param.cparameter_position), get_variable_cexpression (param.name));
+ carg_map.set (get_param_pos (get_ccode_pos (param)), get_variable_cexpression (param.name));
}
return cparam;
}
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;
}
@@ -63,35 +63,35 @@ public class Vala.GTypeModule : GErrorModule {
if (is_gtypeinstance) {
decl_space.add_type_declaration (new CCodeNewline ());
- var macro = "(%s_get_type ())".printf (cl.get_lower_case_cname (null));
- decl_space.add_type_declaration (new CCodeMacroReplacement (cl.get_type_id (), macro));
+ var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (cl, null));
+ decl_space.add_type_declaration (new CCodeMacroReplacement (get_ccode_type_id (cl), macro));
- macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (cl.get_type_id (), cl.get_cname ());
- decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(obj)".printf (cl.get_upper_case_cname (null)), macro));
+ macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (get_ccode_type_id (cl), get_ccode_name (cl));
+ decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(obj)".printf (get_ccode_upper_case_name (cl, null)), macro));
- macro = "(G_TYPE_CHECK_CLASS_CAST ((klass), %s, %sClass))".printf (cl.get_type_id (), cl.get_cname ());
- decl_space.add_type_declaration (new CCodeMacroReplacement ("%s_CLASS(klass)".printf (cl.get_upper_case_cname (null)), macro));
+ macro = "(G_TYPE_CHECK_CLASS_CAST ((klass), %s, %sClass))".printf (get_ccode_type_id (cl), get_ccode_name (cl));
+ decl_space.add_type_declaration (new CCodeMacroReplacement ("%s_CLASS(klass)".printf (get_ccode_upper_case_name (cl, null)), macro));
- macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (cl.get_type_id ());
- decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(obj)".printf (get_type_check_function (cl)), macro));
+ macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (get_ccode_type_id (cl));
+ decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(obj)".printf (get_ccode_type_check_function (cl)), macro));
- 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_CHECK_CLASS_TYPE ((klass), %s))".printf (get_ccode_type_id (cl));
+ decl_space.add_type_declaration (new CCodeMacroReplacement ("%s_CLASS(klass)".printf (get_ccode_type_check_function (cl)), macro));
- macro = "(G_TYPE_INSTANCE_GET_CLASS ((obj), %s, %sClass))".printf (cl.get_type_id (), cl.get_cname ());
- decl_space.add_type_declaration (new CCodeMacroReplacement ("%s_GET_CLASS(obj)".printf (cl.get_upper_case_cname (null)), macro));
+ macro = "(G_TYPE_INSTANCE_GET_CLASS ((obj), %s, %sClass))".printf (get_ccode_type_id (cl), get_ccode_name (cl));
+ decl_space.add_type_declaration (new CCodeMacroReplacement ("%s_GET_CLASS(obj)".printf (get_ccode_upper_case_name (cl, 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) {
- var ref_fun = new CCodeFunction (cl.get_lower_case_cprefix () + "ref", "gpointer");
- var unref_fun = new CCodeFunction (cl.get_lower_case_cprefix () + "unref", "void");
+ var ref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "ref", "gpointer");
+ var unref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "unref", "void");
if (cl.access == SymbolAccessibility.PRIVATE) {
ref_fun.modifiers = CCodeModifiers.STATIC;
unref_fun.modifiers = CCodeModifiers.STATIC;
@@ -104,7 +104,7 @@ public class Vala.GTypeModule : GErrorModule {
decl_space.add_function_declaration (unref_fun);
// GParamSpec and GValue functions
- string function_name = cl.get_lower_case_cname ("param_spec_");
+ string function_name = get_ccode_lower_case_name (cl, "param_spec_");
var function = new CCodeFunction (function_name, "GParamSpec*");
function.add_parameter (new CCodeParameter ("name", "const gchar*"));
@@ -121,7 +121,7 @@ public class Vala.GTypeModule : GErrorModule {
decl_space.add_function_declaration (function);
- function = new CCodeFunction (cl.get_set_value_function (), "void");
+ function = new CCodeFunction (get_ccode_set_value_function (cl), "void");
function.add_parameter (new CCodeParameter ("value", "GValue*"));
function.add_parameter (new CCodeParameter ("v_object", "gpointer"));
@@ -133,7 +133,7 @@ public class Vala.GTypeModule : GErrorModule {
decl_space.add_function_declaration (function);
- function = new CCodeFunction (cl.get_take_value_function (), "void");
+ function = new CCodeFunction (get_ccode_take_value_function (cl), "void");
function.add_parameter (new CCodeParameter ("value", "GValue*"));
function.add_parameter (new CCodeParameter ("v_object", "gpointer"));
@@ -145,7 +145,7 @@ public class Vala.GTypeModule : GErrorModule {
decl_space.add_function_declaration (function);
- function = new CCodeFunction (cl.get_get_value_function (), "gpointer");
+ function = new CCodeFunction (get_ccode_get_value_function (cl), "gpointer");
function.add_parameter (new CCodeParameter ("value", "const GValue*"));
if (cl.access == SymbolAccessibility.PRIVATE) {
@@ -157,19 +157,19 @@ public class Vala.GTypeModule : GErrorModule {
decl_space.add_function_declaration (function);
} else if (!is_gtypeinstance) {
if (cl.base_class == null) {
- var function = new CCodeFunction (cl.get_lower_case_cprefix () + "free", "void");
+ var function = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "free", "void");
if (cl.access == SymbolAccessibility.PRIVATE) {
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,8 +312,8 @@ 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 ());
- if (f.variable_type is ArrayType && !f.no_array_length) {
+ instance_struct.add_field (field_ctype, get_ccode_name (f), f.variable_type.get_cdeclarator_suffix ());
+ if (f.variable_type is ArrayType && get_ccode_array_length (f)) {
// create fields to store array dimensions
var array_type = (ArrayType) f.variable_type;
@@ -322,16 +322,16 @@ public class Vala.GTypeModule : GErrorModule {
for (int dim = 1; dim <= array_type.rank; dim++) {
string length_cname;
- if (f.has_array_length_cname) {
- length_cname = f.get_array_length_cname ();
+ if (get_ccode_array_length_name (f) != null) {
+ length_cname = get_ccode_array_length_name (f);
} 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));
}
}
}
@@ -372,26 +372,26 @@ public class Vala.GTypeModule : GErrorModule {
}
// add vfunc field to the type struct
- var vdeclarator = new CCodeFunctionDeclarator (m.vfunc_name);
+ var vdeclarator = new CCodeFunctionDeclarator (get_ccode_vfunc_name (m));
var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
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,8 +419,8 @@ 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 ());
- if (f.variable_type is ArrayType && !f.no_array_length) {
+ instance_priv_struct.add_field (field_ctype, get_ccode_name (f), f.variable_type.get_cdeclarator_suffix ());
+ if (f.variable_type is ArrayType && get_ccode_array_length (f)) {
// create fields to store array dimensions
var array_type = (ArrayType) f.variable_type;
var len_type = int_type.copy ();
@@ -428,16 +428,16 @@ public class Vala.GTypeModule : GErrorModule {
if (!array_type.fixed_length) {
for (int dim = 1; dim <= array_type.rank; dim++) {
string length_cname;
- if (f.has_array_length_cname) {
- length_cname = f.get_array_length_cname ();
+ if (get_ccode_array_length_name (f) != null) {
+ length_cname = get_ccode_array_length_name (f);
} 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,23 +475,23 @@ 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")));
+ cdecl.add_declarator (new CCodeVariableDeclarator ("_vala_%s_class_private_quark".printf (get_ccode_lower_case_name (cl)), new CCodeConstant ("0")));
cdecl.modifiers = CCodeModifiers.STATIC;
decl_space.add_type_declaration (cdecl);
}
@@ -500,8 +500,8 @@ 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 ());
- decl_space.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_PRIVATE(o)".printf (cl.get_upper_case_cname (null)), macro));
+ var macro = "(G_TYPE_INSTANCE_GET_PRIVATE ((o), %s, %sPrivate))".printf (get_ccode_type_id (cl), get_ccode_name (cl));
+ decl_space.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_PRIVATE(o)".printf (get_ccode_upper_case_name (cl, null)), macro));
}
if (cl.has_class_private_fields || has_class_locks) {
@@ -509,11 +509,11 @@ 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 (get_ccode_type_id (cl), 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), get_ccode_lower_case_name (cl));
}
- decl_space.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_CLASS_PRIVATE(klass)".printf (cl.get_upper_case_cname (null)), macro));
+ decl_space.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_CLASS_PRIVATE(klass)".printf (get_ccode_upper_case_name (cl, null)), macro));
}
decl_space.add_type_member_declaration (prop_enum);
} else {
@@ -539,14 +539,14 @@ 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;
}
prop_enum = new CCodeEnum ();
- prop_enum.add_value (new CCodeEnumValue ("%s_DUMMY_PROPERTY".printf (cl.get_upper_case_cname (null))));
+ prop_enum.add_value (new CCodeEnumValue ("%s_DUMMY_PROPERTY".printf (get_ccode_upper_case_name (cl, null))));
class_init_context = new EmitContext (cl);
base_init_context = new EmitContext (cl);
class_finalize_context = new EmitContext (cl);
@@ -584,11 +584,11 @@ public class Vala.GTypeModule : GErrorModule {
if (is_gtypeinstance) {
if (is_fundamental) {
- param_spec_struct = new CCodeStruct ( "_%sParamSpec%s".printf(cl.parent_symbol.get_cprefix (), cl.name));
+ param_spec_struct = new CCodeStruct ( "_%sParamSpec%s".printf(get_ccode_prefix (cl.parent_symbol), cl.name));
param_spec_struct.add_field ("GParamSpec", "parent_instance");
cfile.add_type_definition (param_spec_struct);
- cfile.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (param_spec_struct.name), new CCodeVariableDeclarator ( "%sParamSpec%s".printf(cl.parent_symbol.get_cprefix (), cl.name))));
+ cfile.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (param_spec_struct.name), new CCodeVariableDeclarator ( "%sParamSpec%s".printf(get_ccode_prefix (cl.parent_symbol), cl.name))));
gvaluecollector_h_needed = true;
@@ -649,14 +649,14 @@ public class Vala.GTypeModule : GErrorModule {
var ref_count = new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), "ref_count");
// ref function
- var ref_fun = new CCodeFunction (cl.get_lower_case_cprefix () + "ref", "gpointer");
+ var ref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "ref", "gpointer");
ref_fun.add_parameter (new CCodeParameter ("instance", "gpointer"));
if (cl.access == SymbolAccessibility.PRIVATE) {
ref_fun.modifiers = CCodeModifiers.STATIC;
}
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);
@@ -666,23 +666,23 @@ public class Vala.GTypeModule : GErrorModule {
cfile.add_function (ref_fun);
// unref function
- var unref_fun = new CCodeFunction (cl.get_lower_case_cprefix () + "unref", "void");
+ var unref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "unref", "void");
unref_fun.add_parameter (new CCodeParameter ("instance", "gpointer"));
if (cl.access == SymbolAccessibility.PRIVATE) {
unref_fun.modifiers = CCodeModifiers.STATIC;
}
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);
- var get_class = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (cl.get_upper_case_cname (null))));
+ var get_class = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (get_ccode_upper_case_name (cl, null))));
get_class.add_argument (new CCodeIdentifier ("self"));
// finalize class
- var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (cl.get_upper_case_cname (null))));
+ var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (get_ccode_upper_case_name (cl, null))));
ccast.add_argument (new CCodeIdentifier ("self"));
ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (ccast, "finalize"));
ccall.add_argument (new CCodeIdentifier ("self"));
@@ -719,7 +719,7 @@ public class Vala.GTypeModule : GErrorModule {
}
private void add_type_value_table_init_function (Class cl) {
- var function = new CCodeFunction ("%s_init".printf (cl.get_lower_case_cname ("value_")), "void");
+ var function = new CCodeFunction ("%s_init".printf (get_ccode_lower_case_name (cl, "value_")), "void");
function.add_parameter (new CCodeParameter ("value", "GValue*"));
function.modifiers = CCodeModifiers.STATIC;
@@ -730,14 +730,14 @@ public class Vala.GTypeModule : GErrorModule {
}
private void add_type_value_table_free_function (Class cl) {
- var function = new CCodeFunction ("%s_free_value".printf (cl.get_lower_case_cname ("value_")), "void");
+ var function = new CCodeFunction ("%s_free_value".printf (get_ccode_lower_case_name (cl, "value_")), "void");
function.add_parameter (new CCodeParameter ("value", "GValue*"));
function.modifiers = CCodeModifiers.STATIC;
push_function (function);
var vpointer = new CCodeMemberAccess(new CCodeMemberAccess.pointer (new CCodeIdentifier ("value"), "data[0]"),"v_pointer");
- var ccall = new CCodeFunctionCall (new CCodeIdentifier (cl.get_lower_case_cprefix () + "unref"));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_lower_case_prefix (cl) + "unref"));
ccall.add_argument (vpointer);
ccode.open_if (vpointer);
@@ -749,7 +749,7 @@ public class Vala.GTypeModule : GErrorModule {
}
private void add_type_value_table_copy_function (Class cl) {
- var function = new CCodeFunction ("%s_copy_value".printf (cl.get_lower_case_cname ("value_")), "void");
+ var function = new CCodeFunction ("%s_copy_value".printf (get_ccode_lower_case_name (cl, "value_")), "void");
function.add_parameter (new CCodeParameter ("src_value", "const GValue*"));
function.add_parameter (new CCodeParameter ("dest_value", "GValue*"));
function.modifiers = CCodeModifiers.STATIC;
@@ -759,7 +759,7 @@ public class Vala.GTypeModule : GErrorModule {
var dest_vpointer = new CCodeMemberAccess (new CCodeMemberAccess.pointer (new CCodeIdentifier ("dest_value"), "data[0]"), "v_pointer");
var src_vpointer = new CCodeMemberAccess (new CCodeMemberAccess.pointer (new CCodeIdentifier ("src_value"), "data[0]"), "v_pointer");
- var ref_ccall = new CCodeFunctionCall (new CCodeIdentifier (cl.get_lower_case_cprefix () + "ref"));
+ var ref_ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_lower_case_prefix (cl) + "ref"));
ref_ccall.add_argument ( src_vpointer );
ccode.open_if (src_vpointer);
@@ -773,7 +773,7 @@ public class Vala.GTypeModule : GErrorModule {
}
private void add_type_value_table_peek_pointer_function (Class cl) {
- var function = new CCodeFunction ("%s_peek_pointer".printf (cl.get_lower_case_cname ("value_")), "gpointer");
+ var function = new CCodeFunction ("%s_peek_pointer".printf (get_ccode_lower_case_name (cl, "value_")), "gpointer");
function.add_parameter (new CCodeParameter ("value", "const GValue*"));
function.modifiers = CCodeModifiers.STATIC;
@@ -787,7 +787,7 @@ public class Vala.GTypeModule : GErrorModule {
}
private void add_type_value_table_lcopy_value_function ( Class cl ) {
- var function = new CCodeFunction ("%s_lcopy_value".printf (cl.get_lower_case_cname ("value_")), "gchar*");
+ var function = new CCodeFunction ("%s_lcopy_value".printf (get_ccode_lower_case_name (cl, "value_")), "gchar*");
function.add_parameter (new CCodeParameter ("value", "const GValue*"));
function.add_parameter (new CCodeParameter ("n_collect_values", "guint"));
function.add_parameter (new CCodeParameter ("collect_values", "GTypeCValue*"));
@@ -800,7 +800,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"));
@@ -815,7 +815,7 @@ public class Vala.GTypeModule : GErrorModule {
var main_condition = new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, vpointer);
var main_else_if_condition = new CCodeBinaryExpression (CCodeBinaryOperator.BITWISE_AND, new CCodeIdentifier ("collect_flags"), new CCodeIdentifier ("G_VALUE_NOCOPY_CONTENTS"));
- var ref_fct = new CCodeFunctionCall (new CCodeIdentifier (cl.get_ref_function()));
+ var ref_fct = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_ref_function (cl)));
ref_fct.add_argument (vpointer);
ccode.open_if (main_condition);
ccode.add_assignment (object_p_ptr, null_);
@@ -831,7 +831,7 @@ public class Vala.GTypeModule : GErrorModule {
}
private void add_type_value_table_collect_value_function (Class cl) {
- var function = new CCodeFunction ("%s_collect_value".printf (cl.get_lower_case_cname ("value_")), "gchar*");
+ var function = new CCodeFunction ("%s_collect_value".printf (get_ccode_lower_case_name (cl, "value_")), "gchar*");
function.add_parameter (new CCodeParameter ("value", "GValue*"));
function.add_parameter (new CCodeParameter ("n_collect_values", "guint"));
function.add_parameter (new CCodeParameter ("collect_values", "GTypeCValue*"));
@@ -845,7 +845,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"));
@@ -882,7 +882,7 @@ public class Vala.GTypeModule : GErrorModule {
ccode.close ();
- var ref_call = new CCodeFunctionCall (new CCodeIdentifier (cl.get_ref_function ()));
+ var ref_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_ref_function (cl)));
ref_call.add_argument (new CCodeIdentifier ("object"));
ccode.add_assignment (vpointer, ref_call);
@@ -898,7 +898,7 @@ public class Vala.GTypeModule : GErrorModule {
}
private void add_g_param_spec_type_function (Class cl) {
- string function_name = cl.get_lower_case_cname ("param_spec_");
+ string function_name = get_ccode_lower_case_name (cl, "param_spec_");
var function = new CCodeFunction (function_name, "GParamSpec*");
function.add_parameter (new CCodeParameter ("name", "const gchar*"));
@@ -913,11 +913,11 @@ public class Vala.GTypeModule : GErrorModule {
push_function (function);
- ccode.add_declaration ("%sParamSpec%s*".printf (cl.parent_symbol.get_cprefix (), cl.name), new CCodeVariableDeclarator ("spec"));
+ ccode.add_declaration ("%sParamSpec%s*".printf (get_ccode_prefix (cl.parent_symbol), cl.name), new CCodeVariableDeclarator ("spec"));
var subccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_is_a"));
subccall.add_argument (new CCodeIdentifier ("object_type"));
- subccall.add_argument (new CCodeIdentifier ( cl.get_type_id() ));
+ subccall.add_argument (new CCodeIdentifier ( get_ccode_type_id (cl) ));
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_return_val_if_fail"));
ccall.add_argument (subccall);
@@ -944,7 +944,7 @@ public class Vala.GTypeModule : GErrorModule {
}
private void add_g_value_set_function (Class cl) {
- var function = new CCodeFunction (cl.get_set_value_function (), "void");
+ var function = new CCodeFunction (get_ccode_set_value_function (cl), "void");
function.add_parameter (new CCodeParameter ("value", "GValue*"));
function.add_parameter (new CCodeParameter ("v_object", "gpointer"));
@@ -956,11 +956,11 @@ 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" ));
- ccall_typecheck.add_argument (new CCodeIdentifier ( cl.get_type_id() ));
+ ccall_typecheck.add_argument (new CCodeIdentifier ( get_ccode_type_id (cl) ));
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_return_if_fail"));
ccall.add_argument (ccall_typecheck);
@@ -971,7 +971,7 @@ public class Vala.GTypeModule : GErrorModule {
ccode.open_if (new CCodeIdentifier ("v_object"));
ccall_typecheck = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_CHECK_INSTANCE_TYPE"));
ccall_typecheck.add_argument (new CCodeIdentifier ( "v_object" ));
- ccall_typecheck.add_argument (new CCodeIdentifier ( cl.get_type_id() ));
+ ccall_typecheck.add_argument (new CCodeIdentifier ( get_ccode_type_id (cl) ));
ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_return_if_fail"));
ccall.add_argument (ccall_typecheck);
@@ -993,7 +993,7 @@ public class Vala.GTypeModule : GErrorModule {
ccode.add_assignment (vpointer, new CCodeConstant ("v_object"));
- ccall = new CCodeFunctionCall (new CCodeIdentifier (cl.get_ref_function ()));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_ref_function (cl)));
ccall.add_argument (vpointer);
ccode.add_expression (ccall);
@@ -1002,7 +1002,7 @@ public class Vala.GTypeModule : GErrorModule {
ccode.close ();
ccode.open_if (new CCodeIdentifier ("old"));
- ccall = new CCodeFunctionCall (new CCodeIdentifier (cl.get_unref_function ()));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_unref_function (cl)));
ccall.add_argument (new CCodeIdentifier ("old"));
ccode.add_expression (ccall);
ccode.close ();
@@ -1012,7 +1012,7 @@ public class Vala.GTypeModule : GErrorModule {
}
private void add_g_value_take_function (Class cl) {
- var function = new CCodeFunction (cl.get_take_value_function (), "void");
+ var function = new CCodeFunction (get_ccode_take_value_function (cl), "void");
function.add_parameter (new CCodeParameter ("value", "GValue*"));
function.add_parameter (new CCodeParameter ("v_object", "gpointer"));
@@ -1024,11 +1024,11 @@ 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" ));
- ccall_typecheck.add_argument (new CCodeIdentifier ( cl.get_type_id() ));
+ ccall_typecheck.add_argument (new CCodeIdentifier ( get_ccode_type_id (cl) ));
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_return_if_fail"));
ccall.add_argument (ccall_typecheck);
@@ -1040,7 +1040,7 @@ public class Vala.GTypeModule : GErrorModule {
ccall_typecheck = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_CHECK_INSTANCE_TYPE"));
ccall_typecheck.add_argument (new CCodeIdentifier ( "v_object" ));
- ccall_typecheck.add_argument (new CCodeIdentifier ( cl.get_type_id() ));
+ ccall_typecheck.add_argument (new CCodeIdentifier ( get_ccode_type_id (cl) ));
ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_return_if_fail"));
ccall.add_argument (ccall_typecheck);
@@ -1067,7 +1067,7 @@ public class Vala.GTypeModule : GErrorModule {
ccode.close ();
ccode.open_if (new CCodeIdentifier ("old"));
- ccall = new CCodeFunctionCall (new CCodeIdentifier (cl.get_unref_function ()));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_unref_function (cl)));
ccall.add_argument (new CCodeIdentifier ("old"));
ccode.add_expression (ccall);
ccode.close ();
@@ -1077,7 +1077,7 @@ public class Vala.GTypeModule : GErrorModule {
}
private void add_g_value_get_function (Class cl) {
- var function = new CCodeFunction (cl.get_get_value_function (), "gpointer");
+ var function = new CCodeFunction (get_ccode_get_value_function (cl), "gpointer");
function.add_parameter (new CCodeParameter ("value", "const GValue*"));
if (cl.access == SymbolAccessibility.PRIVATE) {
@@ -1090,7 +1090,7 @@ public class Vala.GTypeModule : GErrorModule {
var ccall_typecheck = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_CHECK_VALUE_TYPE"));
ccall_typecheck.add_argument (new CCodeIdentifier ("value"));
- ccall_typecheck.add_argument (new CCodeIdentifier (cl.get_type_id ()));
+ ccall_typecheck.add_argument (new CCodeIdentifier (get_ccode_type_id (cl)));
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_return_val_if_fail"));
ccall.add_argument (ccall_typecheck);
@@ -1106,15 +1106,15 @@ public class Vala.GTypeModule : GErrorModule {
private void begin_base_init_function (Class cl) {
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 ())));
+ var base_init = new CCodeFunction ("%s_base_init".printf (get_ccode_lower_case_name (cl, null)), "void");
+ 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"));
@@ -1124,7 +1124,7 @@ public class Vala.GTypeModule : GErrorModule {
ccode.add_assignment (new CCodeIdentifier ("parent_type"), ccall);
ccode.open_if (new CCodeIdentifier ("parent_type"));
- ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf (cl.get_upper_case_cname (null))));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf (get_ccode_upper_case_name (cl, null))));
ccall2 = new CCodeFunctionCall (new CCodeIdentifier ("g_type_class_peek"));
ccall2.add_argument (new CCodeIdentifier ("parent_type"));
ccall.add_argument (ccall2);
@@ -1132,7 +1132,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");
@@ -1141,7 +1141,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 ();
@@ -1149,7 +1149,7 @@ public class Vala.GTypeModule : GErrorModule {
ccall2 = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_FROM_CLASS"));
ccall2.add_argument (new CCodeIdentifier ("klass"));
ccall.add_argument (ccall2);
- ccall.add_argument (new CCodeIdentifier ("_vala_%s_class_private_quark".printf (cl.get_lower_case_cname ())));
+ ccall.add_argument (new CCodeIdentifier ("_vala_%s_class_private_quark".printf (get_ccode_lower_case_name (cl))));
ccall.add_argument (new CCodeIdentifier ("priv"));
ccode.add_expression (ccall);
}
@@ -1167,15 +1167,15 @@ public class Vala.GTypeModule : GErrorModule {
private void begin_class_init_function (Class cl) {
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 ())));
+ var func = new CCodeFunction ("%s_class_init".printf (get_ccode_lower_case_name (cl, null)));
+ func.add_parameter (new CCodeParameter ("klass", "%sClass *".printf (get_ccode_name (cl))));
func.modifiers = CCodeModifiers.STATIC;
CCodeFunctionCall ccall;
/* save pointer to parent class */
var parent_decl = new CCodeDeclaration ("gpointer");
- var parent_var_decl = new CCodeVariableDeclarator ("%s_parent_class".printf (cl.get_lower_case_cname (null)));
+ var parent_var_decl = new CCodeVariableDeclarator ("%s_parent_class".printf (get_ccode_lower_case_name (cl, null)));
parent_var_decl.initializer = new CCodeConstant ("NULL");
parent_decl.add_declarator (parent_var_decl);
parent_decl.modifiers = CCodeModifiers.STATIC;
@@ -1185,7 +1185,7 @@ public class Vala.GTypeModule : GErrorModule {
ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_class_peek_parent"));
ccall.add_argument (new CCodeIdentifier ("klass"));
- var parent_assignment = new CCodeAssignment (new CCodeIdentifier ("%s_parent_class".printf (cl.get_lower_case_cname (null))), ccall);
+ var parent_assignment = new CCodeAssignment (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (cl, null))), ccall);
ccode.add_expression (parent_assignment);
@@ -1196,9 +1196,9 @@ public class Vala.GTypeModule : GErrorModule {
fundamental_class = fundamental_class.base_class;
}
- ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (fundamental_class.get_upper_case_cname (null))));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (get_ccode_upper_case_name (fundamental_class, null))));
ccall.add_argument (new CCodeIdentifier ("klass"));
- var finalize_assignment = new CCodeAssignment (new CCodeMemberAccess.pointer (ccall, "finalize"), new CCodeIdentifier (cl.get_lower_case_cprefix () + "finalize"));
+ var finalize_assignment = new CCodeAssignment (new CCodeMemberAccess.pointer (ccall, "finalize"), new CCodeIdentifier (get_ccode_lower_case_prefix (cl) + "finalize"));
ccode.add_expression (finalize_assignment);
}
@@ -1206,7 +1206,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);
}
@@ -1219,13 +1219,13 @@ public class Vala.GTypeModule : GErrorModule {
// there is currently no default handler for abstract async methods
if (!m.is_abstract || !m.coroutine) {
- var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (((Class) base_type).get_upper_case_cname (null))));
+ var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (get_ccode_upper_case_name (base_type))));
ccast.add_argument (new CCodeIdentifier ("klass"));
- ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, m.base_method.vfunc_name), new CCodeIdentifier (m.get_real_cname ()));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, get_ccode_vfunc_name (m.base_method)), new CCodeIdentifier (get_ccode_real_name (m)));
if (m.coroutine) {
- ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, m.base_method.get_finish_vfunc_name ()), new CCodeIdentifier (m.get_finish_real_cname ()));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, get_ccode_finish_vfunc_name (m.base_method)), new CCodeIdentifier (get_ccode_finish_real_name (m)));
}
}
}
@@ -1235,9 +1235,9 @@ public class Vala.GTypeModule : GErrorModule {
if (sig.default_handler == null) {
continue;
}
- var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (cl.get_upper_case_cname (null))));
+ var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (get_ccode_upper_case_name (cl, null))));
ccast.add_argument (new CCodeIdentifier ("klass"));
- ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, sig.default_handler.vfunc_name), new CCodeIdentifier (sig.default_handler.get_real_cname ()));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, get_ccode_vfunc_name (sig.default_handler)), new CCodeIdentifier (get_ccode_real_name (sig.default_handler)));
}
/* connect overridden properties */
@@ -1247,15 +1247,15 @@ public class Vala.GTypeModule : GErrorModule {
}
var base_type = prop.base_property.parent_symbol;
- var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (((Class) base_type).get_upper_case_cname (null))));
+ var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (get_ccode_upper_case_name (base_type))));
ccast.add_argument (new CCodeIdentifier ("klass"));
if (prop.get_accessor != null) {
- string cname = "%s_real_get_%s".printf (cl.get_lower_case_cname (null), prop.name);
+ string cname = "%s_real_get_%s".printf (get_ccode_lower_case_name (cl, null), prop.name);
ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "get_%s".printf (prop.name)), new CCodeIdentifier (cname));
}
if (prop.set_accessor != null) {
- string cname = "%s_real_set_%s".printf (cl.get_lower_case_cname (null), prop.name);
+ string cname = "%s_real_set_%s".printf (get_ccode_lower_case_name (cl, null), prop.name);
ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "set_%s".printf (prop.name)), new CCodeIdentifier (cname));
}
}
@@ -1280,8 +1280,8 @@ public class Vala.GTypeModule : GErrorModule {
}
private void add_interface_init_function (Class cl, Interface iface) {
- var iface_init = new CCodeFunction ("%s_%s_interface_init".printf (cl.get_lower_case_cname (null), iface.get_lower_case_cname (null)), "void");
- iface_init.add_parameter (new CCodeParameter ("iface", "%s *".printf (iface.get_type_cname ())));
+ var iface_init = new CCodeFunction ("%s_%s_interface_init".printf (get_ccode_lower_case_name (cl), get_ccode_lower_case_name (iface)), "void");
+ iface_init.add_parameter (new CCodeParameter ("iface", "%s *".printf (get_ccode_type_name (iface))));
iface_init.modifiers = CCodeModifiers.STATIC;
push_function (iface_init);
@@ -1289,8 +1289,8 @@ public class Vala.GTypeModule : GErrorModule {
CCodeFunctionCall ccall;
/* save pointer to parent vtable */
- string parent_iface_var = "%s_%s_parent_iface".printf (cl.get_lower_case_cname (null), iface.get_lower_case_cname (null));
- var parent_decl = new CCodeDeclaration (iface.get_type_cname () + "*");
+ string parent_iface_var = "%s_%s_parent_iface".printf (get_ccode_lower_case_name (cl), get_ccode_lower_case_name (iface));
+ var parent_decl = new CCodeDeclaration (get_ccode_type_name (iface) + "*");
var parent_var_decl = new CCodeVariableDeclarator (parent_iface_var);
parent_var_decl.initializer = new CCodeConstant ("NULL");
parent_decl.add_declarator (parent_var_decl);
@@ -1313,20 +1313,20 @@ 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 ());
+ cfunc = new CCodeIdentifier (get_ccode_real_name (m));
}
cfunc = cast_method_pointer (m.base_interface_method, cfunc, iface);
- ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, m.base_interface_method.vfunc_name), cfunc);
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, get_ccode_vfunc_name (m.base_interface_method)), cfunc);
if (m.coroutine) {
if (m.is_abstract || m.is_virtual) {
- cfunc = new CCodeIdentifier (m.get_finish_cname ());
+ cfunc = new CCodeIdentifier (get_ccode_finish_name (m));
} else {
- cfunc = new CCodeIdentifier (m.get_finish_real_cname ());
+ cfunc = new CCodeIdentifier (get_ccode_finish_real_name (m));
}
- ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, m.base_interface_method.get_finish_vfunc_name ()), cfunc);
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, get_ccode_finish_vfunc_name (m.base_interface_method)), cfunc);
}
}
@@ -1351,10 +1351,10 @@ 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);
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, get_ccode_vfunc_name (m)), cfunc);
}
}
}
@@ -1372,9 +1372,9 @@ public class Vala.GTypeModule : GErrorModule {
var ciface = new CCodeIdentifier ("iface");
if (prop.get_accessor != null) {
- string cname = "%s_real_get_%s".printf (cl.get_lower_case_cname (null), prop.name);
+ string cname = "%s_real_get_%s".printf (get_ccode_lower_case_name (cl, null), prop.name);
if (prop.is_abstract || prop.is_virtual) {
- cname = "%s_get_%s".printf (cl.get_lower_case_cname (null), prop.name);
+ cname = "%s_get_%s".printf (get_ccode_lower_case_name (cl, null), prop.name);
}
CCodeExpression cfunc = new CCodeIdentifier (cname);
@@ -1384,9 +1384,9 @@ public class Vala.GTypeModule : GErrorModule {
ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, "get_%s".printf (prop.name)), cfunc);
}
if (prop.set_accessor != null) {
- string cname = "%s_real_set_%s".printf (cl.get_lower_case_cname (null), prop.name);
+ string cname = "%s_real_set_%s".printf (get_ccode_lower_case_name (cl, null), prop.name);
if (prop.is_abstract || prop.is_virtual) {
- cname = "%s_set_%s".printf (cl.get_lower_case_cname (null), prop.name);
+ cname = "%s_set_%s".printf (get_ccode_lower_case_name (cl, null), prop.name);
}
CCodeExpression cfunc = new CCodeIdentifier (cname);
@@ -1423,7 +1423,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);
@@ -1431,7 +1431,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);
@@ -1446,13 +1446,13 @@ 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);
}
@@ -1463,11 +1463,11 @@ public class Vala.GTypeModule : GErrorModule {
if (m.return_type.is_real_non_null_struct_type ()) {
cast = "void (*)";
} else {
- cast = m.return_type.get_cname () + " (*)";
+ cast = get_ccode_name (m.return_type) + " (*)";
}
- string cast_args = base_type.get_cname () + "*";
+ string cast_args = get_ccode_name (base_type) + "*";
- var vdeclarator = new CCodeFunctionDeclarator (m.vfunc_name);
+ var vdeclarator = new CCodeFunctionDeclarator (get_ccode_vfunc_name (m));
var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
generate_cparameters (m, cfile, cparam_map, new CCodeFunction ("fake"), vdeclarator);
@@ -1503,8 +1503,8 @@ public class Vala.GTypeModule : GErrorModule {
private void begin_instance_init_function (Class cl) {
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 ())));
+ var func = new CCodeFunction ("%s_instance_init".printf (get_ccode_lower_case_name (cl, null)));
+ func.add_parameter (new CCodeParameter ("self", "%s *".printf (get_ccode_name (cl))));
func.modifiers = CCodeModifiers.STATIC;
push_function (func);
@@ -1516,7 +1516,7 @@ public class Vala.GTypeModule : GErrorModule {
}
if (!cl.is_compact && (cl.has_private_fields || cl.get_type_parameters ().size > 0)) {
- var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (cl.get_upper_case_cname (null))));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (get_ccode_upper_case_name (cl, null))));
ccall.add_argument (new CCodeIdentifier ("self"));
func.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), "priv"), ccall);
}
@@ -1531,10 +1531,10 @@ public class Vala.GTypeModule : GErrorModule {
private void begin_class_finalize_function (Class cl) {
push_context (class_finalize_context);
- var function = new CCodeFunction ("%s_class_finalize".printf (cl.get_lower_case_cname (null)), "void");
+ var function = new CCodeFunction ("%s_class_finalize".printf (get_ccode_lower_case_name (cl, null)), "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("klass", cl.get_cname () + "Class *"));
+ function.add_parameter (new CCodeParameter ("klass", get_ccode_name (cl) + "Class *"));
push_function (function);
@@ -1553,10 +1553,10 @@ public class Vala.GTypeModule : GErrorModule {
private void begin_base_finalize_function (Class cl) {
push_context (base_finalize_context);
- var function = new CCodeFunction ("%s_base_finalize".printf (cl.get_lower_case_cname (null)), "void");
+ var function = new CCodeFunction ("%s_base_finalize".printf (get_ccode_lower_case_name (cl, null)), "void");
function.modifiers = CCodeModifiers.STATIC;
- function.add_parameter (new CCodeParameter ("klass", cl.get_cname () + "Class *"));
+ function.add_parameter (new CCodeParameter ("klass", get_ccode_name (cl) + "Class *"));
push_function (function);
@@ -1573,16 +1573,16 @@ 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);
- var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf (cl.get_upper_case_cname (null))));
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf (get_ccode_upper_case_name (cl, null))));
ccall.add_argument (new CCodeConstant ("klass"));
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));
@@ -1604,23 +1604,23 @@ public class Vala.GTypeModule : GErrorModule {
fundamental_class = fundamental_class.base_class;
}
- var func = new CCodeFunction ("%s_finalize".printf (cl.get_lower_case_cname (null)));
- func.add_parameter (new CCodeParameter ("obj", fundamental_class.get_cname () + "*"));
+ var func = new CCodeFunction ("%s_finalize".printf (get_ccode_lower_case_name (cl, null)));
+ func.add_parameter (new CCodeParameter ("obj", get_ccode_name (fundamental_class) + "*"));
func.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");
+ var function = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "free", "void");
if (cl.access == SymbolAccessibility.PRIVATE) {
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);
}
@@ -1650,8 +1650,8 @@ public class Vala.GTypeModule : GErrorModule {
// chain up to finalize function of the base class
if (cl.base_class != null) {
- var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (fundamental_class.get_upper_case_cname ())));
- ccast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (cl.get_lower_case_cname (null))));
+ var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (get_ccode_upper_case_name (fundamental_class))));
+ ccast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (get_ccode_lower_case_name (cl, null))));
var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (ccast, "finalize"));
ccall.add_argument (new CCodeIdentifier ("obj"));
push_context (instance_finalize_context);
@@ -1662,7 +1662,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"));
push_context (instance_finalize_context);
ccode.add_expression (ccall);
@@ -1674,31 +1674,39 @@ public class Vala.GTypeModule : GErrorModule {
public override CCodeFunctionCall get_param_spec (Property prop) {
var cspec = new CCodeFunctionCall ();
- cspec.add_argument (prop.get_canonical_cconstant ());
- cspec.add_argument (new CCodeConstant ("\"%s\"".printf (prop.nick)));
- cspec.add_argument (new CCodeConstant ("\"%s\"".printf (prop.blurb)));
+ cspec.add_argument (get_property_canonical_cconstant (prop));
+ var nick = prop.get_attribute_string ("Description", "nick");
+ if (nick == null) {
+ nick = prop.name.replace ("_", "-");
+ }
+ var blurb = prop.get_attribute_string ("Description", "blurb");
+ if (blurb == null) {
+ blurb = prop.name.replace ("_", "-");
+ }
+ cspec.add_argument (new CCodeConstant ("\"%s\"".printf (nick)));
+ cspec.add_argument (new CCodeConstant ("\"%s\"".printf (blurb)));
if (prop.property_type.data_type is Class || prop.property_type.data_type is Interface) {
- string param_spec_name = prop.property_type.data_type.get_param_spec_function ();
+ string param_spec_name = get_ccode_param_spec_function (prop.property_type.data_type);
cspec.call = new CCodeIdentifier (param_spec_name);
if (param_spec_name == "g_param_spec_string") {
cspec.add_argument (new CCodeConstant ("NULL"));
} else if (param_spec_name == "g_param_spec_variant") {
cspec.add_argument (new CCodeConstant ("G_VARIANT_TYPE_ANY"));
cspec.add_argument (new CCodeConstant ("NULL"));
- } else if (prop.property_type.data_type.get_type_id () != "G_TYPE_POINTER") {
- cspec.add_argument (new CCodeIdentifier (prop.property_type.data_type.get_type_id ()));
+ } else if (get_ccode_type_id (prop.property_type.data_type) != "G_TYPE_POINTER") {
+ cspec.add_argument (new CCodeIdentifier (get_ccode_type_id (prop.property_type.data_type)));
}
} else if (prop.property_type.data_type is Enum) {
var e = prop.property_type.data_type as Enum;
- if (e.has_type_id) {
+ if (get_ccode_has_type_id (e)) {
if (e.is_flags) {
cspec.call = new CCodeIdentifier ("g_param_spec_flags");
} else {
cspec.call = new CCodeIdentifier ("g_param_spec_enum");
}
- cspec.add_argument (new CCodeIdentifier (e.get_type_id ()));
+ cspec.add_argument (new CCodeIdentifier (get_ccode_type_id (e)));
} else {
if (e.is_flags) {
cspec.call = new CCodeIdentifier ("g_param_spec_uint");
@@ -1714,11 +1722,11 @@ public class Vala.GTypeModule : GErrorModule {
if (prop.initializer != null) {
cspec.add_argument ((CCodeExpression) get_ccodenode (prop.initializer));
} else {
- cspec.add_argument (new CCodeConstant (prop.property_type.data_type.get_default_value ()));
+ cspec.add_argument (new CCodeConstant (get_ccode_default_value (prop.property_type.data_type)));
}
} else if (prop.property_type.data_type is Struct) {
var st = (Struct) prop.property_type.data_type;
- if (st.get_type_id () == "G_TYPE_INT") {
+ if (get_ccode_type_id (st) == "G_TYPE_INT") {
cspec.call = new CCodeIdentifier ("g_param_spec_int");
cspec.add_argument (new CCodeConstant ("G_MININT"));
cspec.add_argument (new CCodeConstant ("G_MAXINT"));
@@ -1727,7 +1735,7 @@ public class Vala.GTypeModule : GErrorModule {
} else {
cspec.add_argument (new CCodeConstant ("0"));
}
- } else if (st.get_type_id () == "G_TYPE_UINT") {
+ } else if (get_ccode_type_id (st) == "G_TYPE_UINT") {
cspec.call = new CCodeIdentifier ("g_param_spec_uint");
cspec.add_argument (new CCodeConstant ("0"));
cspec.add_argument (new CCodeConstant ("G_MAXUINT"));
@@ -1736,7 +1744,7 @@ public class Vala.GTypeModule : GErrorModule {
} else {
cspec.add_argument (new CCodeConstant ("0U"));
}
- } else if (st.get_type_id () == "G_TYPE_INT64") {
+ } else if (get_ccode_type_id (st) == "G_TYPE_INT64") {
cspec.call = new CCodeIdentifier ("g_param_spec_int64");
cspec.add_argument (new CCodeConstant ("G_MININT64"));
cspec.add_argument (new CCodeConstant ("G_MAXINT64"));
@@ -1745,7 +1753,7 @@ public class Vala.GTypeModule : GErrorModule {
} else {
cspec.add_argument (new CCodeConstant ("0"));
}
- } else if (st.get_type_id () == "G_TYPE_UINT64") {
+ } else if (get_ccode_type_id (st) == "G_TYPE_UINT64") {
cspec.call = new CCodeIdentifier ("g_param_spec_uint64");
cspec.add_argument (new CCodeConstant ("0"));
cspec.add_argument (new CCodeConstant ("G_MAXUINT64"));
@@ -1754,7 +1762,7 @@ public class Vala.GTypeModule : GErrorModule {
} else {
cspec.add_argument (new CCodeConstant ("0U"));
}
- } else if (st.get_type_id () == "G_TYPE_LONG") {
+ } else if (get_ccode_type_id (st) == "G_TYPE_LONG") {
cspec.call = new CCodeIdentifier ("g_param_spec_long");
cspec.add_argument (new CCodeConstant ("G_MINLONG"));
cspec.add_argument (new CCodeConstant ("G_MAXLONG"));
@@ -1763,7 +1771,7 @@ public class Vala.GTypeModule : GErrorModule {
} else {
cspec.add_argument (new CCodeConstant ("0L"));
}
- } else if (st.get_type_id () == "G_TYPE_ULONG") {
+ } else if (get_ccode_type_id (st) == "G_TYPE_ULONG") {
cspec.call = new CCodeIdentifier ("g_param_spec_ulong");
cspec.add_argument (new CCodeConstant ("0"));
cspec.add_argument (new CCodeConstant ("G_MAXULONG"));
@@ -1772,14 +1780,14 @@ public class Vala.GTypeModule : GErrorModule {
} else {
cspec.add_argument (new CCodeConstant ("0UL"));
}
- } else if (st.get_type_id () == "G_TYPE_BOOLEAN") {
+ } else if (get_ccode_type_id (st) == "G_TYPE_BOOLEAN") {
cspec.call = new CCodeIdentifier ("g_param_spec_boolean");
if (prop.initializer != null) {
cspec.add_argument ((CCodeExpression) get_ccodenode (prop.initializer));
} else {
cspec.add_argument (new CCodeConstant ("FALSE"));
}
- } else if (st.get_type_id () == "G_TYPE_CHAR") {
+ } else if (get_ccode_type_id (st) == "G_TYPE_CHAR") {
cspec.call = new CCodeIdentifier ("g_param_spec_char");
cspec.add_argument (new CCodeConstant ("G_MININT8"));
cspec.add_argument (new CCodeConstant ("G_MAXINT8"));
@@ -1788,7 +1796,7 @@ public class Vala.GTypeModule : GErrorModule {
} else {
cspec.add_argument (new CCodeConstant ("0"));
}
- } else if (st.get_type_id () == "G_TYPE_UCHAR") {
+ } else if (get_ccode_type_id (st) == "G_TYPE_UCHAR") {
cspec.call = new CCodeIdentifier ("g_param_spec_uchar");
cspec.add_argument (new CCodeConstant ("0"));
cspec.add_argument (new CCodeConstant ("G_MAXUINT8"));
@@ -1797,7 +1805,7 @@ public class Vala.GTypeModule : GErrorModule {
} else {
cspec.add_argument (new CCodeConstant ("0"));
}
- }else if (st.get_type_id () == "G_TYPE_FLOAT") {
+ }else if (get_ccode_type_id (st) == "G_TYPE_FLOAT") {
cspec.call = new CCodeIdentifier ("g_param_spec_float");
cspec.add_argument (new CCodeConstant ("-G_MAXFLOAT"));
cspec.add_argument (new CCodeConstant ("G_MAXFLOAT"));
@@ -1806,7 +1814,7 @@ public class Vala.GTypeModule : GErrorModule {
} else {
cspec.add_argument (new CCodeConstant ("0.0F"));
}
- } else if (st.get_type_id () == "G_TYPE_DOUBLE") {
+ } else if (get_ccode_type_id (st) == "G_TYPE_DOUBLE") {
cspec.call = new CCodeIdentifier ("g_param_spec_double");
cspec.add_argument (new CCodeConstant ("-G_MAXDOUBLE"));
cspec.add_argument (new CCodeConstant ("G_MAXDOUBLE"));
@@ -1815,7 +1823,7 @@ public class Vala.GTypeModule : GErrorModule {
} else {
cspec.add_argument (new CCodeConstant ("0.0"));
}
- } else if (st.get_type_id () == "G_TYPE_GTYPE") {
+ } else if (get_ccode_type_id (st) == "G_TYPE_GTYPE") {
cspec.call = new CCodeIdentifier ("g_param_spec_gtype");
if (prop.initializer != null) {
cspec.add_argument ((CCodeExpression) get_ccodenode (prop.initializer));
@@ -1824,7 +1832,7 @@ public class Vala.GTypeModule : GErrorModule {
}
} else {
cspec.call = new CCodeIdentifier ("g_param_spec_boxed");
- cspec.add_argument (new CCodeIdentifier (st.get_type_id ()));
+ cspec.add_argument (new CCodeIdentifier (get_ccode_type_id (st)));
}
} else if (prop.property_type is ArrayType && ((ArrayType)prop.property_type).element_type.data_type == string_type.data_type) {
cspec.call = new CCodeIdentifier ("g_param_spec_boxed");
@@ -1853,7 +1861,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;
}
@@ -1867,24 +1875,24 @@ public class Vala.GTypeModule : GErrorModule {
}
}
- var type_struct = new CCodeStruct ("_%s".printf (iface.get_type_cname ()));
+ var type_struct = new CCodeStruct ("_%s".printf (get_ccode_type_name (iface)));
decl_space.add_type_declaration (new CCodeNewline ());
- var macro = "(%s_get_type ())".printf (iface.get_lower_case_cname (null));
- decl_space.add_type_declaration (new CCodeMacroReplacement (iface.get_type_id (), macro));
+ var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (iface, null));
+ decl_space.add_type_declaration (new CCodeMacroReplacement (get_ccode_type_id (iface), macro));
- macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (iface.get_type_id (), iface.get_cname ());
- decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(obj)".printf (iface.get_upper_case_cname (null)), macro));
+ macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (get_ccode_type_id (iface), get_ccode_name (iface));
+ decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(obj)".printf (get_ccode_upper_case_name (iface, null)), macro));
- macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (iface.get_type_id ());
- decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(obj)".printf (get_type_check_function (iface)), macro));
+ macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (get_ccode_type_id (iface));
+ decl_space.add_type_declaration (new CCodeMacroReplacement ("%s(obj)".printf (get_ccode_type_check_function (iface)), macro));
- macro = "(G_TYPE_INSTANCE_GET_INTERFACE ((obj), %s, %s))".printf (iface.get_type_id (), iface.get_type_cname ());
- decl_space.add_type_declaration (new CCodeMacroReplacement ("%s_GET_INTERFACE(obj)".printf (iface.get_upper_case_cname (null)), macro));
+ macro = "(G_TYPE_INSTANCE_GET_INTERFACE ((obj), %s, %s))".printf (get_ccode_type_id (iface), get_ccode_type_name (iface));
+ decl_space.add_type_declaration (new CCodeMacroReplacement ("%s_GET_INTERFACE(obj)".printf (get_ccode_upper_case_name (iface, 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 (type_struct.name), new CCodeVariableDeclarator (iface.get_type_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 (get_ccode_type_name (iface))));
type_struct.add_field ("GTypeInterface", "parent_iface");
@@ -1909,18 +1917,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;
@@ -1938,10 +1946,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);
}
@@ -1969,9 +1977,9 @@ public class Vala.GTypeModule : GErrorModule {
push_context (new EmitContext (iface));
push_line (iface.source_reference);
- 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;
}
@@ -2003,14 +2011,14 @@ public class Vala.GTypeModule : GErrorModule {
private void add_interface_base_init_function (Interface iface) {
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 ())));
+ var base_init = new CCodeFunction ("%s_base_init".printf (get_ccode_lower_case_name (iface, null)), "void");
+ 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"));
@@ -2044,8 +2052,8 @@ public class Vala.GTypeModule : GErrorModule {
if (sig.default_handler == null) {
continue;
}
- var cname = sig.default_handler.get_real_cname ();
- ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, sig.default_handler.vfunc_name), new CCodeIdentifier (cname));
+ var cname = get_ccode_real_name (sig.default_handler);
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, get_ccode_vfunc_name (sig.default_handler)), new CCodeIdentifier (cname));
}
/* create signals */
@@ -2059,10 +2067,10 @@ public class Vala.GTypeModule : GErrorModule {
// connect default implementations
foreach (Method m in iface.get_methods ()) {
if (m.is_virtual) {
- var cname = m.get_real_cname ();
- ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, m.vfunc_name), new CCodeIdentifier (cname));
+ var cname = get_ccode_real_name (m);
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, get_ccode_vfunc_name (m)), new CCodeIdentifier (cname));
if (m.coroutine) {
- ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, m.get_finish_vfunc_name ()), new CCodeIdentifier (m.get_finish_real_cname ()));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, get_ccode_finish_vfunc_name (m)), new CCodeIdentifier (get_ccode_finish_real_name (m)));
}
}
}
@@ -2077,7 +2085,7 @@ public class Vala.GTypeModule : GErrorModule {
public override void visit_struct (Struct st) {
base.visit_struct (st);
- if (st.has_type_id) {
+ if (get_ccode_has_type_id (st)) {
push_line (st.source_reference);
var type_fun = new StructRegisterFunction (st, context);
type_fun.init_from_type (false, false);
@@ -2089,7 +2097,7 @@ public class Vala.GTypeModule : GErrorModule {
public override void visit_enum (Enum en) {
base.visit_enum (en);
- if (en.has_type_id) {
+ if (get_ccode_has_type_id (en)) {
push_line (en.source_reference);
var type_fun = new EnumRegisterFunction (en, context);
type_fun.init_from_type (false, false);
@@ -2102,7 +2110,7 @@ public class Vala.GTypeModule : GErrorModule {
var ma = expr.call as MemberAccess;
var mtype = expr.call.value_type as MethodType;
if (mtype == null || ma == null || ma.inner == null ||
- !(ma.inner.value_type is EnumValueType) || !((Enum) ma.inner.value_type.data_type).has_type_id ||
+ !(ma.inner.value_type is EnumValueType) || !get_ccode_has_type_id (ma.inner.value_type.data_type) ||
mtype.method_symbol != ((EnumValueType) ma.inner.value_type).get_to_string_method ()) {
base.visit_method_call (expr);
return;
@@ -2114,7 +2122,7 @@ public class Vala.GTypeModule : GErrorModule {
emit_temp_var (temp_var);
var class_ref = new CCodeFunctionCall (new CCodeIdentifier ("g_type_class_ref"));
- class_ref.add_argument (new CCodeIdentifier (ma.inner.value_type.get_type_id ()));
+ class_ref.add_argument (new CCodeIdentifier (get_ccode_type_id (ma.inner.value_type)));
var get_value = new CCodeFunctionCall (new CCodeIdentifier ("g_enum_get_value"));
get_value.add_argument (class_ref);
get_value.add_argument ((CCodeExpression) get_ccodenode (((MemberAccess) expr.call).inner));
@@ -2128,7 +2136,7 @@ public class Vala.GTypeModule : GErrorModule {
public override void visit_property (Property prop) {
var cl = current_type_symbol as Class;
var st = current_type_symbol as Struct;
- if (prop.name == "type" && ((cl != null && !cl.is_compact) || (st != null && st.has_type_id))) {
+ if (prop.name == "type" && ((cl != null && !cl.is_compact) || (st != null && get_ccode_has_type_id (st)))) {
Report.error (prop.source_reference, "Property 'type' not allowed");
return;
}
diff --git a/codegen/valagvariantmodule.vala b/codegen/valagvariantmodule.vala
index f7d4d0c..aaef09c 100644
--- a/codegen/valagvariantmodule.vala
+++ b/codegen/valagvariantmodule.vala
@@ -44,32 +44,21 @@ public class Vala.GVariantModule : GAsyncModule {
static bool is_string_marshalled_enum (TypeSymbol? symbol) {
if (symbol != null && symbol is Enum) {
- var dbus = symbol.get_attribute ("DBus");
- return dbus != null && dbus.get_bool ("use_string_marshalling");
+ return symbol.get_attribute_bool ("DBus", "use_string_marshalling");
}
return false;
}
string get_dbus_value (EnumValue value, string default_value) {
- var dbus = value.get_attribute ("DBus");
- if (dbus == null) {
- return default_value;
+ var dbus_value = value.get_attribute_string ("DBus", "value");
+ if (dbus_value != null) {
+ return dbus_value;;
}
-
- string dbus_value = dbus.get_string ("value");
- if (dbus_value == null) {
- return default_value;
- }
- return dbus_value;
+ return default_value;
}
public static string? get_dbus_signature (Symbol symbol) {
- var dbus = symbol.get_attribute ("DBus");
- if (dbus == null) {
- return null;
- }
-
- return dbus.get_string ("signature");
+ return symbol.get_attribute_string ("DBus", "signature");
}
bool get_basic_type_info (string signature, out BasicTypeInfo basic_type) {
@@ -105,12 +94,7 @@ public class Vala.GVariantModule : GAsyncModule {
} else if (is_string_marshalled_enum (datatype.data_type)) {
return "s";
} else if (datatype.data_type != null) {
- string sig = null;
-
- var ccode = datatype.data_type.get_attribute ("CCode");
- if (ccode != null) {
- sig = ccode.get_string ("type_signature");
- }
+ string sig = datatype.data_type.get_attribute_string ("CCode", "type_signature");
var st = datatype.data_type as Struct;
var en = datatype.data_type as Enum;
@@ -202,7 +186,7 @@ public class Vala.GVariantModule : GAsyncModule {
CCodeExpression? generate_enum_value_from_string (EnumValueType type, CCodeExpression? expr, CCodeExpression? error_expr) {
var en = type.type_symbol as Enum;
- var from_string_name = "%s_from_string".printf (en.get_lower_case_cname (null));
+ var from_string_name = "%s_from_string".printf (get_ccode_lower_case_name (en, null));
var from_string_call = new CCodeFunctionCall (new CCodeIdentifier (from_string_name));
from_string_call.add_argument (expr);
@@ -212,9 +196,9 @@ 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_name = "%s_from_string".printf (get_ccode_lower_case_name (en, 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**"));
@@ -222,15 +206,15 @@ 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_name = "%s_from_string".printf (get_ccode_lower_case_name (en, 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 ()) {
@@ -245,7 +229,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 ();
@@ -253,7 +237,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 ();
@@ -283,11 +267,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")));
@@ -335,7 +319,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")));
@@ -363,7 +347,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"));
@@ -380,7 +364,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) {
@@ -474,7 +458,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);
@@ -531,7 +515,7 @@ public class Vala.GVariantModule : GAsyncModule {
CCodeExpression? generate_enum_value_to_string (EnumValueType type, CCodeExpression? expr) {
var en = type.type_symbol as Enum;
- var to_string_name = "%s_to_string".printf (en.get_lower_case_cname (null));
+ var to_string_name = "%s_to_string".printf (get_ccode_lower_case_name (en, null));
var to_string_call = new CCodeFunctionCall (new CCodeIdentifier (to_string_name));
to_string_call.add_argument (expr);
@@ -540,19 +524,19 @@ public class Vala.GVariantModule : GAsyncModule {
}
public CCodeFunction generate_enum_to_string_function_declaration (Enum en) {
- var to_string_name = "%s_to_string".printf (en.get_lower_case_cname (null));
+ var to_string_name = "%s_to_string".printf (get_ccode_lower_case_name (en, 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;
}
public CCodeFunction generate_enum_to_string_function (Enum en) {
- var to_string_name = "%s_to_string".printf (en.get_lower_case_cname (null));
+ var to_string_name = "%s_to_string".printf (get_ccode_lower_case_name (en, 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);
@@ -561,7 +545,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 ();
}
@@ -581,7 +565,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));
@@ -651,7 +635,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) {
@@ -699,8 +683,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/valainterfaceregisterfunction.vala b/codegen/valainterfaceregisterfunction.vala
index cec7cbd..0b900ea 100644
--- a/codegen/valainterfaceregisterfunction.vala
+++ b/codegen/valainterfaceregisterfunction.vala
@@ -43,11 +43,11 @@ public class Vala.InterfaceRegisterFunction : TypeRegisterFunction {
}
public override string get_type_struct_name () {
- return interface_reference.get_type_cname ();
+ return CCodeBaseModule.get_ccode_type_name (interface_reference);
}
public override string get_base_init_func_name () {
- return "%s_base_init".printf (interface_reference.get_lower_case_cname (null));
+ return "%s_base_init".printf (CCodeBaseModule.get_ccode_lower_case_name (interface_reference));
}
public override string get_class_finalize_func_name () {
@@ -84,8 +84,8 @@ public class Vala.InterfaceRegisterFunction : TypeRegisterFunction {
var prereq = prereq_ref.data_type;
var func = new CCodeFunctionCall (new CCodeIdentifier ("g_type_interface_add_prerequisite"));
- func.add_argument (new CCodeIdentifier ("%s_type_id".printf (interface_reference.get_lower_case_cname (null))));
- func.add_argument (new CCodeIdentifier (prereq.get_type_id()));
+ func.add_argument (new CCodeIdentifier ("%s_type_id".printf (CCodeBaseModule.get_ccode_lower_case_name (interface_reference))));
+ func.add_argument (new CCodeIdentifier (CCodeBaseModule.get_ccode_type_id (prereq)));
block.add_statement (new CCodeExpressionStatement (func));
}
diff --git a/codegen/valatyperegisterfunction.vala b/codegen/valatyperegisterfunction.vala
index e3f38ad..a226683 100644
--- a/codegen/valatyperegisterfunction.vala
+++ b/codegen/valatyperegisterfunction.vala
@@ -44,7 +44,7 @@ public abstract class Vala.TypeRegisterFunction {
fundamental = true;
}
- string type_id_name = "%s_type_id".printf (get_type_declaration ().get_lower_case_cname (null));
+ string type_id_name = "%s_type_id".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ()));
var type_block = new CCodeBlock ();
CCodeDeclaration cdecl;
@@ -67,7 +67,7 @@ public abstract class Vala.TypeRegisterFunction {
CCodeFunction fun;
if (!plugin) {
- fun = new CCodeFunction ("%s_get_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType");
+ fun = new CCodeFunction ("%s_get_type".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ())), "GType");
fun.attributes = "G_GNUC_CONST";
/* Function will not be prototyped anyway */
@@ -77,10 +77,10 @@ public abstract class Vala.TypeRegisterFunction {
fun.attributes += " G_GNUC_UNUSED";
}
} else {
- fun = new CCodeFunction ("%s_register_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType");
+ fun = new CCodeFunction ("%s_register_type".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ())), "GType");
fun.add_parameter (new CCodeParameter ("module", "GTypeModule *"));
- var get_fun = new CCodeFunction ("%s_get_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType");
+ var get_fun = new CCodeFunction ("%s_get_type".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ())), "GType");
get_fun.attributes = "G_GNUC_CONST";
get_fun.is_declaration = true;
@@ -133,9 +133,9 @@ 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)));
+ type_init.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("_vala_%s_class_private_quark".printf (CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ()))), quark_reg_call)));
}
CCodeFunctionCall reg_call;
@@ -159,11 +159,11 @@ 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"));
- reg_call.add_argument (new CCodeCastExpression (new CCodeIdentifier (st.get_free_function ()), "GBoxedFreeFunc"));
+ reg_call.add_argument (new CCodeCastExpression (new CCodeIdentifier (CCodeBaseModule.get_ccode_dup_function (st)), "GBoxedCopyFunc"));
+ reg_call.add_argument (new CCodeCastExpression (new CCodeIdentifier (CCodeBaseModule.get_ccode_free_function (st)), "GBoxedFreeFunc"));
} else if (get_type_declaration () is Enum) {
var en = get_type_declaration () as Enum;
var clist = new CCodeInitializerList (); /* or during visit time? */
@@ -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]