[vala] codegen: Remove fallback in array length handling
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Remove fallback in array length handling
- Date: Mon, 18 Oct 2010 08:05:12 +0000 (UTC)
commit 34c18af47efebf67d236f45d59417dbac5ebb15a
Author: Jürg Billeter <j bitron ch>
Date: Sun Oct 17 19:16:58 2010 +0200
codegen: Remove fallback in array length handling
codegen/valaccodearraymodule.vala | 26 ++------------------------
codegen/valaccodecontrolflowmodule.vala | 2 ++
codegen/valadbusclientmodule.vala | 2 ++
codegen/valadbusservermodule.vala | 12 ++++++++++++
codegen/valagdbusclientmodule.vala | 2 ++
codegen/valagdbusservermodule.vala | 10 ++++++++++
6 files changed, 30 insertions(+), 24 deletions(-)
---
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index e57793e..4e938f6 100644
--- a/codegen/valaccodearraymodule.vala
+++ b/codegen/valaccodearraymodule.vala
@@ -154,31 +154,9 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
}
}
- bool is_out = false;
-
- if (array_expr is UnaryExpression) {
- var unary_expr = (UnaryExpression) array_expr;
- if (unary_expr.operator == UnaryOperator.OUT || unary_expr.operator == UnaryOperator.REF) {
- is_out = true;
- }
- }
-
List<CCodeExpression> size = get_array_sizes (array_expr);
- if (size != null && size.size >= dim) {
- return size[dim - 1];
- }
-
- if (!is_out) {
- /* allow arrays with unknown length even for value types
- * as else it may be impossible to bind some libraries
- * users of affected libraries should explicitly set
- * the array length as early as possible
- * by setting the virtual length field of the array
- */
- return new CCodeConstant ("-1");
- } else {
- return new CCodeConstant ("NULL");
- }
+ assert (size != null && size.size >= dim);
+ return size[dim - 1];
}
public override string get_array_size_cname (string array_cname) {
diff --git a/codegen/valaccodecontrolflowmodule.vala b/codegen/valaccodecontrolflowmodule.vala
index 46a4b43..c940088 100644
--- a/codegen/valaccodecontrolflowmodule.vala
+++ b/codegen/valaccodecontrolflowmodule.vala
@@ -371,6 +371,8 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
if (requires_destroy (local.variable_type)) {
var ma = new MemberAccess.simple (local.name);
ma.symbol_reference = local;
+ ma.value_type = local.variable_type.copy ();
+ visit_member_access (ma);
ccode.add_expression (get_unref_expression (get_variable_cexpression (local.name), local.variable_type, ma));
}
}
diff --git a/codegen/valadbusclientmodule.vala b/codegen/valadbusclientmodule.vala
index 3e3abe3..1666a7a 100644
--- a/codegen/valadbusclientmodule.vala
+++ b/codegen/valadbusclientmodule.vala
@@ -1581,6 +1581,8 @@ public class Vala.DBusClientModule : DBusModule {
var local = new LocalVariable (owned_type, param.name);
var ma = new MemberAccess.simple (param.name);
ma.symbol_reference = local;
+ ma.value_type = owned_type.copy ();
+ visit_member_access (ma);
var stmt = new CCodeExpressionStatement (get_unref_expression (new CCodeIdentifier (param.name), owned_type, ma));
postfragment.append (stmt);
}
diff --git a/codegen/valadbusservermodule.vala b/codegen/valadbusservermodule.vala
index edf5e5a..9476d51 100644
--- a/codegen/valadbusservermodule.vala
+++ b/codegen/valadbusservermodule.vala
@@ -254,6 +254,8 @@ public class Vala.DBusServerModule : DBusClientModule {
var local = new LocalVariable (owned_type, param.name);
var ma = new MemberAccess.simple (param.name);
ma.symbol_reference = local;
+ ma.value_type = owned_type.copy ();
+ visit_member_access (ma);
var stmt = new CCodeExpressionStatement (get_unref_expression (new CCodeIdentifier (param.name), owned_type, ma));
if (param.direction == ParameterDirection.IN) {
in_postfragment.append (stmt);
@@ -288,6 +290,8 @@ public class Vala.DBusServerModule : DBusClientModule {
var local = new LocalVariable (m.return_type, " result");
var ma = new MemberAccess.simple ("result");
ma.symbol_reference = local;
+ ma.value_type = m.return_type.copy ();
+ visit_member_access (ma);
out_postfragment.append (new CCodeExpressionStatement (get_unref_expression (new CCodeIdentifier ("result"), m.return_type, ma)));
}
@@ -332,6 +336,8 @@ public class Vala.DBusServerModule : DBusClientModule {
var local = new LocalVariable (m.return_type, " result");
var ma = new MemberAccess.simple ("result");
ma.symbol_reference = local;
+ ma.value_type = m.return_type.copy ();
+ visit_member_access (ma);
out_postfragment.append (new CCodeExpressionStatement (get_unref_expression (new CCodeIdentifier ("result"), m.return_type, ma)));
}
}
@@ -824,6 +830,8 @@ public class Vala.DBusServerModule : DBusClientModule {
var local = new LocalVariable (prop.get_accessor.value_type, " result");
var ma = new MemberAccess.simple ("result");
ma.symbol_reference = local;
+ ma.value_type = local.variable_type.copy ();
+ visit_member_access (ma);
postfragment.append (new CCodeExpressionStatement (get_unref_expression (new CCodeIdentifier ("result"), prop.get_accessor.value_type, ma)));
}
@@ -1040,6 +1048,8 @@ public class Vala.DBusServerModule : DBusClientModule {
var local = new LocalVariable (prop.get_accessor.value_type, " result");
var ma = new MemberAccess.simple ("result");
ma.symbol_reference = local;
+ ma.value_type = local.variable_type.copy ();
+ visit_member_access (ma);
postfragment.append (new CCodeExpressionStatement (get_unref_expression (new CCodeIdentifier ("result"), prop.get_accessor.value_type, ma)));
}
@@ -1217,6 +1227,8 @@ public class Vala.DBusServerModule : DBusClientModule {
var local = new LocalVariable (owned_type, "value");
var ma = new MemberAccess.simple ("value");
ma.symbol_reference = local;
+ ma.value_type = local.variable_type.copy ();
+ visit_member_access (ma);
prop_block.add_statement (new CCodeExpressionStatement (get_unref_expression (new CCodeIdentifier ("value"), owned_type, ma)));
}
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index dd35c09..223703a 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -323,6 +323,8 @@ public class Vala.GDBusClientModule : GDBusModule {
var local = new LocalVariable (owned_type, param.name);
var ma = new MemberAccess.simple (param.name);
ma.symbol_reference = local;
+ ma.value_type = local.variable_type.copy ();
+ visit_member_access (ma);
ccode.add_expression (get_unref_expression (new CCodeIdentifier (param.name), owned_type, ma));
}
}
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index bf5fe2c..28acf76 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -242,6 +242,8 @@ public class Vala.GDBusServerModule : GDBusClientModule {
var local = new LocalVariable (m.return_type, " result");
var ma = new MemberAccess.simple ("result");
ma.symbol_reference = local;
+ ma.value_type = local.variable_type.copy ();
+ visit_member_access (ma);
ccode.add_expression (get_unref_expression (new CCodeIdentifier ("result"), m.return_type, ma));
}
} else {
@@ -265,6 +267,8 @@ public class Vala.GDBusServerModule : GDBusClientModule {
var local = new LocalVariable (m.return_type, " result");
var ma = new MemberAccess.simple ("result");
ma.symbol_reference = local;
+ ma.value_type = local.variable_type.copy ();
+ visit_member_access (ma);
ccode.add_expression (get_unref_expression (new CCodeIdentifier ("result"), m.return_type, ma));
}
}
@@ -288,6 +292,8 @@ public class Vala.GDBusServerModule : GDBusClientModule {
var local = new LocalVariable (owned_type, param.name);
var ma = new MemberAccess.simple (param.name);
ma.symbol_reference = local;
+ ma.value_type = local.variable_type.copy ();
+ visit_member_access (ma);
ccode.add_expression (get_unref_expression (new CCodeIdentifier (param.name), owned_type, ma));
}
}
@@ -436,6 +442,8 @@ public class Vala.GDBusServerModule : GDBusClientModule {
var local = new LocalVariable (prop.property_type, " result");
var ma = new MemberAccess.simple ("result");
ma.symbol_reference = local;
+ ma.value_type = local.variable_type.copy ();
+ visit_member_access (ma);
ccode.add_expression (get_unref_expression (new CCodeIdentifier ("result"), prop.property_type, ma));
}
@@ -493,6 +501,8 @@ public class Vala.GDBusServerModule : GDBusClientModule {
var local = new LocalVariable (owned_type, "value");
var ma = new MemberAccess.simple ("value");
ma.symbol_reference = local;
+ ma.value_type = local.variable_type.copy ();
+ visit_member_access (ma);
ccode.add_expression (get_unref_expression (new CCodeIdentifier ("value"), owned_type, ma));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]