[vala] Replace Vala.InstanceCast class by method
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Replace Vala.InstanceCast class by method
- Date: Sat, 15 Aug 2009 14:41:57 +0000 (UTC)
commit 18c63006bd24706b0d03d0f1f4c383810eab9423
Author: Jürg Billeter <j bitron ch>
Date: Sat Aug 15 16:40:48 2009 +0200
Replace Vala.InstanceCast class by method
codegen/valaccodebasemodule.vala | 18 ++++++++----
codegen/valagobjectmodule.vala | 6 ++--
codegen/valagtypemodule.vala | 2 +-
vala/Makefile.am | 1 -
vala/valainstancecast.vala | 56 --------------------------------------
5 files changed, 16 insertions(+), 67 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 6005a64..10237f7 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2589,7 +2589,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
if (inner_node == null) {
l = new CCodeIdentifier ("self");
} else if (stmt.resource.symbol_reference.parent_symbol != current_type_symbol) {
- l = new InstanceCast ((CCodeExpression) inner_node.ccodenode, parent);
+ l = generate_instance_cast ((CCodeExpression) inner_node.ccodenode, parent);
} else {
l = (CCodeExpression) inner_node.ccodenode;
}
@@ -2714,7 +2714,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
}
public override void visit_base_access (BaseAccess expr) {
- expr.ccodenode = new InstanceCast (new CCodeIdentifier ("self"), expr.value_type.data_type);
+ expr.ccodenode = generate_instance_cast (new CCodeIdentifier ("self"), expr.value_type.data_type);
}
public override void visit_postfix_expression (PostfixExpression expr) {
@@ -3433,7 +3433,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
expr.ccodenode = ccomma;
} else {
- expr.ccodenode = new InstanceCast ((CCodeExpression) expr.inner.ccodenode, expr.type_reference.data_type);
+ expr.ccodenode = generate_instance_cast ((CCodeExpression) expr.inner.ccodenode, expr.type_reference.data_type);
}
} else {
if (expr.is_silent_cast) {
@@ -3539,9 +3539,9 @@ internal class Vala.CCodeBaseModule : CCodeModule {
if (left_cl != right_cl) {
if (left_cl.is_subtype_of (right_cl)) {
- cleft = new InstanceCast (cleft, right_cl);
+ cleft = generate_instance_cast (cleft, right_cl);
} else if (right_cl.is_subtype_of (left_cl)) {
- cright = new InstanceCast (cright, left_cl);
+ cright = generate_instance_cast (cright, left_cl);
}
}
} else if (left_type_as_struct != null && right_type_as_struct != null) {
@@ -3860,7 +3860,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
var iface = target_type.data_type as Interface;
if (context.checking && (iface != null || (cl != null && !cl.is_compact))) {
// checked cast for strict subtypes of GTypeInstance
- return new InstanceCast (cexpr, target_type.data_type);
+ return generate_instance_cast (cexpr, target_type.data_type);
} else if (target_type.data_type != null && expression_type.get_cname () != target_type.get_cname ()) {
var st = target_type.data_type as Struct;
if (target_type.data_type.is_reference_type () || (st != null && st.is_simple_type ())) {
@@ -4155,6 +4155,12 @@ internal class Vala.CCodeBaseModule : CCodeModule {
}
return null;
}
+
+ public CCodeFunctionCall generate_instance_cast (CCodeExpression expr, TypeSymbol type) {
+ var result = new CCodeFunctionCall (new CCodeIdentifier (type.get_upper_case_cname (null)));
+ result.add_argument (expr);
+ return result;
+ }
}
// vim:sw=8 noet
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index ba0ad1f..3f709fd 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -184,7 +184,7 @@ internal class Vala.GObjectModule : GTypeModule {
var block = new CCodeBlock ();
- CCodeFunctionCall ccall = new InstanceCast (new CCodeIdentifier ("object"), cl);
+ CCodeFunctionCall ccall = generate_instance_cast (new CCodeIdentifier ("object"), cl);
var cdecl = new CCodeDeclaration ("%s *".printf (cl.get_cname ()));
cdecl.add_declarator (new CCodeVariableDeclarator ("self", ccall));
block.add_statement (cdecl);
@@ -264,7 +264,7 @@ internal class Vala.GObjectModule : GTypeModule {
var block = new CCodeBlock ();
- CCodeFunctionCall ccall = new InstanceCast (new CCodeIdentifier ("object"), cl);
+ CCodeFunctionCall ccall = generate_instance_cast (new CCodeIdentifier ("object"), cl);
var cdecl = new CCodeDeclaration ("%s *".printf (cl.get_cname ()));
cdecl.add_declarator (new CCodeVariableDeclarator ("self", ccall));
block.add_statement (cdecl);
@@ -461,7 +461,7 @@ internal class Vala.GObjectModule : GTypeModule {
cblock.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("obj"), ccall)));
- ccall = new InstanceCast (new CCodeIdentifier ("obj"), cl);
+ ccall = generate_instance_cast (new CCodeIdentifier ("obj"), cl);
cdecl = new CCodeDeclaration ("%s *".printf (cl.get_cname ()));
cdecl.add_declarator (new CCodeVariableDeclarator ("self", ccall));
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 29dc0e0..a26ce66 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -1469,7 +1469,7 @@ internal class Vala.GTypeModule : GErrorModule {
var cblock = new CCodeBlock ();
- CCodeFunctionCall ccall = new InstanceCast (new CCodeIdentifier ("obj"), cl);
+ CCodeFunctionCall ccall = generate_instance_cast (new CCodeIdentifier ("obj"), cl);
var cdecl = new CCodeDeclaration ("%s *".printf (cl.get_cname ()));
cdecl.add_declarator (new CCodeVariableDeclarator ("self", ccall));
diff --git a/vala/Makefile.am b/vala/Makefile.am
index 157fa25..31b2845 100644
--- a/vala/Makefile.am
+++ b/vala/Makefile.am
@@ -78,7 +78,6 @@ libvalacore_la_VALASOURCES = \
valagenietokentype.vala \
valaifstatement.vala \
valainitializerlist.vala \
- valainstancecast.vala \
valaintegerliteral.vala \
valaintegertype.vala \
valainterface.vala \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]