[vala/0.36] codegen: Always use G_TYPE_CHECK_INSTANCE_TYPE for external symbols
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.36] codegen: Always use G_TYPE_CHECK_INSTANCE_TYPE for external symbols
- Date: Tue, 13 Aug 2019 15:21:14 +0000 (UTC)
commit be3cf0322d407a96bdcce3a267b218ebeea14c15
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 de16d8fbb..48d706e37 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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;
}
}
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 995f81c21..c9e5dd53c 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]