2012-02-03 19:42:56 +01:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
|
|
|
* GObject introspection: Interface 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 "giinterfaceinfo.h"
|
2010-06-07 00:52:12 +02:00
|
|
|
|
2010-06-12 16:14:36 +02:00
|
|
|
/**
|
|
|
|
* SECTION:giinterfaceinfo
|
2013-10-10 22:21:18 +02:00
|
|
|
* @title: GIInterfaceInfo
|
|
|
|
* @short_description: Struct representing a GInterface
|
2010-06-12 16:14:36 +02:00
|
|
|
*
|
|
|
|
* GIInterfaceInfo represents a #GInterface type.
|
|
|
|
*
|
|
|
|
* A GInterface has methods, fields, properties, signals, interfaces, constants,
|
|
|
|
* virtual functions and prerequisites.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_interface_info_get_n_prerequisites:
|
2010-06-12 16:14:36 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
*
|
|
|
|
* Obtain the number of prerequisites for this interface type.
|
|
|
|
* A prerequisites is another interface that needs to be implemented for
|
|
|
|
* interface, similar to an base class for GObjects.
|
|
|
|
*
|
|
|
|
* Returns: number of prerequisites
|
|
|
|
*/
|
2023-12-12 18:51:07 +01:00
|
|
|
guint
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_get_n_prerequisites (GIInterfaceInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 16:14:36 +02:00
|
|
|
InterfaceBlob *blob;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), 0);
|
|
|
|
|
|
|
|
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
return blob->n_prerequisites;
|
|
|
|
}
|
|
|
|
|
2010-06-12 16:14:36 +02:00
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_interface_info_get_prerequisite:
|
2010-06-12 16:14:36 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
* @n: index of prerequisites to get
|
|
|
|
*
|
|
|
|
* Obtain an interface type prerequisites index @n.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): the prerequisites as a #GIBaseInfo. Free the struct by calling
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_base_info_unref() when done.
|
2010-06-12 16:14:36 +02:00
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
GIBaseInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_get_prerequisite (GIInterfaceInfo *info,
|
2023-12-12 18:51:07 +01:00
|
|
|
guint n)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 16:14:36 +02:00
|
|
|
InterfaceBlob *blob;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL);
|
|
|
|
|
|
|
|
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
2023-11-08 16:23:31 +01:00
|
|
|
return gi_info_from_entry (rinfo->repository,
|
|
|
|
rinfo->typelib, blob->prerequisites[n]);
|
2010-06-07 00:52:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-12 16:14:36 +02:00
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_interface_info_get_n_properties:
|
2010-06-12 16:14:36 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
*
|
|
|
|
* Obtain the number of properties that this interface type has.
|
|
|
|
*
|
|
|
|
* Returns: number of properties
|
|
|
|
*/
|
2023-12-12 18:51:07 +01:00
|
|
|
guint
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_get_n_properties (GIInterfaceInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 16:14:36 +02:00
|
|
|
InterfaceBlob *blob;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), 0);
|
|
|
|
|
|
|
|
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
return blob->n_properties;
|
|
|
|
}
|
|
|
|
|
2010-06-12 16:14:36 +02:00
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_interface_info_get_property:
|
2010-06-12 16:14:36 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
* @n: index of property to get
|
|
|
|
*
|
|
|
|
* Obtain an interface type property at index @n.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): the #GIPropertyInfo. Free the struct by calling
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_base_info_unref() when done.
|
2010-06-12 16:14:36 +02:00
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
GIPropertyInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_get_property (GIInterfaceInfo *info,
|
2023-12-12 18:51:07 +01:00
|
|
|
guint n)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
gint offset;
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 16:14:36 +02:00
|
|
|
Header *header;
|
|
|
|
InterfaceBlob *blob;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL);
|
|
|
|
|
|
|
|
header = (Header *)rinfo->typelib->data;
|
|
|
|
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
offset = rinfo->offset + header->interface_blob_size
|
|
|
|
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
|
|
|
|
+ n * header->property_blob_size;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
return (GIPropertyInfo *) gi_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info,
|
|
|
|
rinfo->typelib, offset);
|
2010-06-07 00:52:12 +02:00
|
|
|
}
|
|
|
|
|
2010-06-12 16:14:36 +02:00
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_interface_info_get_n_methods:
|
2010-06-12 16:14:36 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
*
|
|
|
|
* Obtain the number of methods that this interface type has.
|
|
|
|
*
|
|
|
|
* Returns: number of methods
|
|
|
|
*/
|
2023-12-12 18:51:07 +01:00
|
|
|
guint
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_get_n_methods (GIInterfaceInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 16:14:36 +02:00
|
|
|
InterfaceBlob *blob;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), 0);
|
|
|
|
|
|
|
|
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
return blob->n_methods;
|
|
|
|
}
|
|
|
|
|
2010-06-12 16:14:36 +02:00
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_interface_info_get_method:
|
2010-06-12 16:14:36 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
* @n: index of method to get
|
|
|
|
*
|
|
|
|
* Obtain an interface type method at index @n.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): the #GIFunctionInfo. Free the struct by calling
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_base_info_unref() when done.
|
2010-06-12 16:14:36 +02:00
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
GIFunctionInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_get_method (GIInterfaceInfo *info,
|
2023-12-12 18:51:07 +01:00
|
|
|
guint n)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
gint offset;
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 16:14:36 +02:00
|
|
|
Header *header;
|
|
|
|
InterfaceBlob *blob;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL);
|
|
|
|
|
|
|
|
header = (Header *)rinfo->typelib->data;
|
|
|
|
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
offset = rinfo->offset + header->interface_blob_size
|
|
|
|
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
|
|
|
|
+ blob->n_properties * header->property_blob_size
|
|
|
|
+ n * header->function_blob_size;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
return (GIFunctionInfo *) gi_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
|
|
|
|
rinfo->typelib, offset);
|
2010-06-07 00:52:12 +02:00
|
|
|
}
|
|
|
|
|
2010-06-12 16:14:36 +02:00
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_interface_info_find_method:
|
2010-06-12 16:14:36 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
* @name: name of method to obtain
|
|
|
|
*
|
|
|
|
* Obtain a method of the interface type given a @name. %NULL will be
|
|
|
|
* returned if there's no method available with that name.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): the #GIFunctionInfo or %NULL if none found.
|
2023-11-08 15:17:52 +01:00
|
|
|
* Free the struct by calling gi_base_info_unref() when done.
|
2010-06-12 16:14:36 +02:00
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
GIFunctionInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_find_method (GIInterfaceInfo *info,
|
|
|
|
const gchar *name)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
gint offset;
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
|
|
|
Header *header = (Header *)rinfo->typelib->data;
|
|
|
|
InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
|
|
|
|
|
|
|
|
offset = rinfo->offset + header->interface_blob_size
|
|
|
|
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
|
|
|
|
+ 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-06-12 16:14:36 +02:00
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_interface_info_get_n_signals:
|
2010-06-12 16:14:36 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
*
|
|
|
|
* Obtain the number of signals that this interface type has.
|
|
|
|
*
|
|
|
|
* Returns: number of signals
|
|
|
|
*/
|
2023-12-12 18:51:07 +01:00
|
|
|
guint
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_get_n_signals (GIInterfaceInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 16:14:36 +02:00
|
|
|
InterfaceBlob *blob;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), 0);
|
|
|
|
|
|
|
|
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
return blob->n_signals;
|
|
|
|
}
|
|
|
|
|
2010-06-12 16:14:36 +02:00
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_interface_info_get_signal:
|
2010-06-12 16:14:36 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
* @n: index of signal to get
|
|
|
|
*
|
|
|
|
* Obtain an interface type signal at index @n.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): the #GISignalInfo. Free the struct by calling
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_base_info_unref() when done.
|
2010-06-12 16:14:36 +02:00
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
GISignalInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_get_signal (GIInterfaceInfo *info,
|
2023-12-12 18:51:07 +01:00
|
|
|
guint n)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
gint offset;
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 16:14:36 +02:00
|
|
|
Header *header;
|
|
|
|
InterfaceBlob *blob;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL);
|
|
|
|
|
|
|
|
header = (Header *)rinfo->typelib->data;
|
|
|
|
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
offset = rinfo->offset + header->interface_blob_size
|
|
|
|
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
|
|
|
|
+ blob->n_properties * header->property_blob_size
|
|
|
|
+ blob->n_methods * header->function_blob_size
|
|
|
|
+ n * header->signal_blob_size;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
return (GISignalInfo *) gi_info_new (GI_INFO_TYPE_SIGNAL, (GIBaseInfo*)info,
|
|
|
|
rinfo->typelib, offset);
|
2010-06-07 00:52:12 +02:00
|
|
|
}
|
|
|
|
|
2012-08-25 15:51:15 +02:00
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_interface_info_find_signal:
|
2012-08-25 15:51:15 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
* @name: Name of signal
|
|
|
|
*
|
2013-10-10 22:21:18 +02:00
|
|
|
* TODO
|
|
|
|
*
|
2012-08-25 15:51:15 +02:00
|
|
|
* Returns: (transfer full): Info for the signal with name @name in @info, or
|
|
|
|
* %NULL on failure.
|
2023-11-09 00:24:11 +01:00
|
|
|
* Since: 2.80
|
2012-08-25 15:51:15 +02:00
|
|
|
*/
|
|
|
|
GISignalInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_find_signal (GIInterfaceInfo *info,
|
|
|
|
const gchar *name)
|
2012-08-25 15:51:15 +02:00
|
|
|
{
|
2023-12-12 18:51:07 +01:00
|
|
|
guint n_signals;
|
2012-08-25 15:51:15 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
n_signals = gi_interface_info_get_n_signals (info);
|
2023-12-12 18:51:07 +01:00
|
|
|
for (guint i = 0; i < n_signals; i++)
|
2012-08-25 15:51:15 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GISignalInfo *siginfo = gi_interface_info_get_signal (info, i);
|
2012-08-25 15:51:15 +02:00
|
|
|
|
2023-11-28 18:14:30 +01:00
|
|
|
if (g_strcmp0 (gi_base_info_get_name ((GIBaseInfo *) siginfo), name) != 0)
|
2012-08-25 15:51:15 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo*)siginfo);
|
2012-08-25 15:51:15 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return siginfo;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-12 16:14:36 +02:00
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_interface_info_get_n_vfuncs:
|
2010-06-12 16:14:36 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
*
|
|
|
|
* Obtain the number of virtual functions that this interface type has.
|
|
|
|
*
|
|
|
|
* Returns: number of virtual functions
|
|
|
|
*/
|
2023-12-12 18:51:07 +01:00
|
|
|
guint
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_get_n_vfuncs (GIInterfaceInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 16:14:36 +02:00
|
|
|
InterfaceBlob *blob;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), 0);
|
|
|
|
|
|
|
|
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
return blob->n_vfuncs;
|
|
|
|
}
|
|
|
|
|
2010-06-12 16:14:36 +02:00
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_interface_info_get_vfunc:
|
2010-06-12 16:14:36 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
* @n: index of virtual function to get
|
|
|
|
*
|
|
|
|
* Obtain an interface type virtual function at index @n.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): the #GIVFuncInfo. Free the struct by calling
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_base_info_unref() when done.
|
2010-06-12 16:14:36 +02:00
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
GIVFuncInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_get_vfunc (GIInterfaceInfo *info,
|
2023-12-12 18:51:07 +01:00
|
|
|
guint n)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
gint offset;
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 16:14:36 +02:00
|
|
|
Header *header;
|
|
|
|
InterfaceBlob *blob;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL);
|
|
|
|
|
|
|
|
header = (Header *)rinfo->typelib->data;
|
|
|
|
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
offset = rinfo->offset + header->interface_blob_size
|
|
|
|
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
|
|
|
|
+ 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;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
return (GIVFuncInfo *) gi_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_interface_info_find_vfunc:
|
2010-06-12 16:14:36 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
2010-06-07 00:52:12 +02:00
|
|
|
* @name: The name of a virtual function to find.
|
|
|
|
*
|
|
|
|
* Locate a virtual function slot with name @name. See the documentation
|
2023-11-08 15:17:52 +01:00
|
|
|
* for gi_object_info_find_vfunc() for more information on virtuals.
|
2010-06-07 00:52:12 +02:00
|
|
|
*
|
|
|
|
* Returns: (transfer full): the #GIVFuncInfo, or %NULL. Free it with
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_base_info_unref() when done.
|
2010-06-07 00:52:12 +02:00
|
|
|
*/
|
|
|
|
GIVFuncInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_find_vfunc (GIInterfaceInfo *info,
|
|
|
|
const gchar *name)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
gint offset;
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 16:14:36 +02:00
|
|
|
Header *header;
|
|
|
|
InterfaceBlob *blob;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL);
|
|
|
|
|
|
|
|
header = (Header *)rinfo->typelib->data;
|
|
|
|
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
offset = rinfo->offset + header->interface_blob_size
|
|
|
|
+ (blob->n_prerequisites + blob->n_prerequisites % 2) * 2
|
|
|
|
+ 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
|
|
|
}
|
|
|
|
|
2010-06-12 16:14:36 +02:00
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_interface_info_get_n_constants:
|
2010-06-12 16:14:36 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
*
|
|
|
|
* Obtain the number of constants that this interface type has.
|
|
|
|
*
|
|
|
|
* Returns: number of constants
|
|
|
|
*/
|
2023-12-12 18:51:07 +01:00
|
|
|
guint
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_get_n_constants (GIInterfaceInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 16:14:36 +02:00
|
|
|
InterfaceBlob *blob;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
|
|
|
g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), 0);
|
|
|
|
|
|
|
|
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
return blob->n_constants;
|
|
|
|
}
|
|
|
|
|
2010-06-12 16:14:36 +02:00
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_interface_info_get_constant:
|
2010-06-12 16:14:36 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
* @n: index of constant to get
|
|
|
|
*
|
|
|
|
* Obtain an interface type constant at index @n.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): the #GIConstantInfo. Free the struct by calling
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_base_info_unref() when done.
|
2010-06-12 16:14:36 +02:00
|
|
|
*/
|
2010-06-07 00:52:12 +02:00
|
|
|
GIConstantInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_get_constant (GIInterfaceInfo *info,
|
2023-12-12 18:51:07 +01:00
|
|
|
guint n)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
gint offset;
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 16:14:36 +02:00
|
|
|
Header *header;
|
|
|
|
InterfaceBlob *blob;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL);
|
|
|
|
|
|
|
|
header = (Header *)rinfo->typelib->data;
|
|
|
|
blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];
|
2010-06-07 00:52:12 +02:00
|
|
|
|
|
|
|
offset = rinfo->offset + header->interface_blob_size
|
|
|
|
+ (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
|
|
|
|
+ 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;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
return (GIConstantInfo *) gi_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_interface_info_get_iface_struct:
|
2010-06-07 00:52:12 +02:00
|
|
|
* @info: a #GIInterfaceInfo
|
|
|
|
*
|
|
|
|
* Returns the layout C structure associated with this #GInterface.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): the #GIStructInfo or %NULL. Free it with
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_base_info_unref() when done.
|
2010-06-07 00:52:12 +02:00
|
|
|
*/
|
|
|
|
GIStructInfo *
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_interface_info_get_iface_struct (GIInterfaceInfo *info)
|
2010-06-07 00:52:12 +02:00
|
|
|
{
|
|
|
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
2010-06-12 16:14:36 +02:00
|
|
|
InterfaceBlob *blob;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL);
|
|
|
|
|
|
|
|
blob = (InterfaceBlob *)&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;
|
|
|
|
}
|
|
|
|
|
2023-11-28 18:24:20 +01:00
|
|
|
void
|
|
|
|
gi_interface_info_class_init (gpointer g_class,
|
|
|
|
gpointer class_data)
|
|
|
|
{
|
|
|
|
GIBaseInfoClass *info_class = g_class;
|
|
|
|
|
|
|
|
info_class->info_type = GI_INFO_TYPE_INTERFACE;
|
|
|
|
}
|