]> 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>
Tue, 6 Aug 2019 11:53:59 +0000 (13:53 +0200)
and get_ccode_type_check_function() for SourceFileType.SOURCE symbols.

codegen/valaccodebasemodule.vala
codegen/valagtypemodule.vala

index de16d8fbb680d61f5c684db41b095c2d3d9ae47a..48d706e37de993609934fb607691aaddc222d5e3 100644 (file)
@@ -5597,13 +5597,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 995f81c21142b6fc476d79bc6bac135d0187681f..c9e5dd53cf661b0caaaf95c071ce5b23588a316c 100644 (file)
@@ -2267,8 +2267,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) {