[vala/staging] Use type-check to determine a GenericType
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] Use type-check to determine a GenericType
- Date: Wed, 6 Dec 2017 17:42:31 +0000 (UTC)
commit 3fe3f8b7e7e5a1c6e3adf5ad0fa6ace2719b6339
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Dec 6 17:14:34 2017 +0100
Use type-check to determine a GenericType
codegen/valaccodeattribute.vala | 2 +-
codegen/valaccodebasemodule.vala | 16 ++++++++--------
codegen/valagsignalmodule.vala | 10 +++++-----
vala/valaarraytype.vala | 2 +-
vala/valaerrortype.vala | 2 +-
vala/valanulltype.vala | 4 ++--
vala/valapointertype.vala | 2 +-
7 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/codegen/valaccodeattribute.vala b/codegen/valaccodeattribute.vala
index 3f12ff5..79a6933 100644
--- a/codegen/valaccodeattribute.vala
+++ b/codegen/valaccodeattribute.vala
@@ -991,7 +991,7 @@ public class Vala.CCodeAttribute : AttributeCache {
}
} else if (node is ValueType && ((ValueType) node).nullable) {
return "POINTER";
- } else if (node is PointerType || ((DataType) node).type_parameter != null) {
+ } else if (node is PointerType || node is GenericType) {
return "POINTER";
} else if (node is ErrorType) {
return "POINTER";
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 439c54e..f35645a 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2678,7 +2678,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
return new CCodeIdentifier (dup_function);
- } else if (type.type_parameter != null) {
+ } else if (type is GenericType) {
string func_name = "%s_dup_func".printf (type.type_parameter.name.down ());
if (type.type_parameter.parent_symbol is Interface) {
@@ -3176,7 +3176,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return new CCodeConstant ("NULL");
}
return new CCodeIdentifier (unref_function);
- } else if (type.type_parameter != null) {
+ } else if (type is GenericType) {
string func_name = "%s_destroy_func".printf (type.type_parameter.name.down ());
if (type.type_parameter.parent_symbol is Interface) {
@@ -3382,7 +3382,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
*/
var cisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, cvar, new
CCodeConstant ("NULL"));
- if (type.type_parameter != null) {
+ if (type is GenericType) {
var parent = type.type_parameter.parent_symbol;
var cl = parent as Class;
if ((!(parent is Method) && !(parent is ObjectTypeSymbol)) || (cl != null &&
cl.is_compact)) {
@@ -4118,7 +4118,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return false;
}
- if (type.type_parameter != null) {
+ if (type is GenericType) {
if (is_limited_generic_type (type)) {
return false;
}
@@ -4144,7 +4144,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return false;
}
- if (type.type_parameter != null) {
+ if (type is GenericType) {
if (is_limited_generic_type (type)) {
return false;
}
@@ -4287,13 +4287,13 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return store_temp_value (new GLibValue (type, ccall), node);
} else {
var cnotnull = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, cexpr, new
CCodeConstant ("NULL"));
- if (type.type_parameter != null) {
+ if (type is GenericType) {
// dup functions are optional for type parameters
var cdupnotnull = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY,
get_dup_func_expression (type, node.source_reference), new CCodeConstant ("NULL"));
cnotnull = new CCodeBinaryExpression (CCodeBinaryOperator.AND, cnotnull,
cdupnotnull);
}
- if (type.type_parameter != null) {
+ if (type is GenericType) {
// cast from gconstpointer to gpointer as GBoxedCopyFunc expects gpointer
ccall.add_argument (new CCodeCastExpression (cexpr, "gpointer"));
} else {
@@ -6054,7 +6054,7 @@ 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.type_parameter != null) {
+ } else if (type is GenericType) {
return new CCodeConstant ("NULL");
} else if (type is ErrorType) {
return new CCodeConstant ("NULL");
diff --git a/codegen/valagsignalmodule.vala b/codegen/valagsignalmodule.vala
index 5e34245..15a18cb 100644
--- a/codegen/valagsignalmodule.vala
+++ b/codegen/valagsignalmodule.vala
@@ -50,7 +50,7 @@ public class Vala.GSignalModule : GObjectModule {
}
private string? get_value_type_name_from_type_reference (DataType t) {
- if (t is PointerType || t.type_parameter != null) {
+ if (t is PointerType || t is GenericType) {
return "gpointer";
} else if (t is VoidType) {
return "void";
@@ -281,7 +281,7 @@ public class Vala.GSignalModule : GObjectModule {
} else {
get_value_function = "g_value_get_pointer";
}
- } else if (p.variable_type is PointerType || p.variable_type.type_parameter != null) {
+ } else if (p.variable_type is PointerType || p.variable_type is GenericType) {
get_value_function = "g_value_get_pointer";
} else if (p.variable_type is ErrorType) {
get_value_function = "g_value_get_pointer";
@@ -315,7 +315,7 @@ public class Vala.GSignalModule : GObjectModule {
} else {
set_fc = new CCodeFunctionCall (new CCodeIdentifier
("g_value_set_pointer"));
}
- } else if (return_type.type_parameter != null) {
+ } else if (return_type is GenericType) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_set_pointer"));
} else if (return_type is ErrorType) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_set_pointer"));
@@ -400,7 +400,7 @@ public class Vala.GSignalModule : GObjectModule {
csignew.add_argument (marshal_arg);
var params = sig.get_parameters ();
- if (sig.return_type is PointerType || sig.return_type.type_parameter != null) {
+ if (sig.return_type is PointerType || sig.return_type is GenericType) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
} else if (sig.return_type is ErrorType) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
@@ -431,7 +431,7 @@ public class Vala.GSignalModule : GObjectModule {
for (var i = 0; i < ((ArrayType) param.variable_type).rank; i++) {
csignew.add_argument (new CCodeConstant ("G_TYPE_INT"));
}
- } else if (param.variable_type is PointerType || param.variable_type.type_parameter
!= null || param.direction != ParameterDirection.IN) {
+ } else if (param.variable_type is PointerType || param.variable_type is GenericType
|| param.direction != ParameterDirection.IN) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
} else if (param.variable_type is ErrorType) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala
index 0acd0df..f1ecd7b 100644
--- a/vala/valaarraytype.vala
+++ b/vala/valaarraytype.vala
@@ -212,7 +212,7 @@ public class Vala.ArrayType : ReferenceType {
}
/* temporarily ignore type parameters */
- if (target_type.type_parameter != null) {
+ if (target_type is GenericType) {
return true;
}
diff --git a/vala/valaerrortype.vala b/vala/valaerrortype.vala
index c7c9f93..7a79466 100644
--- a/vala/valaerrortype.vala
+++ b/vala/valaerrortype.vala
@@ -48,7 +48,7 @@ public class Vala.ErrorType : ReferenceType {
public override bool compatible (DataType target_type) {
/* temporarily ignore type parameters */
- if (target_type.type_parameter != null) {
+ if (target_type is GenericType) {
return true;
}
diff --git a/vala/valanulltype.vala b/vala/valanulltype.vala
index 19d1109..c827914 100644
--- a/vala/valanulltype.vala
+++ b/vala/valanulltype.vala
@@ -36,12 +36,12 @@ public class Vala.NullType : ReferenceType {
return target_type.nullable;
}
- if (!(target_type is PointerType) && (target_type is NullType || (target_type.data_type ==
null && target_type.type_parameter == null))) {
+ if (!(target_type is PointerType) && (target_type is NullType || (target_type.data_type ==
null && !(target_type is GenericType)))) {
return true;
}
/* null can be cast to any reference or array type or pointer type */
- if (target_type.type_parameter != null ||
+ if (target_type is GenericType ||
target_type is PointerType ||
target_type.nullable ||
target_type.data_type.get_attribute ("PointerType") != null) {
diff --git a/vala/valapointertype.vala b/vala/valapointertype.vala
index e3437f6..9cfe6ea 100644
--- a/vala/valapointertype.vala
+++ b/vala/valapointertype.vala
@@ -74,7 +74,7 @@ public class Vala.PointerType : DataType {
}
/* temporarily ignore type parameters */
- if (target_type.type_parameter != null) {
+ if (target_type is GenericType) {
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]