[vala] vala: Drop DataType.is_array() and use usual type check as anywhere else
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] vala: Drop DataType.is_array() and use usual type check as anywhere else
- Date: Wed, 31 Oct 2018 14:52:11 +0000 (UTC)
commit b85093705878261f7c916f0db713d2783c23e64e
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Oct 31 15:27:36 2018 +0100
vala: Drop DataType.is_array() and use usual type check as anywhere else
codegen/valaccodebasemodule.vala | 2 +-
codegen/valagsignalmodule.vala | 17 ++++++++---------
vala/valaarraytype.vala | 4 ----
vala/valadatatype.vala | 4 ----
vala/valaforeachstatement.vala | 2 +-
5 files changed, 10 insertions(+), 19 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index e37042044..45fb7975f 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1912,7 +1912,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
// note: implicit copy of array is planned to be forbidden
var cl = type.data_type as Class;
return (type is DelegateType ||
- type.is_array () ||
+ type is ArrayType ||
(cl != null && !cl.is_immutable && !is_reference_counting (cl) &&
!get_ccode_is_gboxed (cl)));
}
diff --git a/codegen/valagsignalmodule.vala b/codegen/valagsignalmodule.vala
index 439d181e9..0c23ab21b 100644
--- a/codegen/valagsignalmodule.vala
+++ b/codegen/valagsignalmodule.vala
@@ -192,7 +192,7 @@ public class Vala.GSignalModule : GObjectModule {
foreach (Parameter p in params) {
callback_decl.add_parameter (new CCodeParameter ("arg_%d".printf (n_params),
get_value_type_name_from_parameter (p)));
n_params++;
- if (p.variable_type.is_array ()) {
+ if (p.variable_type is ArrayType) {
for (var j = 0; j < ((ArrayType) p.variable_type).rank; j++) {
callback_decl.add_parameter (new CCodeParameter ("arg_%d".printf
(n_params), "gint"));
n_params++;
@@ -211,7 +211,7 @@ public class Vala.GSignalModule : GObjectModule {
CCodeFunctionCall fc;
- if (return_type.data_type != null || return_type.is_array ()) {
+ if (return_type.data_type != null || return_type is ArrayType) {
ccode.add_declaration (get_value_type_name_from_type_reference (return_type), new
CCodeVariableDeclarator ("v_return"));
fc = new CCodeFunctionCall (new CCodeIdentifier ("g_return_if_fail"));
@@ -243,10 +243,9 @@ public class Vala.GSignalModule : GObjectModule {
i = 1;
foreach (Parameter p in params) {
string get_value_function;
- bool is_array = p.variable_type.is_array ();
if (p.direction != ParameterDirection.IN) {
get_value_function = "g_value_get_pointer";
- } else if (is_array) {
+ } else if (p.variable_type is ArrayType) {
if (((ArrayType) p.variable_type).element_type.data_type ==
string_type.data_type) {
get_value_function = "g_value_get_boxed";
} else {
@@ -265,7 +264,7 @@ public class Vala.GSignalModule : GObjectModule {
inner_fc.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new
CCodeIdentifier ("param_values"), new CCodeIdentifier (i.to_string ())));
fc.add_argument (inner_fc);
i++;
- if (is_array) {
+ if (p.variable_type is ArrayType) {
for (var j = 0; j < ((ArrayType) p.variable_type).rank; j++) {
inner_fc = new CCodeFunctionCall (new CCodeIdentifier
("g_value_get_int"));
inner_fc.add_argument (new CCodeBinaryExpression
(CCodeBinaryOperator.PLUS, new CCodeIdentifier ("param_values"), new CCodeIdentifier (i.to_string ())));
@@ -276,11 +275,11 @@ public class Vala.GSignalModule : GObjectModule {
}
fc.add_argument (new CCodeIdentifier ("data2"));
- if (return_type.data_type != null || return_type.is_array ()) {
+ if (return_type.data_type != null || return_type is ArrayType) {
ccode.add_assignment (new CCodeIdentifier ("v_return"), fc);
CCodeFunctionCall set_fc;
- if (return_type.is_array ()) {
+ if (return_type is ArrayType) {
if (((ArrayType) return_type).element_type.data_type ==
string_type.data_type) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier
("g_value_take_boxed"));
} else {
@@ -386,14 +385,14 @@ public class Vala.GSignalModule : GObjectModule {
int params_len = 0;
foreach (Parameter param in params) {
params_len++;
- if (param.variable_type.is_array ()) {
+ if (param.variable_type is ArrayType) {
params_len += ((ArrayType) param.variable_type).rank;
}
}
csignew.add_argument (new CCodeConstant ("%d".printf (params_len)));
foreach (Parameter param in params) {
- if (param.variable_type.is_array ()) {
+ if (param.variable_type is ArrayType) {
if (((ArrayType) param.variable_type).element_type.data_type ==
string_type.data_type) {
csignew.add_argument (new CCodeConstant ("G_TYPE_STRV"));
} else {
diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala
index c1d4d7f29..e6987f043 100644
--- a/vala/valaarraytype.vala
+++ b/vala/valaarraytype.vala
@@ -176,10 +176,6 @@ public class Vala.ArrayType : ReferenceType {
return result;
}
- public override bool is_array () {
- return true;
- }
-
public override string to_qualified_string (Scope? scope) {
var elem_str = element_type.to_qualified_string (scope);
if (element_type.is_weak () && !(parent_node is Constant)) {
diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala
index 6d4876344..ce8a49610 100644
--- a/vala/valadatatype.vala
+++ b/vala/valadatatype.vala
@@ -378,10 +378,6 @@ public abstract class Vala.DataType : CodeNode {
this is GenericType;
}
- public virtual bool is_array () {
- return false;
- }
-
// check whether this type is at least as accessible as the specified symbol
public virtual bool is_accessible (Symbol sym) {
foreach (var type_arg in get_type_arguments ()) {
diff --git a/vala/valaforeachstatement.vala b/vala/valaforeachstatement.vala
index d0e35485d..67063bbe1 100644
--- a/vala/valaforeachstatement.vala
+++ b/vala/valaforeachstatement.vala
@@ -168,7 +168,7 @@ public class Vala.ForeachStatement : Block {
var collection_type = collection.value_type.copy ();
collection.target_type = collection_type.copy ();
- if (collection_type.is_array ()) {
+ if (collection_type is ArrayType) {
var array_type = (ArrayType) collection_type;
// can't use inline-allocated array for temporary variable
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]