Commit 01918ae7 authored by Christian Hergert's avatar Christian Hergert

gi: handle transfer for some return values

parent 22752351
......@@ -669,6 +669,7 @@ tmpl_expr_gi_call_eval (TmplExprGiCall *node,
GIArgument return_value_arg = { 0 };
GITypeInfo return_value_type;
GIArgument *dispatch_args = NULL;
GITransfer xfer = 0;
TmplExpr *args;
GObject *object;
gboolean ret = FALSE;
......@@ -981,8 +982,9 @@ apply_args:
goto cleanup;
g_callable_info_load_return_type ((GICallableInfo *)function, &return_value_type);
xfer = g_callable_info_get_caller_owns ((GICallableInfo *)function);
if (!tmpl_gi_argument_to_g_value (return_value, &return_value_type, &return_value_arg, error))
if (!tmpl_gi_argument_to_g_value (return_value, &return_value_type, &return_value_arg, xfer, error))
goto cleanup;
ret = TRUE;
......
......@@ -33,6 +33,7 @@ gboolean tmpl_gi_argument_from_g_value (const GValue *value,
gboolean tmpl_gi_argument_to_g_value (GValue *value,
GITypeInfo *type_info,
GIArgument *arg,
GITransfer xfer,
GError **error);
G_END_DECLS
......
......@@ -316,6 +316,7 @@ gboolean
tmpl_gi_argument_to_g_value (GValue *value,
GITypeInfo *type_info,
GIArgument *arg,
GITransfer xfer,
GError **error)
{
GITypeTag tag;
......@@ -395,7 +396,10 @@ tmpl_gi_argument_to_g_value (GValue *value,
case GI_TYPE_TAG_UTF8:
case GI_TYPE_TAG_FILENAME:
g_value_init (value, G_TYPE_STRING);
g_value_set_string (value, arg->v_string);
if (xfer == GI_TRANSFER_NOTHING)
g_value_set_string (value, arg->v_string);
else
g_value_take_string (value, arg->v_string);
return TRUE;
case GI_TYPE_TAG_INTERFACE:
......@@ -408,7 +412,10 @@ tmpl_gi_argument_to_g_value (GValue *value,
case GI_INFO_TYPE_INTERFACE:
case GI_INFO_TYPE_OBJECT:
g_value_init (value, G_TYPE_OBJECT);
g_value_set_object (value, arg->v_pointer);
if (xfer == GI_TRANSFER_NOTHING)
g_value_set_object (value, arg->v_pointer);
else
g_value_take_object (value, arg->v_pointer);
return TRUE;
case GI_INFO_TYPE_FLAGS:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment