[gjs: 3/5] arg-cache: Throw an error when handling unsupported caller-allocates types
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 3/5] arg-cache: Throw an error when handling unsupported caller-allocates types
- Date: Thu, 10 Sep 2020 05:29:56 +0000 (UTC)
commit ddb3730e9436805311d0fdbae9b00cd60c4dffe6
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Mon Sep 7 20:14:51 2020 +0200
arg-cache: Throw an error when handling unsupported caller-allocates types
Previous of commit aa28329b7 we were assuming that all the
caller-allocates function were using an interface tag, that was wrong
but at the same time we don't yet support any other type of
caller-allocats function yet [1], so if we detect one type that we don't
support we should just throw with some valuable error as we used to do and
not just crash.
Otherwise it would be impossible to test a solution for bug [2].
[1] https://gitlab.gnome.org/GNOME/gjs/-/issues/106
[2] https://gitlab.gnome.org/GNOME/gjs/-/issues/344
gi/arg-cache.cpp | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/gi/arg-cache.cpp b/gi/arg-cache.cpp
index 6e193a4b4..d49576ef5 100644
--- a/gi/arg-cache.cpp
+++ b/gi/arg-cache.cpp
@@ -1576,8 +1576,15 @@ bool gjs_arg_cache_build_arg(JSContext* cx, GjsArgumentCache* self,
*inc_counter_out = true;
GITypeTag type_tag = g_type_info_get_tag(&self->type_info);
- if (direction == GI_DIRECTION_OUT && type_tag == GI_TYPE_TAG_INTERFACE &&
- g_arg_info_is_caller_allocates(arg)) {
+ if (direction == GI_DIRECTION_OUT && g_arg_info_is_caller_allocates(arg)) {
+ if (type_tag != GI_TYPE_TAG_INTERFACE) {
+ gjs_throw(cx,
+ "Unsupported type %s for argument %s with (out "
+ "caller-allocates)",
+ g_type_tag_to_string(type_tag), self->arg_name);
+ return false;
+ }
+
GjsAutoBaseInfo interface_info =
g_type_info_get_interface(&self->type_info);
g_assert(interface_info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]