[glib/wip/otte/interface-types: 438/448] closure: Support generic marshals for interface returns
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/otte/interface-types: 438/448] closure: Support generic marshals for interface returns
- Date: Sat, 24 Oct 2020 03:35:48 +0000 (UTC)
commit 07c00cae48bd3724cf15bd5b00e2737d91d60694
Author: Benjamin Otte <otte redhat com>
Date: Mon Nov 25 19:56:47 2019 +0100
closure: Support generic marshals for interface returns
Use the newly added g_type_interface_instantiable_prerequisite() to
allow closure return values being interfaces by looking up the
instantiable type for the interface and using its GValue accessors.
gobject/gclosure.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/gobject/gclosure.c b/gobject/gclosure.c
index 7caf9c4e6..b4edc1755 100644
--- a/gobject/gclosure.c
+++ b/gobject/gclosure.c
@@ -1258,8 +1258,12 @@ static void
value_from_ffi_type (GValue *gvalue, gpointer *value)
{
ffi_arg *int_val = (ffi_arg*) value;
+ GType type;
- switch (g_type_fundamental (G_VALUE_TYPE (gvalue)))
+ type = G_VALUE_TYPE (gvalue);
+
+restart:
+ switch (g_type_fundamental (type))
{
case G_TYPE_INT:
g_value_set_int (gvalue, (gint) *int_val);
@@ -1318,9 +1322,15 @@ value_from_ffi_type (GValue *gvalue, gpointer *value)
case G_TYPE_VARIANT:
g_value_take_variant (gvalue, *(gpointer*)value);
break;
+ case G_TYPE_INTERFACE:
+ type = g_type_interface_instantiable_prerequisite (G_VALUE_TYPE (gvalue));
+ if (type)
+ goto restart;
+ G_GNUC_FALLTHROUGH;
default:
- g_warning ("value_from_ffi_type: Unsupported fundamental type: %s",
- g_type_name (g_type_fundamental (G_VALUE_TYPE (gvalue))));
+ g_warning ("value_from_ffi_type: Unsupported fundamental type %s for type %s",
+ g_type_name (g_type_fundamental (G_VALUE_TYPE (gvalue))),
+ g_type_name (G_VALUE_TYPE (gvalue)));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]