2012-02-03 19:42:56 +01:00
|
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
|
|
|
|
* GObject introspection: Object 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 <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 "giobjectinfo.h"
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* GIObjectInfo:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* `GIObjectInfo` represents a classed type.
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Classed types in [type@GObject.Type] inherit from
|
|
|
|
|
* [type@GObject.TypeInstance]; the most common type is [class@GObject.Object].
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* A `GIObjectInfo` doesn’t represent a specific instance of a classed type,
|
|
|
|
|
* instead this represent the object type (i.e. the class).
|
2022-02-13 15:20:51 +01:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* A `GIObjectInfo` has methods, fields, properties, signals, interfaces,
|
2022-02-13 15:20:51 +01:00
|
|
|
|
* constants and virtual functions.
|
2023-12-13 14:23:44 +01:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2014-02-27 11:05:54 +01:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_field_offset:
|
2014-02-27 11:05:54 +01:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
* @n: index of queried field
|
|
|
|
|
*
|
|
|
|
|
* Obtain the offset of the specified field.
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: field offset, in bytes
|
|
|
|
|
* Since: 2.80
|
2014-02-27 11:05:54 +01:00
|
|
|
|
*/
|
2024-01-16 01:00:07 +01:00
|
|
|
|
static size_t
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_field_offset (GIObjectInfo *info,
|
2024-01-16 01:00:07 +01:00
|
|
|
|
size_t n)
|
2014-02-27 11:05:54 +01:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
|
|
|
|
Header *header = (Header *)rinfo->typelib->data;
|
|
|
|
|
ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2024-01-15 22:20:02 +01:00
|
|
|
|
uint32_t offset;
|
2014-02-27 11:05:54 +01:00
|
|
|
|
FieldBlob *field_blob;
|
|
|
|
|
|
|
|
|
|
offset = rinfo->offset + header->object_blob_size
|
|
|
|
|
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2;
|
|
|
|
|
|
2024-01-16 01:57:09 +01:00
|
|
|
|
for (size_t i = 0; i < n; i++)
|
2014-02-27 11:05:54 +01:00
|
|
|
|
{
|
|
|
|
|
field_blob = (FieldBlob *)&rinfo->typelib->data[offset];
|
|
|
|
|
offset += header->field_blob_size;
|
|
|
|
|
if (field_blob->has_embedded_type)
|
|
|
|
|
offset += header->callback_blob_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_parent:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain the parent of the object type.
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (transfer full) (nullable): The `GIObjectInfo`. Free the struct by
|
|
|
|
|
* calling [method@GIRepository.BaseInfo.unref] when done.
|
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIObjectInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_parent (GIObjectInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
|
|
if (blob->parent)
|
2023-11-08 16:23:31 +01:00
|
|
|
|
return (GIObjectInfo *) gi_info_from_entry (rinfo->repository,
|
|
|
|
|
rinfo->typelib, blob->parent);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
else
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_abstract:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Obtain if the object type is an abstract type, i.e. if it cannot be
|
|
|
|
|
* instantiated.
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: `TRUE` if the object type is abstract
|
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
|
gboolean
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_abstract (GIObjectInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), FALSE);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
|
|
|
|
|
2010-06-07 00:52:12 +02:00
|
|
|
|
return blob->abstract != 0;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-09 12:38:27 +01:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_final:
|
2021-02-09 12:38:27 +01:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Checks whether the object type is a final type, i.e. if it cannot
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* be derived.
|
2021-02-09 12:38:27 +01:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: `TRUE` if the object type is final
|
2023-11-09 00:24:11 +01:00
|
|
|
|
* Since: 2.80
|
2021-02-09 12:38:27 +01:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_final (GIObjectInfo *info)
|
2021-02-09 12:38:27 +01:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *) info;
|
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), FALSE);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *) &rinfo->typelib->data[rinfo->offset];
|
|
|
|
|
|
|
|
|
|
return blob->final_ != 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 23:08:56 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_fundamental:
|
2010-06-12 23:08:56 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain if the object type is of a fundamental type which is not
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* `G_TYPE_OBJECT`.
|
2010-06-12 23:08:56 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* This is mostly for supporting `GstMiniObject`.
|
|
|
|
|
*
|
|
|
|
|
* Returns: `TRUE` if the object type is a fundamental type
|
|
|
|
|
* Since: 2.80
|
2010-06-12 23:08:56 +02:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_fundamental (GIObjectInfo *info)
|
2010-06-12 23:08:56 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), FALSE);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
|
|
|
|
|
|
|
|
|
return blob->fundamental != 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_type_name:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Obtain the name of the object’s class/type.
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: name of the object’s type
|
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2024-01-15 20:20:47 +01:00
|
|
|
|
const char *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_type_name (GIObjectInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
|
return gi_typelib_get_string (rinfo->typelib, blob->gtype_name);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-12-12 18:54:19 +01:00
|
|
|
|
* gi_object_info_get_type_init_function_name:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Obtain the name of the function which, when called, will return the
|
|
|
|
|
* [type@GObject.Type] for this object type.
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: the type init function name
|
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2024-01-15 20:20:47 +01:00
|
|
|
|
const char *
|
2023-12-12 18:54:19 +01:00
|
|
|
|
gi_object_info_get_type_init_function_name (GIObjectInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
|
return gi_typelib_get_string (rinfo->typelib, blob->gtype_init);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_n_interfaces:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain the number of interfaces that this object type has.
|
|
|
|
|
*
|
|
|
|
|
* Returns: number of interfaces
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2024-01-15 22:20:02 +01:00
|
|
|
|
unsigned int
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_n_interfaces (GIObjectInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
|
|
return blob->n_interfaces;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_interface:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
* @n: index of interface to get
|
|
|
|
|
*
|
|
|
|
|
* Obtain an object type interface at index @n.
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (transfer full): The [class@GIRepository.InterfaceInfo]. Free the
|
|
|
|
|
* struct by calling [method@GIRepository.BaseInfo.unref] when done.
|
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIInterfaceInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_interface (GIObjectInfo *info,
|
2024-01-15 22:20:02 +01:00
|
|
|
|
unsigned int n)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
2024-01-16 01:40:09 +01:00
|
|
|
|
g_return_val_if_fail (n <= G_MAXUINT16, NULL);
|
2010-06-12 01:51:32 +02:00
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2023-11-08 16:23:31 +01:00
|
|
|
|
return (GIInterfaceInfo *) gi_info_from_entry (rinfo->repository,
|
|
|
|
|
rinfo->typelib, blob->interfaces[n]);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_n_fields:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain the number of fields that this object type has.
|
|
|
|
|
*
|
|
|
|
|
* Returns: number of fields
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2024-01-15 22:20:02 +01:00
|
|
|
|
unsigned int
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_n_fields (GIObjectInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
|
|
return blob->n_fields;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_field:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
* @n: index of field to get
|
|
|
|
|
*
|
|
|
|
|
* Obtain an object type field at index @n.
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (transfer full): The [class@GIRepository.FieldInfo]. Free the struct
|
|
|
|
|
* by calling [method@GIRepository.BaseInfo.unref] when done.
|
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIFieldInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_field (GIObjectInfo *info,
|
2024-01-15 22:20:02 +01:00
|
|
|
|
unsigned int n)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
2024-01-16 01:00:07 +01:00
|
|
|
|
size_t offset;
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
2024-01-16 01:40:09 +01:00
|
|
|
|
g_return_val_if_fail (n <= G_MAXUINT16, NULL);
|
2010-06-12 01:51:32 +02:00
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
|
offset = gi_object_info_get_field_offset(info, n);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2024-02-08 11:34:40 +01:00
|
|
|
|
return (GIFieldInfo *) gi_base_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib, offset);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_n_properties:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain the number of properties that this object type has.
|
|
|
|
|
*
|
|
|
|
|
* Returns: number of properties
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2024-01-15 22:20:02 +01:00
|
|
|
|
unsigned int
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_n_properties (GIObjectInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
return blob->n_properties;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_property:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
* @n: index of property to get
|
|
|
|
|
*
|
|
|
|
|
* Obtain an object type property at index @n.
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (transfer full): The [class@GIRepository.PropertyInfo]. Free the
|
|
|
|
|
* struct by calling [method@GIRepository.BaseInfo.unref] when done.
|
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIPropertyInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_property (GIObjectInfo *info,
|
2024-01-15 22:20:02 +01:00
|
|
|
|
unsigned int n)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
2024-01-16 01:00:07 +01:00
|
|
|
|
size_t offset;
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
Header *header;
|
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
2024-01-16 01:40:09 +01:00
|
|
|
|
g_return_val_if_fail (n <= G_MAXUINT16, NULL);
|
2010-06-12 01:51:32 +02:00
|
|
|
|
|
|
|
|
|
header = (Header *)rinfo->typelib->data;
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2014-02-28 02:10:19 +01:00
|
|
|
|
offset = rinfo->offset + header->object_blob_size
|
|
|
|
|
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
|
|
|
|
|
+ blob->n_fields * header->field_blob_size
|
|
|
|
|
+ blob->n_field_callbacks * header->callback_blob_size
|
2010-06-07 00:52:12 +02:00
|
|
|
|
+ n * header->property_blob_size;
|
|
|
|
|
|
2024-02-08 11:34:40 +01:00
|
|
|
|
return (GIPropertyInfo *) gi_base_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info,
|
|
|
|
|
rinfo->typelib, offset);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_n_methods:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain the number of methods that this object type has.
|
|
|
|
|
*
|
|
|
|
|
* Returns: number of methods
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2024-01-15 22:20:02 +01:00
|
|
|
|
unsigned int
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_n_methods (GIObjectInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
|
|
return blob->n_methods;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_method:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
* @n: index of method to get
|
|
|
|
|
*
|
|
|
|
|
* Obtain an object type method at index @n.
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (transfer full): The [class@GIRepository.FunctionInfo]. Free the
|
|
|
|
|
* struct by calling [method@GIRepository.BaseInfo.unref] when done.
|
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIFunctionInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_method (GIObjectInfo *info,
|
2024-01-15 22:20:02 +01:00
|
|
|
|
unsigned int n)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
2024-01-16 01:00:07 +01:00
|
|
|
|
size_t offset;
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
Header *header;
|
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
2024-01-16 01:40:09 +01:00
|
|
|
|
g_return_val_if_fail (n <= G_MAXUINT16, NULL);
|
2010-06-12 01:51:32 +02:00
|
|
|
|
|
|
|
|
|
header = (Header *)rinfo->typelib->data;
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
|
|
|
|
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2014-02-28 02:10:19 +01:00
|
|
|
|
offset = rinfo->offset + header->object_blob_size
|
|
|
|
|
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
|
|
|
|
|
+ blob->n_fields * header->field_blob_size
|
|
|
|
|
+ blob->n_field_callbacks * header->callback_blob_size
|
2010-06-07 00:52:12 +02:00
|
|
|
|
+ blob->n_properties * header->property_blob_size
|
|
|
|
|
+ n * header->function_blob_size;
|
|
|
|
|
|
2024-02-08 11:34:40 +01:00
|
|
|
|
return (GIFunctionInfo *) gi_base_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
|
|
|
|
|
rinfo->typelib, offset);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_find_method:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
2010-06-12 16:14:22 +02:00
|
|
|
|
* @name: name of method to obtain
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Obtain a method of the object type given a @name.
|
|
|
|
|
*
|
|
|
|
|
* `NULL` will be returned if there’s no method available with that name.
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (transfer full) (nullable): The [class@GIRepository.FunctionInfo],
|
|
|
|
|
* or `NULL` if no method could be found. Free the struct by calling
|
|
|
|
|
* [method@GIRepository.BaseInfo.unref] when done.
|
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIFunctionInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_find_method (GIObjectInfo *info,
|
2024-01-15 20:20:47 +01:00
|
|
|
|
const char *name)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
2024-01-16 01:00:07 +01:00
|
|
|
|
size_t offset;
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
Header *header;
|
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
|
|
|
|
|
|
|
|
|
|
header = (Header *)rinfo->typelib->data;
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2014-02-28 02:10:19 +01:00
|
|
|
|
offset = rinfo->offset + header->object_blob_size
|
|
|
|
|
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
|
|
|
|
|
+ blob->n_fields * header->field_blob_size +
|
|
|
|
|
+ blob->n_field_callbacks * header->callback_blob_size
|
2010-06-07 00:52:12 +02:00
|
|
|
|
+ blob->n_properties * header->property_blob_size;
|
|
|
|
|
|
2023-11-08 16:23:31 +01:00
|
|
|
|
return gi_base_info_find_method ((GIBaseInfo*)info, offset, blob->n_methods, name);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-22 20:22:19 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_find_method_using_interfaces:
|
2010-10-22 20:22:19 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
* @name: name of method to obtain
|
2024-02-05 19:40:03 +01:00
|
|
|
|
* @declarer: (out) (transfer full) (optional) (nullable): The
|
|
|
|
|
* [class@GIRepository.ObjectInfo] or [class@GIRepository.InterfaceInfo] which
|
|
|
|
|
* declares the method, or `NULL` to ignore. If no method is found, this will
|
|
|
|
|
* return `NULL`.
|
2010-10-22 20:22:19 +02:00
|
|
|
|
*
|
|
|
|
|
* Obtain a method of the object given a @name, searching both the
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* object @info and any interfaces it implements.
|
|
|
|
|
*
|
|
|
|
|
* `NULL` will be returned if there’s no method available with that name.
|
2010-10-22 20:22:19 +02:00
|
|
|
|
*
|
|
|
|
|
* Note that this function does *not* search parent classes; you will have
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* to chain up if that’s desired.
|
2010-10-22 20:22:19 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (transfer full) (nullable): The [class@GIRepository.FunctionInfo],
|
|
|
|
|
* or `NULL` if none was found. Free the struct by calling
|
|
|
|
|
* [method@GIRepository.BaseInfo.unref] when done.
|
|
|
|
|
* Since: 2.80
|
2010-10-22 20:22:19 +02:00
|
|
|
|
*/
|
|
|
|
|
GIFunctionInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_find_method_using_interfaces (GIObjectInfo *info,
|
2024-01-15 20:20:47 +01:00
|
|
|
|
const char *name,
|
2024-02-05 19:40:03 +01:00
|
|
|
|
GIBaseInfo **declarer)
|
2010-10-22 20:22:19 +02:00
|
|
|
|
{
|
|
|
|
|
GIFunctionInfo *result = NULL;
|
2024-02-05 19:40:03 +01:00
|
|
|
|
GIBaseInfo *declarer_result = NULL;
|
2010-10-22 20:22:19 +02:00
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
|
result = gi_object_info_find_method (info, name);
|
2010-10-22 20:22:19 +02:00
|
|
|
|
if (result)
|
2024-02-05 19:40:03 +01:00
|
|
|
|
declarer_result = gi_base_info_ref (info);
|
2010-10-22 20:22:19 +02:00
|
|
|
|
|
|
|
|
|
if (result == NULL)
|
|
|
|
|
{
|
|
|
|
|
int n_interfaces;
|
|
|
|
|
int i;
|
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
|
n_interfaces = gi_object_info_get_n_interfaces (info);
|
2010-10-22 20:22:19 +02:00
|
|
|
|
for (i = 0; i < n_interfaces; ++i)
|
2024-01-16 17:30:37 +01:00
|
|
|
|
{
|
|
|
|
|
GIInterfaceInfo *iface_info;
|
2010-10-22 20:22:19 +02:00
|
|
|
|
|
2024-01-16 17:30:37 +01:00
|
|
|
|
iface_info = gi_object_info_get_interface (info, i);
|
2010-10-22 20:22:19 +02:00
|
|
|
|
|
2024-01-16 17:30:37 +01:00
|
|
|
|
result = gi_interface_info_find_method (iface_info, name);
|
2010-10-22 20:22:19 +02:00
|
|
|
|
|
2024-01-16 17:30:37 +01:00
|
|
|
|
if (result != NULL)
|
|
|
|
|
{
|
2024-02-05 19:40:03 +01:00
|
|
|
|
declarer_result = GI_BASE_INFO (g_steal_pointer (&iface_info));
|
2024-01-16 17:30:37 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
gi_base_info_unref ((GIBaseInfo*) iface_info);
|
|
|
|
|
}
|
2010-10-22 20:22:19 +02:00
|
|
|
|
}
|
2024-02-05 19:40:03 +01:00
|
|
|
|
|
|
|
|
|
if (declarer)
|
|
|
|
|
*declarer = g_steal_pointer (&declarer_result);
|
|
|
|
|
|
|
|
|
|
g_clear_pointer (&declarer_result, gi_base_info_unref);
|
|
|
|
|
|
|
|
|
|
return g_steal_pointer (&result);
|
2010-10-22 20:22:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_n_signals:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain the number of signals that this object type has.
|
|
|
|
|
*
|
|
|
|
|
* Returns: number of signals
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2024-01-15 22:20:02 +01:00
|
|
|
|
unsigned int
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_n_signals (GIObjectInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
|
|
return blob->n_signals;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-04 18:33:16 +01:00
|
|
|
|
static uint32_t
|
|
|
|
|
object_get_signal_offset (GIObjectInfo *info, unsigned int n)
|
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *) info;
|
|
|
|
|
Header *header = (Header *) rinfo->typelib->data;
|
|
|
|
|
ObjectBlob *blob = (ObjectBlob *) &rinfo->typelib->data[rinfo->offset];
|
|
|
|
|
|
|
|
|
|
return rinfo->offset + header->object_blob_size
|
|
|
|
|
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
|
|
|
|
|
+ blob->n_fields * header->field_blob_size
|
|
|
|
|
+ blob->n_field_callbacks * header->callback_blob_size
|
|
|
|
|
+ blob->n_properties * header->property_blob_size
|
|
|
|
|
+ blob->n_methods * header->function_blob_size
|
|
|
|
|
+ n * header->signal_blob_size;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_signal:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
* @n: index of signal to get
|
|
|
|
|
*
|
|
|
|
|
* Obtain an object type signal at index @n.
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (transfer full): The [class@GIRepository.SignalInfo]. Free the
|
|
|
|
|
* struct by calling [method@GIRepository.BaseInfo.unref] when done.
|
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GISignalInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_signal (GIObjectInfo *info,
|
2024-01-15 22:20:02 +01:00
|
|
|
|
unsigned int n)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
2024-01-16 01:40:09 +01:00
|
|
|
|
g_return_val_if_fail (n <= G_MAXUINT16, NULL);
|
2010-06-12 01:51:32 +02:00
|
|
|
|
|
2024-11-04 18:33:16 +01:00
|
|
|
|
return (GISignalInfo *) gi_base_info_new (GI_INFO_TYPE_SIGNAL, (GIBaseInfo*)info,
|
|
|
|
|
rinfo->typelib, object_get_signal_offset (info, n));
|
|
|
|
|
}
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2024-11-04 18:33:16 +01:00
|
|
|
|
static GISignalInfo *
|
|
|
|
|
find_signal (GIRealInfo *rinfo,
|
|
|
|
|
uint32_t offset,
|
|
|
|
|
uint16_t n_signals,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
|
|
|
|
Header *header = (Header *) rinfo->typelib->data;
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2024-11-04 18:33:16 +01:00
|
|
|
|
for (uint16_t i = 0; i < n_signals; i++)
|
|
|
|
|
{
|
|
|
|
|
const SignalBlob *sblob = (SignalBlob *) &rinfo->typelib->data[offset];
|
|
|
|
|
const char *sname = gi_typelib_get_string (rinfo->typelib, sblob->name);
|
|
|
|
|
|
|
|
|
|
if (strcmp (name, sname) == 0)
|
|
|
|
|
return (GISignalInfo *) gi_base_info_new (GI_INFO_TYPE_SIGNAL, (GIBaseInfo *) rinfo,
|
|
|
|
|
rinfo->typelib, offset);
|
|
|
|
|
|
|
|
|
|
offset += header->signal_blob_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
2010-06-07 00:52:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-26 17:47:00 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_find_signal:
|
2010-10-26 17:47:00 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* @name: name of signal
|
2010-10-26 17:47:00 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Obtain a signal of the object type given a @name.
|
2013-10-10 22:21:18 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* `NULL` will be returned if there’s no signal available with that name.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full) (nullable): The [class@GIRepository.SignalInfo],
|
|
|
|
|
* or `NULL` if no signal could be found. Free the struct by calling
|
|
|
|
|
* [method@GIRepository.BaseInfo.unref] when done.
|
|
|
|
|
* Since: 2.80
|
2010-10-26 17:47:00 +02:00
|
|
|
|
*/
|
|
|
|
|
GISignalInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_find_signal (GIObjectInfo *info,
|
2024-01-15 20:20:47 +01:00
|
|
|
|
const char *name)
|
2010-10-26 17:47:00 +02:00
|
|
|
|
{
|
2024-11-04 18:33:16 +01:00
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *) info;
|
2010-10-26 17:47:00 +02:00
|
|
|
|
|
2024-11-04 18:33:16 +01:00
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
2010-10-26 17:47:00 +02:00
|
|
|
|
|
2024-11-04 18:33:16 +01:00
|
|
|
|
return find_signal (rinfo, object_get_signal_offset (info, 0),
|
|
|
|
|
gi_object_info_get_n_signals (info), name);
|
2010-10-26 17:47:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_n_vfuncs:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain the number of virtual functions that this object type has.
|
|
|
|
|
*
|
|
|
|
|
* Returns: number of virtual functions
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2024-01-15 22:20:02 +01:00
|
|
|
|
unsigned int
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_n_vfuncs (GIObjectInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
|
|
return blob->n_vfuncs;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_vfunc:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
* @n: index of virtual function to get
|
|
|
|
|
*
|
|
|
|
|
* Obtain an object type virtual function at index @n.
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (transfer full): The [class@GIRepository.VFuncInfo]. Free the struct
|
|
|
|
|
* by calling [method@GIRepository.BaseInfo.unref] when done.
|
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIVFuncInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_vfunc (GIObjectInfo *info,
|
2024-01-15 22:20:02 +01:00
|
|
|
|
unsigned int n)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
2024-01-16 01:00:07 +01:00
|
|
|
|
size_t offset;
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
Header *header;
|
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
2024-01-16 01:40:09 +01:00
|
|
|
|
g_return_val_if_fail (n <= G_MAXUINT16, NULL);
|
2010-06-12 01:51:32 +02:00
|
|
|
|
|
|
|
|
|
header = (Header *)rinfo->typelib->data;
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2014-02-28 02:10:19 +01:00
|
|
|
|
offset = rinfo->offset + header->object_blob_size
|
|
|
|
|
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
|
|
|
|
|
+ blob->n_fields * header->field_blob_size
|
|
|
|
|
+ blob->n_field_callbacks * header->callback_blob_size
|
2010-06-07 00:52:12 +02:00
|
|
|
|
+ blob->n_properties * header->property_blob_size
|
|
|
|
|
+ blob->n_methods * header->function_blob_size
|
|
|
|
|
+ blob->n_signals * header->signal_blob_size
|
|
|
|
|
+ n * header->vfunc_blob_size;
|
|
|
|
|
|
2024-02-08 11:34:40 +01:00
|
|
|
|
return (GIVFuncInfo *) gi_base_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*)info,
|
|
|
|
|
rinfo->typelib, offset);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_find_vfunc:
|
2010-06-07 00:52:12 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* @name: the name of a virtual function to find.
|
|
|
|
|
*
|
|
|
|
|
* Locate a virtual function slot with name @name.
|
|
|
|
|
*
|
|
|
|
|
* Note that the namespace for virtuals is distinct from that of methods; there
|
|
|
|
|
* may or may not be a concrete method associated for a virtual. If there is
|
|
|
|
|
* one, it may be retrieved using [method@GIRepository.VFuncInfo.get_invoker],
|
|
|
|
|
* otherwise that method will return `NULL`.
|
|
|
|
|
*
|
|
|
|
|
* See the documentation for [method@GIRepository.VFuncInfo.get_invoker] for
|
|
|
|
|
* more information on invoking virtuals.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full) (nullable): The [class@GIRepository.VFuncInfo], or
|
|
|
|
|
* `NULL` if none is found. Free it with [method@GIRepository.BaseInfo.unref]
|
|
|
|
|
* when done.
|
|
|
|
|
* Since: 2.80
|
2010-06-07 00:52:12 +02:00
|
|
|
|
*/
|
|
|
|
|
GIVFuncInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_find_vfunc (GIObjectInfo *info,
|
2024-01-15 20:20:47 +01:00
|
|
|
|
const char *name)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
2024-01-16 01:00:07 +01:00
|
|
|
|
size_t offset;
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
Header *header;
|
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
|
|
|
|
|
|
|
|
|
header = (Header *)rinfo->typelib->data;
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2014-02-28 02:10:19 +01:00
|
|
|
|
offset = rinfo->offset + header->object_blob_size
|
|
|
|
|
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
|
|
|
|
|
+ blob->n_fields * header->field_blob_size
|
|
|
|
|
+ blob->n_field_callbacks * header->callback_blob_size
|
2010-06-07 00:52:12 +02:00
|
|
|
|
+ blob->n_properties * header->property_blob_size
|
|
|
|
|
+ blob->n_methods * header->function_blob_size
|
|
|
|
|
+ blob->n_signals * header->signal_blob_size;
|
|
|
|
|
|
2023-11-08 16:23:31 +01:00
|
|
|
|
return gi_base_info_find_vfunc (rinfo, offset, blob->n_vfuncs, name);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-01-04 20:46:51 +01:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_find_vfunc_using_interfaces:
|
2012-01-04 20:46:51 +01:00
|
|
|
|
* @info: a #GIObjectInfo
|
2012-04-10 00:09:10 +02:00
|
|
|
|
* @name: name of vfunc to obtain
|
2024-02-05 19:40:03 +01:00
|
|
|
|
* @declarer: (out) (transfer full) (optional) (nullable): The
|
|
|
|
|
* [class@GIRepository.ObjectInfo] or [class@GIRepository.InterfaceInfo] which
|
|
|
|
|
* declares the vfunc, or `NULL` to ignore. If no vfunc is found, this will
|
|
|
|
|
* return `NULL`.
|
2012-01-04 20:46:51 +01:00
|
|
|
|
*
|
|
|
|
|
* Locate a virtual function slot with name @name, searching both the object
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* @info and any interfaces it implements.
|
|
|
|
|
*
|
|
|
|
|
* `NULL` will be returned if there’s no vfunc available with that name.
|
|
|
|
|
*
|
|
|
|
|
* Note that the namespace for virtuals is distinct from that of methods; there
|
|
|
|
|
* may or may not be a concrete method associated for a virtual. If there is
|
|
|
|
|
* one, it may be retrieved using [method@GIRepository.VFuncInfo.get_invoker],
|
|
|
|
|
* otherwise that method will return `NULL`.
|
2012-01-04 20:46:51 +01:00
|
|
|
|
*
|
|
|
|
|
* Note that this function does *not* search parent classes; you will have
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* to chain up if that’s desired.
|
2012-01-04 20:46:51 +01:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (transfer full) (nullable): The [class@GIRepository.VFuncInfo],
|
|
|
|
|
* or `NULL` if none was found. Free the struct by calling
|
|
|
|
|
* [method@GIRepository.BaseInfo.unref] when done.
|
|
|
|
|
* Since: 2.80
|
2012-01-04 20:46:51 +01:00
|
|
|
|
*/
|
|
|
|
|
GIVFuncInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info,
|
2024-01-15 20:20:47 +01:00
|
|
|
|
const char *name,
|
2024-02-05 19:40:03 +01:00
|
|
|
|
GIBaseInfo **declarer)
|
2012-01-04 20:46:51 +01:00
|
|
|
|
{
|
|
|
|
|
GIVFuncInfo *result = NULL;
|
2024-02-05 19:40:03 +01:00
|
|
|
|
GIBaseInfo *declarer_result = NULL;
|
2012-01-04 20:46:51 +01:00
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
|
result = gi_object_info_find_vfunc (info, name);
|
2012-01-04 20:46:51 +01:00
|
|
|
|
if (result)
|
2024-02-05 19:40:03 +01:00
|
|
|
|
declarer_result = gi_base_info_ref (info);
|
2012-01-04 20:46:51 +01:00
|
|
|
|
|
|
|
|
|
if (result == NULL)
|
|
|
|
|
{
|
|
|
|
|
int n_interfaces;
|
|
|
|
|
int i;
|
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
|
n_interfaces = gi_object_info_get_n_interfaces (info);
|
2012-01-04 20:46:51 +01:00
|
|
|
|
for (i = 0; i < n_interfaces; ++i)
|
2024-01-16 17:30:37 +01:00
|
|
|
|
{
|
|
|
|
|
GIInterfaceInfo *iface_info;
|
2012-01-04 20:46:51 +01:00
|
|
|
|
|
2024-01-16 17:30:37 +01:00
|
|
|
|
iface_info = gi_object_info_get_interface (info, i);
|
2012-01-04 20:46:51 +01:00
|
|
|
|
|
2024-01-16 17:30:37 +01:00
|
|
|
|
result = gi_interface_info_find_vfunc (iface_info, name);
|
2012-01-04 20:46:51 +01:00
|
|
|
|
|
2024-01-16 17:30:37 +01:00
|
|
|
|
if (result != NULL)
|
|
|
|
|
{
|
2024-02-05 19:40:03 +01:00
|
|
|
|
declarer_result = GI_BASE_INFO (g_steal_pointer (&iface_info));
|
2024-01-16 17:30:37 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
gi_base_info_unref ((GIBaseInfo*) iface_info);
|
|
|
|
|
}
|
2012-01-04 20:46:51 +01:00
|
|
|
|
}
|
2024-02-05 19:40:03 +01:00
|
|
|
|
|
|
|
|
|
if (declarer)
|
|
|
|
|
*declarer = g_steal_pointer (&declarer_result);
|
|
|
|
|
|
|
|
|
|
g_clear_pointer (&declarer_result, gi_base_info_unref);
|
|
|
|
|
|
|
|
|
|
return g_steal_pointer (&result);
|
2012-01-04 20:46:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_n_constants:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain the number of constants that this object type has.
|
|
|
|
|
*
|
|
|
|
|
* Returns: number of constants
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2024-01-15 22:20:02 +01:00
|
|
|
|
unsigned int
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_n_constants (GIObjectInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
|
|
return blob->n_constants;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 01:51:32 +02:00
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_constant:
|
2010-06-12 01:51:32 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
* @n: index of constant to get
|
|
|
|
|
*
|
|
|
|
|
* Obtain an object type constant at index @n.
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (transfer full): The [class@GIRepository.ConstantInfo]. Free the
|
|
|
|
|
* struct by calling [method@GIRepository.BaseInfo.unref] when done.
|
|
|
|
|
* Since: 2.80
|
2010-06-12 01:51:32 +02:00
|
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIConstantInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_constant (GIObjectInfo *info,
|
2024-01-15 22:20:02 +01:00
|
|
|
|
unsigned int n)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
2024-01-16 01:00:07 +01:00
|
|
|
|
size_t offset;
|
2010-06-07 00:52:12 +02:00
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
Header *header;
|
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
2024-01-16 01:40:09 +01:00
|
|
|
|
g_return_val_if_fail (n <= G_MAXUINT16, NULL);
|
2010-06-12 01:51:32 +02:00
|
|
|
|
|
|
|
|
|
header = (Header *)rinfo->typelib->data;
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
2014-02-28 02:10:19 +01:00
|
|
|
|
offset = rinfo->offset + header->object_blob_size
|
|
|
|
|
+ (blob->n_interfaces + blob->n_interfaces % 2) * 2
|
|
|
|
|
+ blob->n_fields * header->field_blob_size
|
|
|
|
|
+ blob->n_field_callbacks * header->callback_blob_size
|
2010-06-07 00:52:12 +02:00
|
|
|
|
+ blob->n_properties * header->property_blob_size
|
|
|
|
|
+ blob->n_methods * header->function_blob_size
|
|
|
|
|
+ blob->n_signals * header->signal_blob_size
|
|
|
|
|
+ blob->n_vfuncs * header->vfunc_blob_size
|
|
|
|
|
+ n * header->constant_blob_size;
|
|
|
|
|
|
2024-02-08 11:34:40 +01:00
|
|
|
|
return (GIConstantInfo *) gi_base_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info,
|
|
|
|
|
rinfo->typelib, offset);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_class_struct:
|
2010-06-07 00:52:12 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Every [class@GObject.Object] has two structures; an instance structure and a
|
|
|
|
|
* class structure. This function returns the metadata for the class structure.
|
2010-06-07 00:52:12 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (transfer full) (nullable): The [class@GIRepository.StructInfo] or
|
|
|
|
|
* `NULL` if it’s unknown. Free with [method@GIRepository.BaseInfo.unref] when
|
|
|
|
|
* done.
|
|
|
|
|
* Since: 2.80
|
2010-06-07 00:52:12 +02:00
|
|
|
|
*/
|
|
|
|
|
GIStructInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_class_struct (GIObjectInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 01:51:32 +02:00
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
|
|
if (blob->gtype_struct)
|
2023-11-08 16:23:31 +01:00
|
|
|
|
return (GIStructInfo *) gi_info_from_entry (rinfo->repository,
|
|
|
|
|
rinfo->typelib, blob->gtype_struct);
|
2010-06-07 00:52:12 +02:00
|
|
|
|
else
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-12 23:08:56 +02:00
|
|
|
|
typedef const char* (*SymbolGetter) (GIObjectInfo *info);
|
|
|
|
|
|
|
|
|
|
static void *
|
|
|
|
|
_get_func(GIObjectInfo *info,
|
|
|
|
|
SymbolGetter getter)
|
|
|
|
|
{
|
|
|
|
|
const char* symbol;
|
|
|
|
|
GSList *parents = NULL, *l;
|
|
|
|
|
GIObjectInfo *parent_info;
|
2024-01-15 20:16:00 +01:00
|
|
|
|
void *func = NULL;
|
2010-06-12 23:08:56 +02:00
|
|
|
|
|
2023-11-28 18:14:30 +01:00
|
|
|
|
parent_info = (GIObjectInfo *) gi_base_info_ref ((GIBaseInfo *) info);
|
2011-12-12 22:14:57 +01:00
|
|
|
|
while (parent_info != NULL)
|
|
|
|
|
{
|
|
|
|
|
parents = g_slist_prepend (parents, parent_info);
|
2023-11-08 15:17:52 +01:00
|
|
|
|
parent_info = gi_object_info_get_parent (parent_info);
|
2010-06-12 23:08:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-12-12 22:14:57 +01:00
|
|
|
|
for (l = parents; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
parent_info = l->data;
|
|
|
|
|
symbol = getter (parent_info);
|
|
|
|
|
if (symbol == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_typelib_symbol (((GIRealInfo *)parent_info)->typelib, symbol, (gpointer*) &func);
|
2011-12-12 22:14:57 +01:00
|
|
|
|
if (func)
|
|
|
|
|
break;
|
|
|
|
|
}
|
2010-06-12 23:08:56 +02:00
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
|
g_slist_free_full (parents, (GDestroyNotify) gi_base_info_unref);
|
2011-12-12 22:14:57 +01:00
|
|
|
|
return func;
|
2010-06-12 23:08:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-12-12 19:07:50 +01:00
|
|
|
|
* gi_object_info_get_ref_function_name:
|
2010-06-12 23:08:56 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain the symbol name of the function that should be called to ref this
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* object type.
|
2010-06-12 23:08:56 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* It’s mainly used for fundamental types. The type signature for
|
|
|
|
|
* the symbol is [type@GIRepository.ObjectInfoRefFunction]. To fetch the
|
|
|
|
|
* function pointer see
|
|
|
|
|
* [method@GIRepository.ObjectInfo.get_ref_function_pointer].
|
|
|
|
|
*
|
|
|
|
|
* Returns: (nullable): the symbol, or `NULL` if the object type has no ref
|
|
|
|
|
* function
|
|
|
|
|
* Since: 2.80
|
2010-06-12 23:08:56 +02:00
|
|
|
|
*/
|
|
|
|
|
const char *
|
2023-12-12 19:07:50 +01:00
|
|
|
|
gi_object_info_get_ref_function_name (GIObjectInfo *info)
|
2010-06-12 23:08:56 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
|
|
|
|
|
|
|
|
|
if (blob->ref_func)
|
2023-11-08 15:17:52 +01:00
|
|
|
|
return gi_typelib_get_string (rinfo->typelib, blob->ref_func);
|
2010-06-12 23:08:56 +02:00
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_ref_function_pointer: (skip)
|
2010-06-12 23:08:56 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain a pointer to a function which can be used to
|
|
|
|
|
* increase the reference count an instance of this object type.
|
2023-12-13 14:23:44 +01:00
|
|
|
|
*
|
2010-06-12 23:08:56 +02:00
|
|
|
|
* This takes derivation into account and will reversely traverse
|
|
|
|
|
* the base classes of this type, starting at the top type.
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (nullable): the function pointer, or `NULL` if the object type has
|
|
|
|
|
* no ref function
|
|
|
|
|
* Since: 2.80
|
2010-06-12 23:08:56 +02:00
|
|
|
|
*/
|
|
|
|
|
GIObjectInfoRefFunction
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_ref_function_pointer (GIObjectInfo *info)
|
2010-06-12 23:08:56 +02:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
|
|
|
|
|
2023-12-12 19:07:50 +01:00
|
|
|
|
return (GIObjectInfoRefFunction)_get_func(info, (SymbolGetter)gi_object_info_get_ref_function_name);
|
2010-06-12 23:08:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-12-12 19:07:50 +01:00
|
|
|
|
* gi_object_info_get_unref_function_name:
|
2010-06-12 23:08:56 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain the symbol name of the function that should be called to unref this
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* object type.
|
|
|
|
|
*
|
|
|
|
|
* It’s mainly used for fundamental types. The type signature for the symbol is
|
|
|
|
|
* [type@GIRepository.ObjectInfoUnrefFunction]. To fetch the function pointer
|
|
|
|
|
* see [method@GIRepository.ObjectInfo.get_unref_function_pointer].
|
2010-06-12 23:08:56 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (nullable): the symbol, or `NULL` if the object type has no unref
|
|
|
|
|
* function
|
|
|
|
|
* Since: 2.80
|
2010-06-12 23:08:56 +02:00
|
|
|
|
*/
|
|
|
|
|
const char *
|
2023-12-12 19:07:50 +01:00
|
|
|
|
gi_object_info_get_unref_function_name (GIObjectInfo *info)
|
2010-06-12 23:08:56 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
|
|
|
|
|
|
|
|
|
if (blob->unref_func)
|
2023-11-08 15:17:52 +01:00
|
|
|
|
return gi_typelib_get_string (rinfo->typelib, blob->unref_func);
|
2010-06-12 23:08:56 +02:00
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_unref_function_pointer: (skip)
|
2010-06-12 23:08:56 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain a pointer to a function which can be used to
|
|
|
|
|
* decrease the reference count an instance of this object type.
|
2023-12-13 14:23:44 +01:00
|
|
|
|
*
|
2010-06-12 23:08:56 +02:00
|
|
|
|
* This takes derivation into account and will reversely traverse
|
|
|
|
|
* the base classes of this type, starting at the top type.
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (nullable): the function pointer, or `NULL` if the object type has
|
|
|
|
|
* no unref function
|
|
|
|
|
* Since: 2.80
|
2010-06-12 23:08:56 +02:00
|
|
|
|
*/
|
|
|
|
|
GIObjectInfoUnrefFunction
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_unref_function_pointer (GIObjectInfo *info)
|
2010-06-12 23:08:56 +02:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
|
|
|
|
|
2023-12-12 19:07:50 +01:00
|
|
|
|
return (GIObjectInfoUnrefFunction)_get_func(info, (SymbolGetter)gi_object_info_get_unref_function_name);
|
2010-06-12 23:08:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-12-12 19:07:50 +01:00
|
|
|
|
* gi_object_info_get_set_value_function_name:
|
2010-06-12 23:08:56 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Obtain the symbol name of the function that should be called to set a
|
|
|
|
|
* [type@GObject.Value], given an object instance pointer of this object type.
|
2010-06-12 23:08:56 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* It’s mainly used for fundamental types. The type signature for the symbol
|
|
|
|
|
* is [type@GIRepository.ObjectInfoSetValueFunction]. To fetch the function
|
|
|
|
|
* pointer see [method@GIRepository.ObjectInfo.get_set_value_function_pointer].
|
|
|
|
|
*
|
|
|
|
|
* Returns: (nullable): the symbol, or `NULL` if the object type has no
|
|
|
|
|
* set-value function
|
|
|
|
|
* Since: 2.80
|
2010-06-12 23:08:56 +02:00
|
|
|
|
*/
|
|
|
|
|
const char *
|
2023-12-12 19:07:50 +01:00
|
|
|
|
gi_object_info_get_set_value_function_name (GIObjectInfo *info)
|
2010-06-12 23:08:56 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
|
|
|
|
|
|
|
|
|
if (blob->set_value_func)
|
2023-11-08 15:17:52 +01:00
|
|
|
|
return gi_typelib_get_string (rinfo->typelib, blob->set_value_func);
|
2010-06-12 23:08:56 +02:00
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_set_value_function_pointer: (skip)
|
2010-06-12 23:08:56 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Obtain a pointer to a function which can be used to set a
|
|
|
|
|
* [type@GObject.Value], given an instance of this object type.
|
|
|
|
|
*
|
2010-06-12 23:08:56 +02:00
|
|
|
|
* This takes derivation into account and will reversely traverse
|
|
|
|
|
* the base classes of this type, starting at the top type.
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (nullable): the function pointer, or `NULL` if the object type has
|
|
|
|
|
* no set-value function
|
|
|
|
|
* Since: 2.80
|
2010-06-12 23:08:56 +02:00
|
|
|
|
*/
|
|
|
|
|
GIObjectInfoSetValueFunction
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_set_value_function_pointer (GIObjectInfo *info)
|
2010-06-12 23:08:56 +02:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
|
|
|
|
|
2023-12-12 19:07:50 +01:00
|
|
|
|
return (GIObjectInfoSetValueFunction)_get_func(info, (SymbolGetter)gi_object_info_get_set_value_function_name);
|
2010-06-12 23:08:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-12-12 19:07:50 +01:00
|
|
|
|
* gi_object_info_get_get_value_function_name:
|
2010-06-12 23:08:56 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
|
|
|
|
* Obtain the symbol name of the function that should be called to convert
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* an object instance pointer of this object type to a [type@GObject.Value].
|
2010-06-12 23:08:56 +02:00
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* It’s mainly used for fundamental types. The type signature for the symbol
|
|
|
|
|
* is [type@GIRepository.ObjectInfoGetValueFunction]. To fetch the function
|
|
|
|
|
* pointer see [method@GIRepository.ObjectInfo.get_get_value_function_pointer].
|
|
|
|
|
*
|
|
|
|
|
* Returns: (nullable): the symbol, or `NULL` if the object type has no
|
|
|
|
|
* get-value function
|
|
|
|
|
* Since: 2.80
|
2010-06-12 23:08:56 +02:00
|
|
|
|
*/
|
|
|
|
|
const char *
|
2023-12-12 19:07:50 +01:00
|
|
|
|
gi_object_info_get_get_value_function_name (GIObjectInfo *info)
|
2010-06-12 23:08:56 +02:00
|
|
|
|
{
|
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
|
|
|
|
ObjectBlob *blob;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
|
|
|
|
|
|
|
|
|
blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
|
|
|
|
|
|
|
|
|
|
if (blob->get_value_func)
|
2023-11-08 15:17:52 +01:00
|
|
|
|
return gi_typelib_get_string (rinfo->typelib, blob->get_value_func);
|
2010-06-12 23:08:56 +02:00
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
|
* gi_object_info_get_get_value_function_pointer: (skip)
|
2010-06-12 23:08:56 +02:00
|
|
|
|
* @info: a #GIObjectInfo
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Obtain a pointer to a function which can be used to extract an instance of
|
|
|
|
|
* this object type out of a [type@GObject.Value].
|
|
|
|
|
*
|
2010-06-12 23:08:56 +02:00
|
|
|
|
* This takes derivation into account and will reversely traverse
|
|
|
|
|
* the base classes of this type, starting at the top type.
|
|
|
|
|
*
|
2023-12-13 14:23:44 +01:00
|
|
|
|
* Returns: (nullable): the function pointer, or `NULL` if the object type has
|
|
|
|
|
* no get-value function
|
|
|
|
|
* Since: 2.80
|
2010-06-12 23:08:56 +02:00
|
|
|
|
*/
|
|
|
|
|
GIObjectInfoGetValueFunction
|
2023-11-08 15:17:52 +01:00
|
|
|
|
gi_object_info_get_get_value_function_pointer (GIObjectInfo *info)
|
2010-06-12 23:08:56 +02:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
|
|
|
|
|
|
2023-12-12 19:07:50 +01:00
|
|
|
|
return (GIObjectInfoGetValueFunction)_get_func(info, (SymbolGetter)gi_object_info_get_get_value_function_name);
|
2010-06-12 23:08:56 +02:00
|
|
|
|
}
|
2023-11-28 18:24:20 +01:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gi_object_info_class_init (gpointer g_class,
|
|
|
|
|
gpointer class_data)
|
|
|
|
|
{
|
|
|
|
|
GIBaseInfoClass *info_class = g_class;
|
|
|
|
|
|
|
|
|
|
info_class->info_type = GI_INFO_TYPE_OBJECT;
|
|
|
|
|
}
|