]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Always use G_TYPE_CHECK_INSTANCE_TYPE for external symbols
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 12 May 2019 18:59:15 +0000 (20:59 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 13 May 2019 06:08:10 +0000 (08:08 +0200)
and get_ccode_type_check_function() for SourceFileType.SOURCE symbols.

codegen/valaccodebasemodule.vala
codegen/valagtypemodule.vala

index 17091394ff61c1374bee680a76500bb617a1e6b3..b623a20608f6d8cd43b256f129c2d579ed6bbc54 100644 (file)
@@ -5670,13 +5670,20 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        var type_domain = new CCodeIdentifier (get_ccode_upper_case_name (et.error_domain));
                        return new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, instance_domain, type_domain);
                } else {
-                       var type_id = get_type_id_expression (type);
-                       if (type_id == null) {
-                               return new CCodeInvalidExpression ();
+                       CCodeFunctionCall ccheck;
+                       if (type.data_type == null || type.data_type.external_package) {
+                               var type_id = get_type_id_expression (type);
+                               if (type_id == null) {
+                                       return new CCodeInvalidExpression ();
+                               }
+                               ccheck = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_CHECK_INSTANCE_TYPE"));
+                               ccheck.add_argument ((CCodeExpression) ccodenode);
+                               ccheck.add_argument (type_id);
+                       } else {
+                               ccheck = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_check_function (type.data_type)));
+                               ccheck.add_argument ((CCodeExpression) ccodenode);
                        }
-                       var ccheck = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_CHECK_INSTANCE_TYPE"));
-                       ccheck.add_argument ((CCodeExpression) ccodenode);
-                       ccheck.add_argument (type_id);
+
                        return ccheck;
                }
        }
index 119437cbe7a5c7ca806facbaa3a6fd499eae02d6..4c926dc0e57f2ff39a4aadbb51a563f2a421b392 100644 (file)
@@ -2424,8 +2424,19 @@ public class Vala.GTypeModule : GErrorModule {
                if (!context.assert) {
                        return;
                } else if (context.checking && ((t is Class && !((Class) t).is_compact) || t is Interface)) {
-                       var ctype_check = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_check_function (t)));
-                       ctype_check.add_argument (new CCodeIdentifier (var_name));
+                       if (!get_ccode_has_type_id (t)) {
+                               return;
+                       }
+
+                       CCodeFunctionCall ctype_check;
+                       if (t.external_package) {
+                               ctype_check = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_CHECK_INSTANCE_TYPE"));
+                               ctype_check.add_argument (new CCodeIdentifier (var_name));
+                               ctype_check.add_argument (new CCodeIdentifier (get_ccode_type_id (t)));
+                       } else {
+                               ctype_check = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_check_function (t)));
+                               ctype_check.add_argument (new CCodeIdentifier (var_name));
+                       }
 
                        CCodeExpression cexpr = ctype_check;
                        if (!non_null) {