2012-02-03 19:42:56 +01:00
|
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
|
|
|
|
* GObject introspection: Virtual Function implementation
|
2010-06-07 00:52:12 +02:00
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2005 Matthias Clasen
|
|
|
|
|
* Copyright (C) 2008,2009 Red Hat, Inc.
|
|
|
|
|
*
|
2023-10-25 18:10:10 +02:00
|
|
|
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
|
*
|
2010-06-07 00:52:12 +02:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
2014-07-04 12:27:41 +02:00
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2010-06-07 00:52:12 +02:00
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
2023-10-25 18:45:42 +02:00
|
|
|
|
#include <girepository/girepository.h>
|
2023-11-28 18:24:20 +01:00
|
|
|
|
#include "gibaseinfo-private.h"
|
2010-06-07 00:52:12 +02:00
|
|
|
|
#include "girepository-private.h"
|
|
|
|
|
#include "gitypelib-internal.h"
|
2023-10-25 19:11:38 +02:00
|
|
|
|
#include "givfuncinfo.h"
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2010-06-11 16:11:01 +02:00
|
|
|
|
/**
|
2023-11-09 00:36:19 +01:00
|
|
|
|
* GIVFuncInfo:
|
2010-06-11 16:11:01 +02:00
|
|
|
|
*
|
2023-12-13 14:26:20 +01:00
|
|
|
|
* `GIVFuncInfo` represents a virtual function.
|
2010-06-12 01:16:00 +02:00
|
|
|
|
*
|
2022-02-13 15:20:51 +01:00
|
|
|
|
* A virtual function is a callable object that belongs to either a
|
2023-11-28 18:24:20 +01:00
|
|
|
|
* [type@GIRepository.ObjectInfo] or a [type@GIRepository.InterfaceInfo].
|
2023-11-09 00:36:19 +01:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.80
|
2010-06-11 16:11:01 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIVFuncInfo *
|
2023-11-08 16:23:31 +01:00
|
|
|
|
gi_base_info_find_vfunc (GIRealInfo *rinfo,
|
2024-01-15 22:20:02 +01:00
|
|
|
|
uint32_t offset,
|
2024-01-16 01:57:09 +01:00
|
|
|
|
uint16_t n_vfuncs,
|
2024-01-15 20:20:47 +01:00
|
|
|
|
const char *name)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
/* FIXME hash */
|
|
|
|
|
Header *header = (Header *)rinfo->typelib->data;
|
|
|
|
|
|
2024-01-16 01:57:09 +01:00
|
|
|
|
for (uint16_t i = 0; i < n_vfuncs; i++)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
VFuncBlob *fblob = (VFuncBlob *)&rinfo->typelib->data[offset];
|
2024-01-15 20:20:47 +01:00
|
|
|
|
const char *fname = (const char *)&rinfo->typelib->data[fblob->name];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
|
|
if (strcmp (name, fname) == 0)
|
2024-02-08 11:34:40 +01:00
|
|
|
|
return (GIVFuncInfo *) gi_base_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*) rinfo,
|
|
|
|
|
rinfo->typelib, offset);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
|
|
offset += header->vfunc_blob_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-11 16:11:01 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_vfunc_info_get_flags:
|
2010-06-11 16:11:01 +02:00
|
|
|
|
* @info: a #GIVFuncInfo
|
|
|
|
|
*
|
2023-11-09 00:36:19 +01:00
|
|
|
|
* Obtain the flags for this virtual function info.
|
|
|
|
|
*
|
|
|
|
|
* See [flags@GIRepository.VFuncInfoFlags] for more information about possible
|
|
|
|
|
* flag values.
|
2010-06-11 16:11:01 +02:00
|
|
|
|
*
|
|
|
|
|
* Returns: the flags
|
2023-11-09 00:36:19 +01:00
|
|
|
|
* Since: 2.80
|
2010-06-11 16:11:01 +02:00
|
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIVFuncInfoFlags
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_vfunc_info_get_flags (GIVFuncInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIVFuncInfoFlags flags;
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-11 16:11:01 +02:00
|
|
|
|
VFuncBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
|
g_return_val_if_fail (GI_IS_VFUNC_INFO (info), 0);
|
|
|
|
|
|
|
|
|
|
blob = (VFuncBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
|
|
flags = 0;
|
|
|
|
|
|
|
|
|
|
if (blob->must_chain_up)
|
|
|
|
|
flags = flags | GI_VFUNC_MUST_CHAIN_UP;
|
|
|
|
|
|
|
|
|
|
if (blob->must_be_implemented)
|
|
|
|
|
flags = flags | GI_VFUNC_MUST_OVERRIDE;
|
|
|
|
|
|
|
|
|
|
if (blob->must_not_be_implemented)
|
|
|
|
|
flags = flags | GI_VFUNC_MUST_NOT_OVERRIDE;
|
|
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-11 16:11:01 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_vfunc_info_get_offset:
|
2010-06-11 16:11:01 +02:00
|
|
|
|
* @info: a #GIVFuncInfo
|
|
|
|
|
*
|
2023-12-13 14:26:20 +01:00
|
|
|
|
* Obtain the offset of the function pointer in the class struct.
|
|
|
|
|
*
|
|
|
|
|
* The value `0xFFFF` indicates that the struct offset is unknown.
|
2010-06-11 16:11:01 +02:00
|
|
|
|
*
|
2023-11-09 00:36:19 +01:00
|
|
|
|
* Returns: the struct offset or `0xFFFF` if it’s unknown
|
|
|
|
|
* Since: 2.80
|
2010-06-11 16:11:01 +02:00
|
|
|
|
*/
|
2024-01-16 01:00:07 +01:00
|
|
|
|
size_t
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_vfunc_info_get_offset (GIVFuncInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-11 16:11:01 +02:00
|
|
|
|
VFuncBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
|
g_return_val_if_fail (GI_IS_VFUNC_INFO (info), 0);
|
|
|
|
|
|
|
|
|
|
blob = (VFuncBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
|
|
return blob->struct_offset;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-11 16:11:01 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_vfunc_info_get_signal:
|
2010-06-11 16:11:01 +02:00
|
|
|
|
* @info: a #GIVFuncInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain the signal for the virtual function if one is set.
|
2023-11-09 00:36:19 +01:00
|
|
|
|
*
|
2010-06-11 16:11:01 +02:00
|
|
|
|
* The signal comes from the object or interface to which
|
|
|
|
|
* this virtual function belongs.
|
|
|
|
|
*
|
2023-12-13 14:26:20 +01:00
|
|
|
|
* Returns: (transfer full) (nullable): the signal, or `NULL` if none is set
|
2023-11-09 00:36:19 +01:00
|
|
|
|
* Since: 2.80
|
2010-06-11 16:11:01 +02:00
|
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GISignalInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_vfunc_info_get_signal (GIVFuncInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-11 16:11:01 +02:00
|
|
|
|
VFuncBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
|
g_return_val_if_fail (GI_IS_VFUNC_INFO (info), 0);
|
|
|
|
|
|
|
|
|
|
blob = (VFuncBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
|
|
if (blob->class_closure)
|
2023-11-08 15:17:52 +01:00
|
|
|
|
return gi_interface_info_get_signal ((GIInterfaceInfo *)rinfo->container, blob->signal);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_vfunc_info_get_invoker:
|
2010-06-07 00:52:12 +02:00
|
|
|
|
* @info: a #GIVFuncInfo
|
|
|
|
|
*
|
|
|
|
|
* If this virtual function has an associated invoker method, this
|
|
|
|
|
* method will return it. An invoker method is a C entry point.
|
|
|
|
|
*
|
|
|
|
|
* Not all virtuals will have invokers.
|
|
|
|
|
*
|
2023-12-13 14:26:20 +01:00
|
|
|
|
* Returns: (transfer full) (nullable): The [type@GIRepository.FunctionInfo] or
|
|
|
|
|
* `NULL` if none is set. Free it with [method@GIRepository.BaseInfo.unref]
|
|
|
|
|
* when done.
|
2023-11-09 00:36:19 +01:00
|
|
|
|
* Since: 2.80
|
2010-06-07 00:52:12 +02:00
|
|
|
|
*/
|
|
|
|
|
GIFunctionInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_vfunc_info_get_invoker (GIVFuncInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-11 16:11:01 +02:00
|
|
|
|
VFuncBlob *blob;
|
|
|
|
|
GIBaseInfo *container;
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIInfoType parent_type;
|
|
|
|
|
|
2010-06-11 16:11:01 +02:00
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
|
g_return_val_if_fail (GI_IS_VFUNC_INFO (info), 0);
|
|
|
|
|
|
|
|
|
|
blob = (VFuncBlob *)&rinfo->typelib->data[rinfo->offset];
|
|
|
|
|
|
2010-06-07 00:52:12 +02:00
|
|
|
|
/* 1023 = 0x3ff is the maximum of the 10 bits for invoker index */
|
|
|
|
|
if (blob->invoker == 1023)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2010-06-11 16:11:01 +02:00
|
|
|
|
container = rinfo->container;
|
2023-12-12 17:16:30 +01:00
|
|
|
|
parent_type = gi_base_info_get_info_type (container);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
if (parent_type == GI_INFO_TYPE_OBJECT)
|
2023-11-08 15:17:52 +01:00
|
|
|
|
return gi_object_info_get_method ((GIObjectInfo*)container, blob->invoker);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
else if (parent_type == GI_INFO_TYPE_INTERFACE)
|
2023-11-08 15:17:52 +01:00
|
|
|
|
return gi_interface_info_get_method ((GIInterfaceInfo*)container, blob->invoker);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
else
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-13 13:53:55 +01:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_vfunc_info_get_address:
|
2010-12-13 13:53:55 +01:00
|
|
|
|
* @info: a #GIVFuncInfo
|
2023-12-13 14:26:20 +01:00
|
|
|
|
* @implementor_gtype: [type@GObject.Type] implementing this virtual function
|
|
|
|
|
* @error: return location for a [type@GLib.Error], or `NULL`
|
2010-12-13 13:53:55 +01:00
|
|
|
|
*
|
2023-12-13 14:26:20 +01:00
|
|
|
|
* Looks up where the implementation for @info is inside the type struct of
|
|
|
|
|
* @implementor_gtype.
|
2010-12-13 13:53:55 +01:00
|
|
|
|
*
|
2023-12-13 14:26:20 +01:00
|
|
|
|
* Returns: address to a function
|
2023-11-09 00:36:19 +01:00
|
|
|
|
* Since: 2.80
|
2010-12-13 13:53:55 +01:00
|
|
|
|
*/
|
2024-01-15 20:16:00 +01:00
|
|
|
|
void *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info,
|
|
|
|
|
GType implementor_gtype,
|
|
|
|
|
GError **error)
|
2010-12-13 13:53:55 +01:00
|
|
|
|
{
|
2013-10-13 02:02:22 +02:00
|
|
|
|
GIBaseInfo *container_info;
|
|
|
|
|
GIInterfaceInfo *interface_info;
|
2010-12-13 13:53:55 +01:00
|
|
|
|
GIObjectInfo *object_info;
|
|
|
|
|
GIStructInfo *struct_info;
|
|
|
|
|
GIFieldInfo *field_info = NULL;
|
|
|
|
|
int length, i, offset;
|
2024-01-15 20:16:00 +01:00
|
|
|
|
void *implementor_class, *implementor_vtable;
|
|
|
|
|
void *func = NULL;
|
2010-12-13 13:53:55 +01:00
|
|
|
|
|
2023-11-09 00:45:46 +01:00
|
|
|
|
g_return_val_if_fail (vfunc_info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_VFUNC_INFO (vfunc_info), NULL);
|
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
|
|
|
|
|
2023-11-28 18:14:30 +01:00
|
|
|
|
container_info = gi_base_info_get_container ((GIBaseInfo *) vfunc_info);
|
2023-12-12 17:16:30 +01:00
|
|
|
|
if (gi_base_info_get_info_type (container_info) == GI_INFO_TYPE_OBJECT)
|
2013-10-13 02:02:22 +02:00
|
|
|
|
{
|
|
|
|
|
object_info = (GIObjectInfo*) container_info;
|
|
|
|
|
interface_info = NULL;
|
2023-11-08 15:17:52 +01:00
|
|
|
|
struct_info = gi_object_info_get_class_struct (object_info);
|
2013-10-13 02:02:22 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
interface_info = (GIInterfaceInfo*) container_info;
|
|
|
|
|
object_info = NULL;
|
2023-11-08 15:17:52 +01:00
|
|
|
|
struct_info = gi_interface_info_get_iface_struct (interface_info);
|
2013-10-13 02:02:22 +02:00
|
|
|
|
}
|
2010-12-13 13:53:55 +01:00
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
|
length = gi_struct_info_get_n_fields (struct_info);
|
2010-12-13 13:53:55 +01:00
|
|
|
|
for (i = 0; i < length; i++)
|
|
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
|
field_info = gi_struct_info_get_field (struct_info, i);
|
2010-12-13 13:53:55 +01:00
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
|
if (strcmp (gi_base_info_get_name ( (GIBaseInfo*) field_info),
|
|
|
|
|
gi_base_info_get_name ( (GIBaseInfo*) vfunc_info)) != 0) {
|
2023-11-28 18:14:30 +01:00
|
|
|
|
gi_base_info_unref ((GIBaseInfo *) field_info);
|
2010-12-13 13:53:55 +01:00
|
|
|
|
field_info = NULL;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (field_info == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error,
|
2023-11-08 15:17:52 +01:00
|
|
|
|
GI_INVOKE_ERROR,
|
|
|
|
|
GI_INVOKE_ERROR_SYMBOL_NOT_FOUND,
|
2010-12-13 13:53:55 +01:00
|
|
|
|
"Couldn't find struct field for this vfunc");
|
2012-08-25 09:05:17 +02:00
|
|
|
|
goto out;
|
2010-12-13 13:53:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-13 02:02:22 +02:00
|
|
|
|
implementor_class = g_type_class_ref (implementor_gtype);
|
|
|
|
|
|
|
|
|
|
if (object_info)
|
|
|
|
|
{
|
|
|
|
|
implementor_vtable = implementor_class;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GType interface_type;
|
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
|
interface_type = gi_registered_type_info_get_g_type ((GIRegisteredTypeInfo*) interface_info);
|
2013-10-13 02:02:22 +02:00
|
|
|
|
implementor_vtable = g_type_interface_peek (implementor_class, interface_type);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
|
offset = gi_field_info_get_offset (field_info);
|
2024-01-15 20:16:00 +01:00
|
|
|
|
func = *(void**) G_STRUCT_MEMBER_P (implementor_vtable, offset);
|
2013-10-13 02:02:22 +02:00
|
|
|
|
g_type_class_unref (implementor_class);
|
2023-11-28 18:14:30 +01:00
|
|
|
|
gi_base_info_unref ((GIBaseInfo *) field_info);
|
2010-12-13 13:53:55 +01:00
|
|
|
|
|
|
|
|
|
if (func == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error,
|
2023-11-08 15:17:52 +01:00
|
|
|
|
GI_INVOKE_ERROR,
|
|
|
|
|
GI_INVOKE_ERROR_SYMBOL_NOT_FOUND,
|
2010-12-13 13:53:55 +01:00
|
|
|
|
"Class %s doesn't implement %s",
|
|
|
|
|
g_type_name (implementor_gtype),
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_base_info_get_name ( (GIBaseInfo*) vfunc_info));
|
2012-08-25 09:05:17 +02:00
|
|
|
|
goto out;
|
2010-12-13 13:53:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-25 09:05:17 +02:00
|
|
|
|
out:
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_base_info_unref ((GIBaseInfo*) struct_info);
|
2012-08-25 09:05:17 +02:00
|
|
|
|
|
2010-12-13 13:53:55 +01:00
|
|
|
|
return func;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_vfunc_info_invoke: (skip)
|
2010-12-13 13:53:55 +01:00
|
|
|
|
* @info: a #GIVFuncInfo describing the virtual function to invoke
|
2023-12-13 14:26:20 +01:00
|
|
|
|
* @implementor: [type@GObject.Type] of the type that implements this virtual
|
|
|
|
|
* function
|
2023-11-09 00:42:11 +01:00
|
|
|
|
* @in_args: (array length=n_in_args) (nullable): an array of
|
2023-12-13 14:26:20 +01:00
|
|
|
|
* [struct@GIRepository.Argument]s, one for each ‘in’ parameter of @info. If
|
|
|
|
|
* there are no ‘in’ parameters, @in_args can be `NULL`
|
2010-12-13 13:53:55 +01:00
|
|
|
|
* @n_in_args: the length of the @in_args array
|
2023-11-09 00:42:11 +01:00
|
|
|
|
* @out_args: (array length=n_out_args) (nullable): an array of
|
2023-12-13 14:26:20 +01:00
|
|
|
|
* [struct@GIRepository.Argument]s allocated by the caller, one for each
|
|
|
|
|
* ‘out’ parameter of @info. If there are no ‘out’ parameters, @out_args may
|
|
|
|
|
* be `NULL`
|
2010-12-13 13:53:55 +01:00
|
|
|
|
* @n_out_args: the length of the @out_args array
|
2023-12-13 14:26:20 +01:00
|
|
|
|
* @return_value: (out caller-allocates) (not optional) (nullable): return
|
|
|
|
|
* location for the return value from the vfunc; `NULL` may be returned if
|
|
|
|
|
* the vfunc returns that
|
2023-11-09 00:36:19 +01:00
|
|
|
|
* @error: return location for detailed error information, or `NULL`
|
2010-12-13 13:53:55 +01:00
|
|
|
|
*
|
|
|
|
|
* Invokes the function described in @info with the given
|
2023-12-13 14:26:20 +01:00
|
|
|
|
* arguments.
|
|
|
|
|
*
|
|
|
|
|
* Note that ‘inout’ parameters must appear in both argument lists.
|
2010-12-13 13:53:55 +01:00
|
|
|
|
*
|
2023-12-13 14:26:20 +01:00
|
|
|
|
* Returns: `TRUE` if the vfunc was executed successfully and didn’t throw
|
|
|
|
|
* a [type@GLib.Error]; `FALSE` if @error is set
|
2023-11-09 00:36:19 +01:00
|
|
|
|
* Since: 2.80
|
2010-12-13 13:53:55 +01:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_vfunc_info_invoke (GIVFuncInfo *info,
|
|
|
|
|
GType implementor,
|
|
|
|
|
const GIArgument *in_args,
|
2024-01-16 00:35:23 +01:00
|
|
|
|
size_t n_in_args,
|
2024-01-05 14:57:35 +01:00
|
|
|
|
GIArgument *out_args,
|
2024-01-16 00:35:23 +01:00
|
|
|
|
size_t n_out_args,
|
2023-11-08 15:17:52 +01:00
|
|
|
|
GIArgument *return_value,
|
|
|
|
|
GError **error)
|
2010-12-13 13:53:55 +01:00
|
|
|
|
{
|
2024-01-15 20:16:00 +01:00
|
|
|
|
void *func;
|
2023-11-09 00:42:44 +01:00
|
|
|
|
GError *local_error = NULL;
|
2010-12-13 13:53:55 +01:00
|
|
|
|
|
2023-11-09 00:45:46 +01:00
|
|
|
|
g_return_val_if_fail (info != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (GI_IS_VFUNC_INFO (info), FALSE);
|
|
|
|
|
g_return_val_if_fail (in_args != NULL || n_in_args == 0, FALSE);
|
|
|
|
|
g_return_val_if_fail (out_args != NULL || n_out_args == 0, FALSE);
|
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
|
|
|
2023-11-09 00:42:44 +01:00
|
|
|
|
func = gi_vfunc_info_get_address (info, implementor, &local_error);
|
|
|
|
|
if (local_error != NULL)
|
|
|
|
|
{
|
|
|
|
|
g_propagate_error (error, g_steal_pointer (&local_error));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2010-12-13 13:53:55 +01:00
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
|
return gi_callable_info_invoke ((GICallableInfo*) info,
|
|
|
|
|
func,
|
|
|
|
|
in_args,
|
|
|
|
|
n_in_args,
|
|
|
|
|
out_args,
|
|
|
|
|
n_out_args,
|
|
|
|
|
return_value,
|
|
|
|
|
error);
|
2010-12-13 13:53:55 +01:00
|
|
|
|
}
|
2023-11-28 18:24:20 +01:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gi_vfunc_info_class_init (gpointer g_class,
|
|
|
|
|
gpointer class_data)
|
|
|
|
|
{
|
|
|
|
|
GIBaseInfoClass *info_class = g_class;
|
|
|
|
|
|
|
|
|
|
info_class->info_type = GI_INFO_TYPE_VFUNC;
|
|
|
|
|
}
|