[vala/wip/attributes: 17/119] codegen: Add get_ccode_type_id
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 17/119] codegen: Add get_ccode_type_id
- Date: Mon, 4 Jul 2011 10:23:31 +0000 (UTC)
commit 868304e9ebb0e358e1c4d4e44151b96d226175f8
Author: Luca Bruno <lucabru src gnome org>
Date: Tue Jun 28 09:44:53 2011 +0200
codegen: Add get_ccode_type_id
codegen/valaccodebasemodule.vala | 87 ++++++++++++++++++++++++---
codegen/valaccodemethodmodule.vala | 2 +-
codegen/valaccodestructmodule.vala | 2 +-
codegen/valaclassregisterfunction.vala | 6 +-
codegen/valadovabasemodule.vala | 2 +-
codegen/valagdbusclientmodule.vala | 4 +-
codegen/valagsignalmodule.vala | 8 +-
codegen/valagtypemodule.vala | 70 +++++++++++-----------
codegen/valainterfaceregisterfunction.vala | 2 +-
9 files changed, 125 insertions(+), 58 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 744286c..e504e3c 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -701,7 +701,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
decl_space.add_type_declaration (new CCodeNewline ());
var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (en, null));
- decl_space.add_type_declaration (new CCodeMacroReplacement (en.get_type_id (), macro));
+ decl_space.add_type_declaration (new CCodeMacroReplacement (get_ccode_type_id (en), macro));
var fun_name = "%s_get_type".printf (get_ccode_lower_case_name (en, null));
var regfun = new CCodeFunction (fun_name, "GType");
@@ -2218,8 +2218,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return new CCodeIdentifier (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);
@@ -2557,7 +2557,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
assert (cl != null && cl.is_gboxed);
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);
@@ -2587,7 +2587,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var cl = type.data_type as Class;
if (cl != null && cl.is_gboxed) {
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);
@@ -4092,7 +4092,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (!m.has_new_function) {
// 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.add_argument (new CCodeIdentifier (get_ccode_type_id (cl)));
} else {
creation_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (m)));
}
@@ -4414,7 +4414,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;
}
@@ -4443,7 +4443,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
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)\""));
@@ -5080,7 +5080,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
@@ -5150,7 +5150,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
} else {
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_variable_cexpression (decl.name)));
}
- ccall.add_argument (new CCodeIdentifier (type.get_type_id ()));
+ ccall.add_argument (new CCodeIdentifier (get_ccode_type_id (type)));
ccode.add_expression (ccall);
if (requires_destroy (type)) {
@@ -5646,6 +5646,17 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return get_ccode_attribute(sym).free_function;
}
+ 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 override void visit_class (Class cl) {
}
@@ -6126,6 +6137,15 @@ public class Vala.CCodeAttribute : AttributeCache {
}
}
+ public string type_id {
+ get {
+ if (_type_id == null) {
+ _type_id = get_default_type_id ();
+ }
+ return _type_id;
+ }
+ }
+
private string _name;
private string _const_name;
private string _type_name;
@@ -6139,6 +6159,7 @@ public class Vala.CCodeAttribute : AttributeCache {
private string _ref_sink_function;
private string _copy_function;
private string _free_function;
+ private string _type_id;
public CCodeAttribute (CodeNode node) {
this.node = node;
@@ -6170,6 +6191,7 @@ public class Vala.CCodeAttribute : AttributeCache {
_ref_sink_function = attr.get_string ("ref_sink_function");
_copy_function = attr.get_string ("copy_function");
_free_function = attr.get_string ("free_function");
+ _type_id = attr.get_string ("type_id");
}
}
@@ -6437,4 +6459,49 @@ public class Vala.CCodeAttribute : AttributeCache {
}
return "";
}
+
+ private string get_default_type_id () {
+ if (sym != null) {
+ if (sym is Class && !((Class) sym).is_compact || sym is Interface) {
+ return ((Class) sym).get_upper_case_cname ("TYPE_");
+ } else if (sym is ErrorType && sym.source_reference != null && sym.source_reference.file.context.require_glib_version (2, 26)) {
+ return "G_TYPE_ERROR";
+ } else if (sym is Struct) {
+ var st = (Struct) sym;
+ if (!st.has_type_id) {
+ var base_struct = st.base_struct;
+ if (base_struct != null) {
+ return CCodeBaseModule.get_ccode_type_id (base_struct);
+ }
+ if (!st.is_simple_type ()) {
+ return "G_TYPE_POINTER";
+ }
+ } else {
+ return st.get_upper_case_cname ("TYPE_");
+ }
+ } else if (sym is VoidType) {
+ return "G_TYPE_NONE";
+ } else {
+ return "G_TYPE_POINTER";
+ }
+ } else if (node is ArrayType && ((ArrayType) node).element_type.data_type == string_type.data_type) {
+ return "G_TYPE_STRV";
+ } else if (node is PointerType || node is DelegateType) {
+ return "G_TYPE_POINTER";
+ } else if (node is ErrorType) {
+ if (node.source_reference != null && node.source_reference.file.context.require_glib_version (2, 26)) {
+ return "G_TYPE_ERROR";
+ } else {
+ return "G_TYPE_POINTER";
+ }
+ } else if (node is VoidType) {
+ return "G_TYPE_NONE";
+ } else {
+ var type = (DataType) node;
+ if (type.data_type != null) {
+ return CCodeBaseModule.get_ccode_type_id (type.data_type);
+ }
+ }
+ return "";
+ }
}
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 89904e3..13fc80a 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -1015,7 +1015,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
push_function (vfunc);
var vcall = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname ()));
- vcall.add_argument (new CCodeIdentifier (current_class.get_type_id ()));
+ 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 e3f0cf1..6f8a7ad 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -50,7 +50,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
if (st.has_type_id) {
decl_space.add_type_declaration (new CCodeNewline ());
var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (st, null));
- decl_space.add_type_declaration (new CCodeMacroReplacement (st.get_type_id (), macro));
+ 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);
diff --git a/codegen/valaclassregisterfunction.vala b/codegen/valaclassregisterfunction.vala
index 274661f..684b1ef 100644
--- a/codegen/valaclassregisterfunction.vala
+++ b/codegen/valaclassregisterfunction.vala
@@ -87,7 +87,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
}
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 () {
@@ -183,14 +183,14 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
if (!plugin) {
var reg_call = new CCodeFunctionCall (new CCodeIdentifier ("g_type_add_interface_static"));
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 (iface.get_type_id ()));
+ reg_call.add_argument (new CCodeIdentifier (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 (CCodeBaseModule.get_ccode_lower_case_name (class_reference, null))));
- reg_call.add_argument (new CCodeIdentifier (iface.get_type_id ()));
+ reg_call.add_argument (new CCodeIdentifier (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/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index ec45d9d..f1a1054 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -1591,7 +1591,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
if (!m.has_new_function) {
// 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.add_argument (new CCodeIdentifier (CCodeBaseModule.get_ccode_type_id (cl)));
} else {
creation_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (m)));
}
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index f39262b..16b010a 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -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");
@@ -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
diff --git a/codegen/valagsignalmodule.vala b/codegen/valagsignalmodule.vala
index d5496b6..95dee3c 100644
--- a/codegen/valagsignalmodule.vala
+++ b/codegen/valagsignalmodule.vala
@@ -337,7 +337,7 @@ public class Vala.GSignalModule : GObjectModule {
public override CCodeFunctionCall get_signal_creation (Signal sig, TypeSymbol type) {
var csignew = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_new"));
csignew.add_argument (new CCodeConstant ("\"%s\"".printf (get_ccode_name (sig))));
- csignew.add_argument (new CCodeIdentifier (type.get_type_id ()));
+ csignew.add_argument (new CCodeIdentifier (get_ccode_type_id (type)));
string[] flags = new string[0];
if (sig.run_type == "first") {
flags += "G_SIGNAL_RUN_FIRST";
@@ -393,7 +393,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;
@@ -418,7 +418,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)));
}
}
@@ -630,7 +630,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 8c74e31..af13a23 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -64,21 +64,21 @@ public class Vala.GTypeModule : GErrorModule {
if (is_gtypeinstance) {
decl_space.add_type_declaration (new CCodeNewline ());
var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (cl, null));
- decl_space.add_type_declaration (new CCodeMacroReplacement (cl.get_type_id (), macro));
+ 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 (), get_ccode_name (cl));
+ 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 (cl.get_upper_case_cname (null)), macro));
- macro = "(G_TYPE_CHECK_CLASS_CAST ((klass), %s, %sClass))".printf (cl.get_type_id (), get_ccode_name (cl));
+ 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 (cl.get_upper_case_cname (null)), macro));
- macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (cl.get_type_id ());
+ 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_type_check_function (cl)), macro));
- macro = "(G_TYPE_CHECK_CLASS_TYPE ((klass), %s))".printf (cl.get_type_id ());
+ 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_type_check_function (cl)), macro));
- macro = "(G_TYPE_INSTANCE_GET_CLASS ((obj), %s, %sClass))".printf (cl.get_type_id (), get_ccode_name (cl));
+ 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 (cl.get_upper_case_cname (null)), macro));
decl_space.add_type_declaration (new CCodeNewline ());
}
@@ -500,7 +500,7 @@ public class Vala.GTypeModule : GErrorModule {
/* only add the *Private struct if it is not empty, i.e. we actually have private data */
if (cl.has_private_fields || cl.get_type_parameters ().size > 0) {
decl_space.add_type_definition (instance_priv_struct);
- var macro = "(G_TYPE_INSTANCE_GET_PRIVATE ((o), %s, %sPrivate))".printf (cl.get_type_id (), get_ccode_name (cl));
+ 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 (cl.get_upper_case_cname (null)), macro));
}
@@ -509,7 +509,7 @@ 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 (), get_ccode_name (cl));
+ 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 (get_ccode_name (cl), get_ccode_lower_case_name (cl));
}
@@ -913,7 +913,7 @@ public class Vala.GTypeModule : GErrorModule {
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);
@@ -956,7 +956,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_if_fail"));
ccall.add_argument (ccall_typecheck);
@@ -967,7 +967,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);
@@ -1024,7 +1024,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_if_fail"));
ccall.add_argument (ccall_typecheck);
@@ -1036,7 +1036,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);
@@ -1086,7 +1086,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);
@@ -1668,8 +1668,8 @@ public class Vala.GTypeModule : GErrorModule {
} 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;
@@ -1679,7 +1679,7 @@ public class Vala.GTypeModule : GErrorModule {
} 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");
@@ -1699,7 +1699,7 @@ public class Vala.GTypeModule : GErrorModule {
}
} 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"));
@@ -1708,7 +1708,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"));
@@ -1717,7 +1717,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"));
@@ -1726,7 +1726,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"));
@@ -1735,7 +1735,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"));
@@ -1744,7 +1744,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"));
@@ -1753,14 +1753,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"));
@@ -1769,7 +1769,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"));
@@ -1778,7 +1778,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"));
@@ -1787,7 +1787,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"));
@@ -1796,7 +1796,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));
@@ -1805,7 +1805,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");
@@ -1852,15 +1852,15 @@ public class Vala.GTypeModule : GErrorModule {
decl_space.add_type_declaration (new CCodeNewline ());
var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (iface, null));
- decl_space.add_type_declaration (new CCodeMacroReplacement (iface.get_type_id (), macro));
+ 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 (), get_ccode_name (iface));
+ 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 (iface.get_upper_case_cname (null)), macro));
- macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (iface.get_type_id ());
+ 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_type_check_function (iface)), macro));
- macro = "(G_TYPE_INSTANCE_GET_INTERFACE ((obj), %s, %s))".printf (iface.get_type_id (), iface.get_type_cname ());
+ macro = "(G_TYPE_INSTANCE_GET_INTERFACE ((obj), %s, %s))".printf (get_ccode_type_id (iface), iface.get_type_cname ());
decl_space.add_type_declaration (new CCodeMacroReplacement ("%s_GET_INTERFACE(obj)".printf (iface.get_upper_case_cname (null)), macro));
decl_space.add_type_declaration (new CCodeNewline ());
@@ -2088,7 +2088,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));
diff --git a/codegen/valainterfaceregisterfunction.vala b/codegen/valainterfaceregisterfunction.vala
index d52af3f..f2233be 100644
--- a/codegen/valainterfaceregisterfunction.vala
+++ b/codegen/valainterfaceregisterfunction.vala
@@ -85,7 +85,7 @@ public class Vala.InterfaceRegisterFunction : TypeRegisterFunction {
var func = new CCodeFunctionCall (new CCodeIdentifier ("g_type_interface_add_prerequisite"));
func.add_argument (new CCodeIdentifier ("%s_type_id".printf (CCodeBaseModule.get_ccode_lower_case_name (interface_reference))));
- func.add_argument (new CCodeIdentifier (prereq.get_type_id()));
+ func.add_argument (new CCodeIdentifier (get_ccode_type_id (prereq)));
block.add_statement (new CCodeExpressionStatement (func));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]