[vala/wip/error-gtype: 10/11] WIP
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/error-gtype: 10/11] WIP
- Date: Thu, 24 Feb 2022 14:28:53 +0000 (UTC)
commit d9c06f7c09a5f89add9533b9c28ee4e6053d7b05
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Oct 15 12:48:13 2019 +0200
WIP
codegen/valaccodeattribute.vala | 2 +-
codegen/valaccodebasemodule.vala | 21 ++++++++++++++++++++-
2 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodeattribute.vala b/codegen/valaccodeattribute.vala
index ffb963772..74ddbd663 100644
--- a/codegen/valaccodeattribute.vala
+++ b/codegen/valaccodeattribute.vala
@@ -1078,7 +1078,7 @@ public class Vala.CCodeAttribute : AttributeCache {
if (get_ccode_has_type_id (edomain)) {
return get_ccode_upper_case_name (edomain, "TYPE_");
} else {
- return "G_TYPE_INT";
+ return "G_TYPE_ERROR";
}
} else {
return "G_TYPE_POINTER";
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 65a6df560..1e90f9d69 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5438,7 +5438,26 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public override void visit_typeof_expression (TypeofExpression expr) {
cfile.add_include ("glib-object.h");
- set_cvalue (expr, get_type_id_expression (expr.type_reference));
+ CCodeExpression type_id_expression;
+ if (expr.type_reference is ErrorType) {
+ unowned ErrorType error_type = expr.type_reference as ErrorType;
+ string type_id;
+ if (error_type.error_domain != null && get_ccode_has_type_id
(error_type.error_domain)) {
+ type_id = get_ccode_type_id (error_type);
+ if (type_id == "") {
+ type_id = "G_TYPE_INVALID";
+ } else {
+ generate_type_declaration (error_type, cfile);
+ }
+ } else {
+ type_id = "G_TYPE_ERROR";
+ }
+ type_id_expression = new CCodeIdentifier (type_id);
+ } else {
+ type_id_expression = get_type_id_expression (expr.type_reference);
+ }
+
+ set_cvalue (expr, type_id_expression);
}
public override void visit_unary_expression (UnaryExpression expr) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]