[vala/wip/error-gtype: 2/2] WIP
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/error-gtype: 2/2] WIP
- Date: Tue, 21 Jan 2020 14:21:50 +0000 (UTC)
commit c4b71de9e860a38ccf70d80ffb08419bb66b2373
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 697a2d715..1b5ab58f0 100644
--- a/codegen/valaccodeattribute.vala
+++ b/codegen/valaccodeattribute.vala
@@ -1008,7 +1008,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 932228eb5..9ef9d91cd 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5131,7 +5131,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]