]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Use type-check to determine a GenericType
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 6 Dec 2017 16:14:34 +0000 (17:14 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 6 Dec 2017 16:39:50 +0000 (17:39 +0100)
codegen/valaccodeattribute.vala
codegen/valaccodebasemodule.vala
codegen/valagsignalmodule.vala
vala/valaarraytype.vala
vala/valaerrortype.vala
vala/valanulltype.vala
vala/valapointertype.vala

index 3f12ff5f833e26ea52c64e8a91a37e1cd7ec3b53..79a6933d0c83f5b391a8120ecd14d956bbbc0b97 100644 (file)
@@ -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";
index 439c54e72d411e5479d98019a85f39cc9e6c9258..f35645ab4e9301d11297f2330c8f1883b86e6fbb 100644 (file)
@@ -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");
index 5e3424531f6556246cc91150f0153f8b06c7381d..15a18cb7b0a20c78e8adf741cb9387938054e677 100644 (file)
@@ -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"));
index 0acd0dfbf52df3e46523c79209f2a75673cb8de2..f1ecd7b6810b420959764b4189e2dea084c2edb5 100644 (file)
@@ -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;
                }
 
index c7c9f9348fd31524c53625c1716b9f96c4c04e64..7a7946643e8986a95f976b03f6c1741456136d7f 100644 (file)
@@ -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;
                }
 
index 19d110984d7a7ffbc8257f6259bdf8ce830ddf38..c827914473fbf736d8d7ae5cac0587609efadaed 100644 (file)
@@ -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) {
index e3437f62e8ddd53215bf645210660b73ee5c537a..9cfe6ea42c5f9ff65fc5914a2d2c0f4583b35ef6 100644 (file)
@@ -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;
                }