[vala/staging] codegen: Always use G_TYPE_CHECK_INSTANCE_TYPE for external symbols



commit 14ea9335179db8923e618bd15f404c023e04a58e
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun May 12 20:59:15 2019 +0200

    codegen: Always use G_TYPE_CHECK_INSTANCE_TYPE for external symbols
    
    and get_ccode_type_check_function() for SourceFileType.SOURCE symbols.

 codegen/valaccodebasemodule.vala | 19 +++++++++++++------
 codegen/valagtypemodule.vala     | 15 +++++++++++++--
 2 files changed, 26 insertions(+), 8 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 17091394f..b623a2060 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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;
                }
        }
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 119437cbe..4c926dc0e 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -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) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]