LCOV - code coverage report
Current view: top level - glib/girepository - giobjectinfo.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 167 334 50.0 %
Date: 2024-05-07 05:15:23 Functions: 17 37 45.9 %
Branches: 18 48 37.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
       2                 :            :  * GObject introspection: Object implementation
       3                 :            :  *
       4                 :            :  * Copyright (C) 2005 Matthias Clasen
       5                 :            :  * Copyright (C) 2008,2009 Red Hat, Inc.
       6                 :            :  *
       7                 :            :  * SPDX-License-Identifier: LGPL-2.1-or-later
       8                 :            :  *
       9                 :            :  * This library is free software; you can redistribute it and/or
      10                 :            :  * modify it under the terms of the GNU Lesser General Public
      11                 :            :  * License as published by the Free Software Foundation; either
      12                 :            :  * version 2 of the License, or (at your option) any later version.
      13                 :            :  *
      14                 :            :  * This library is distributed in the hope that it will be useful,
      15                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17                 :            :  * Lesser General Public License for more details.
      18                 :            :  *
      19                 :            :  * You should have received a copy of the GNU Lesser General Public
      20                 :            :  * License along with this library; if not, write to the
      21                 :            :  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      22                 :            :  * Boston, MA 02111-1307, USA.
      23                 :            :  */
      24                 :            : 
      25                 :            : #include "config.h"
      26                 :            : 
      27                 :            : #include <glib.h>
      28                 :            : 
      29                 :            : #include <girepository/girepository.h>
      30                 :            : #include "gibaseinfo-private.h"
      31                 :            : #include "girepository-private.h"
      32                 :            : #include "gitypelib-internal.h"
      33                 :            : #include "giobjectinfo.h"
      34                 :            : 
      35                 :            : /**
      36                 :            :  * GIObjectInfo:
      37                 :            :  *
      38                 :            :  * `GIObjectInfo` represents a classed type.
      39                 :            :  *
      40                 :            :  * Classed types in [type@GObject.Type] inherit from
      41                 :            :  * [type@GObject.TypeInstance]; the most common type is [class@GObject.Object].
      42                 :            :  *
      43                 :            :  * A `GIObjectInfo` doesn’t represent a specific instance of a classed type,
      44                 :            :  * instead this represent the object type (i.e. the class).
      45                 :            :  *
      46                 :            :  * A `GIObjectInfo` has methods, fields, properties, signals, interfaces,
      47                 :            :  * constants and virtual functions.
      48                 :            :  *
      49                 :            :  * Since: 2.80
      50                 :            :  */
      51                 :            : 
      52                 :            : /**
      53                 :            :  * gi_object_info_get_field_offset:
      54                 :            :  * @info: a #GIObjectInfo
      55                 :            :  * @n: index of queried field
      56                 :            :  *
      57                 :            :  * Obtain the offset of the specified field.
      58                 :            :  *
      59                 :            :  * Returns: field offset, in bytes
      60                 :            :  * Since: 2.80
      61                 :            :  */
      62                 :            : static size_t
      63                 :          0 : gi_object_info_get_field_offset (GIObjectInfo *info,
      64                 :            :                                  size_t        n)
      65                 :            : {
      66                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
      67                 :          0 :   Header *header = (Header *)rinfo->typelib->data;
      68                 :          0 :   ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
      69                 :            :   uint32_t offset;
      70                 :            :   FieldBlob *field_blob;
      71                 :            : 
      72                 :          0 :   offset = rinfo->offset + header->object_blob_size
      73                 :          0 :     + (blob->n_interfaces + blob->n_interfaces % 2) * 2;
      74                 :            : 
      75         [ #  # ]:          0 :   for (size_t i = 0; i < n; i++)
      76                 :            :     {
      77                 :          0 :       field_blob = (FieldBlob *)&rinfo->typelib->data[offset];
      78                 :          0 :       offset += header->field_blob_size;
      79         [ #  # ]:          0 :       if (field_blob->has_embedded_type)
      80                 :          0 :         offset += header->callback_blob_size;
      81                 :            :     }
      82                 :            : 
      83                 :          0 :   return offset;
      84                 :            : }
      85                 :            : 
      86                 :            : /**
      87                 :            :  * gi_object_info_get_parent:
      88                 :            :  * @info: a #GIObjectInfo
      89                 :            :  *
      90                 :            :  * Obtain the parent of the object type.
      91                 :            :  *
      92                 :            :  * Returns: (transfer full) (nullable): The `GIObjectInfo`. Free the struct by
      93                 :            :  *   calling [method@GIRepository.BaseInfo.unref] when done.
      94                 :            :  * Since: 2.80
      95                 :            :  */
      96                 :            : GIObjectInfo *
      97                 :          1 : gi_object_info_get_parent (GIObjectInfo *info)
      98                 :            : {
      99                 :          1 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     100                 :            :   ObjectBlob *blob;
     101                 :            : 
     102                 :          1 :   g_return_val_if_fail (info != NULL, NULL);
     103                 :          1 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
     104                 :            : 
     105                 :          1 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     106                 :            : 
     107         [ -  + ]:          1 :   if (blob->parent)
     108                 :          0 :     return (GIObjectInfo *) gi_info_from_entry (rinfo->repository,
     109                 :          0 :                                                 rinfo->typelib, blob->parent);
     110                 :            :   else
     111                 :          1 :     return NULL;
     112                 :            : }
     113                 :            : 
     114                 :            : /**
     115                 :            :  * gi_object_info_get_abstract:
     116                 :            :  * @info: a #GIObjectInfo
     117                 :            :  *
     118                 :            :  * Obtain if the object type is an abstract type, i.e. if it cannot be
     119                 :            :  * instantiated.
     120                 :            :  *
     121                 :            :  * Returns: `TRUE` if the object type is abstract
     122                 :            :  * Since: 2.80
     123                 :            :  */
     124                 :            : gboolean
     125                 :          0 : gi_object_info_get_abstract (GIObjectInfo *info)
     126                 :            : {
     127                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     128                 :            :   ObjectBlob *blob;
     129                 :            : 
     130                 :          0 :   g_return_val_if_fail (info != NULL, FALSE);
     131                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), FALSE);
     132                 :            : 
     133                 :          0 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     134                 :            : 
     135                 :          0 :   return blob->abstract != 0;
     136                 :            : }
     137                 :            : 
     138                 :            : /**
     139                 :            :  * gi_object_info_get_final:
     140                 :            :  * @info: a #GIObjectInfo
     141                 :            :  *
     142                 :            :  * Checks whether the object type is a final type, i.e. if it cannot
     143                 :            :  * be derived.
     144                 :            :  *
     145                 :            :  * Returns: `TRUE` if the object type is final
     146                 :            :  * Since: 2.80
     147                 :            :  */
     148                 :            : gboolean
     149                 :          0 : gi_object_info_get_final (GIObjectInfo *info)
     150                 :            : {
     151                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *) info;
     152                 :            :   ObjectBlob *blob;
     153                 :            : 
     154                 :          0 :   g_return_val_if_fail (info != NULL, FALSE);
     155                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), FALSE);
     156                 :            : 
     157                 :          0 :   blob = (ObjectBlob *) &rinfo->typelib->data[rinfo->offset];
     158                 :            : 
     159                 :          0 :   return blob->final_ != 0;
     160                 :            : }
     161                 :            : 
     162                 :            : /**
     163                 :            :  * gi_object_info_get_fundamental:
     164                 :            :  * @info: a #GIObjectInfo
     165                 :            :  *
     166                 :            :  * Obtain if the object type is of a fundamental type which is not
     167                 :            :  * `G_TYPE_OBJECT`.
     168                 :            :  *
     169                 :            :  * This is mostly for supporting `GstMiniObject`.
     170                 :            :  *
     171                 :            :  * Returns: `TRUE` if the object type is a fundamental type
     172                 :            :  * Since: 2.80
     173                 :            :  */
     174                 :            : gboolean
     175                 :          0 : gi_object_info_get_fundamental (GIObjectInfo *info)
     176                 :            : {
     177                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     178                 :            :   ObjectBlob *blob;
     179                 :            : 
     180                 :          0 :   g_return_val_if_fail (info != NULL, FALSE);
     181                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), FALSE);
     182                 :            : 
     183                 :          0 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     184                 :            : 
     185                 :          0 :   return blob->fundamental != 0;
     186                 :            : }
     187                 :            : 
     188                 :            : /**
     189                 :            :  * gi_object_info_get_type_name:
     190                 :            :  * @info: a #GIObjectInfo
     191                 :            :  *
     192                 :            :  * Obtain the name of the object’s class/type.
     193                 :            :  *
     194                 :            :  * Returns: name of the object’s type
     195                 :            :  * Since: 2.80
     196                 :            :  */
     197                 :            : const char *
     198                 :          0 : gi_object_info_get_type_name (GIObjectInfo *info)
     199                 :            : {
     200                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     201                 :            :   ObjectBlob *blob;
     202                 :            : 
     203                 :          0 :   g_return_val_if_fail (info != NULL, NULL);
     204                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
     205                 :            : 
     206                 :          0 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     207                 :            : 
     208                 :          0 :   return gi_typelib_get_string (rinfo->typelib, blob->gtype_name);
     209                 :            : }
     210                 :            : 
     211                 :            : /**
     212                 :            :  * gi_object_info_get_type_init_function_name:
     213                 :            :  * @info: a #GIObjectInfo
     214                 :            :  *
     215                 :            :  * Obtain the name of the function which, when called, will return the
     216                 :            :  * [type@GObject.Type] for this object type.
     217                 :            :  *
     218                 :            :  * Returns: the type init function name
     219                 :            :  * Since: 2.80
     220                 :            :  */
     221                 :            : const char *
     222                 :          0 : gi_object_info_get_type_init_function_name (GIObjectInfo *info)
     223                 :            : {
     224                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     225                 :            :   ObjectBlob *blob;
     226                 :            : 
     227                 :          0 :   g_return_val_if_fail (info != NULL, NULL);
     228                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
     229                 :            : 
     230                 :          0 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     231                 :            : 
     232                 :          0 :   return gi_typelib_get_string (rinfo->typelib, blob->gtype_init);
     233                 :            : }
     234                 :            : 
     235                 :            : /**
     236                 :            :  * gi_object_info_get_n_interfaces:
     237                 :            :  * @info: a #GIObjectInfo
     238                 :            :  *
     239                 :            :  * Obtain the number of interfaces that this object type has.
     240                 :            :  *
     241                 :            :  * Returns: number of interfaces
     242                 :            :  * Since: 2.80
     243                 :            :  */
     244                 :            : unsigned int
     245                 :          1 : gi_object_info_get_n_interfaces (GIObjectInfo *info)
     246                 :            : {
     247                 :          1 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     248                 :            :   ObjectBlob *blob;
     249                 :            : 
     250                 :          1 :   g_return_val_if_fail (info != NULL, 0);
     251                 :          1 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
     252                 :            : 
     253                 :          1 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     254                 :            : 
     255                 :          1 :   return blob->n_interfaces;
     256                 :            : }
     257                 :            : 
     258                 :            : /**
     259                 :            :  * gi_object_info_get_interface:
     260                 :            :  * @info: a #GIObjectInfo
     261                 :            :  * @n: index of interface to get
     262                 :            :  *
     263                 :            :  * Obtain an object type interface at index @n.
     264                 :            :  *
     265                 :            :  * Returns: (transfer full): The [class@GIRepository.InterfaceInfo]. Free the
     266                 :            :  *   struct by calling [method@GIRepository.BaseInfo.unref] when done.
     267                 :            :  * Since: 2.80
     268                 :            :  */
     269                 :            : GIInterfaceInfo *
     270                 :          3 : gi_object_info_get_interface (GIObjectInfo *info,
     271                 :            :                               unsigned int  n)
     272                 :            : {
     273                 :          3 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     274                 :            :   ObjectBlob *blob;
     275                 :            : 
     276                 :          3 :   g_return_val_if_fail (info != NULL, NULL);
     277                 :          3 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
     278                 :          3 :   g_return_val_if_fail (n <= G_MAXUINT16, NULL);
     279                 :            : 
     280                 :          3 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     281                 :            : 
     282                 :          3 :   return (GIInterfaceInfo *) gi_info_from_entry (rinfo->repository,
     283                 :          3 :                                                  rinfo->typelib, blob->interfaces[n]);
     284                 :            : }
     285                 :            : 
     286                 :            : /**
     287                 :            :  * gi_object_info_get_n_fields:
     288                 :            :  * @info: a #GIObjectInfo
     289                 :            :  *
     290                 :            :  * Obtain the number of fields that this object type has.
     291                 :            :  *
     292                 :            :  * Returns: number of fields
     293                 :            :  * Since: 2.80
     294                 :            :  */
     295                 :            : unsigned int
     296                 :          0 : gi_object_info_get_n_fields (GIObjectInfo *info)
     297                 :            : {
     298                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     299                 :            :   ObjectBlob *blob;
     300                 :            : 
     301                 :          0 :   g_return_val_if_fail (info != NULL, 0);
     302                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
     303                 :            : 
     304                 :          0 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     305                 :            : 
     306                 :          0 :   return blob->n_fields;
     307                 :            : }
     308                 :            : 
     309                 :            : /**
     310                 :            :  * gi_object_info_get_field:
     311                 :            :  * @info: a #GIObjectInfo
     312                 :            :  * @n: index of field to get
     313                 :            :  *
     314                 :            :  * Obtain an object type field at index @n.
     315                 :            :  *
     316                 :            :  * Returns: (transfer full): The [class@GIRepository.FieldInfo]. Free the struct
     317                 :            :  *   by calling [method@GIRepository.BaseInfo.unref] when done.
     318                 :            :  * Since: 2.80
     319                 :            :  */
     320                 :            : GIFieldInfo *
     321                 :          0 : gi_object_info_get_field (GIObjectInfo *info,
     322                 :            :                           unsigned int  n)
     323                 :            : {
     324                 :            :   size_t offset;
     325                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     326                 :            : 
     327                 :          0 :   g_return_val_if_fail (info != NULL, NULL);
     328                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
     329                 :          0 :   g_return_val_if_fail (n <= G_MAXUINT16, NULL);
     330                 :            : 
     331                 :          0 :   offset = gi_object_info_get_field_offset(info, n);
     332                 :            : 
     333                 :          0 :   return (GIFieldInfo *) gi_base_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib, offset);
     334                 :            : }
     335                 :            : 
     336                 :            : /**
     337                 :            :  * gi_object_info_get_n_properties:
     338                 :            :  * @info: a #GIObjectInfo
     339                 :            :  *
     340                 :            :  * Obtain the number of properties that this object type has.
     341                 :            :  *
     342                 :            :  * Returns: number of properties
     343                 :            :  * Since: 2.80
     344                 :            :  */
     345                 :            : unsigned int
     346                 :          0 : gi_object_info_get_n_properties (GIObjectInfo *info)
     347                 :            : {
     348                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     349                 :            :   ObjectBlob *blob;
     350                 :            : 
     351                 :          0 :   g_return_val_if_fail (info != NULL, 0);
     352                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
     353                 :            : 
     354                 :          0 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     355                 :          0 :   return blob->n_properties;
     356                 :            : }
     357                 :            : 
     358                 :            : /**
     359                 :            :  * gi_object_info_get_property:
     360                 :            :  * @info: a #GIObjectInfo
     361                 :            :  * @n: index of property to get
     362                 :            :  *
     363                 :            :  * Obtain an object type property at index @n.
     364                 :            :  *
     365                 :            :  * Returns: (transfer full): The [class@GIRepository.PropertyInfo]. Free the
     366                 :            :  *   struct by calling [method@GIRepository.BaseInfo.unref] when done.
     367                 :            :  * Since: 2.80
     368                 :            :  */
     369                 :            : GIPropertyInfo *
     370                 :          1 : gi_object_info_get_property (GIObjectInfo *info,
     371                 :            :                              unsigned int  n)
     372                 :            : {
     373                 :            :   size_t offset;
     374                 :          1 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     375                 :            :   Header *header;
     376                 :            :   ObjectBlob *blob;
     377                 :            : 
     378                 :          1 :   g_return_val_if_fail (info != NULL, NULL);
     379                 :          1 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
     380                 :          1 :   g_return_val_if_fail (n <= G_MAXUINT16, NULL);
     381                 :            : 
     382                 :          1 :   header = (Header *)rinfo->typelib->data;
     383                 :          1 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     384                 :            : 
     385                 :          1 :   offset = rinfo->offset + header->object_blob_size
     386                 :          1 :     + (blob->n_interfaces + blob->n_interfaces % 2) * 2
     387                 :          1 :     + blob->n_fields * header->field_blob_size
     388                 :          1 :     + blob->n_field_callbacks * header->callback_blob_size
     389                 :          1 :     + n * header->property_blob_size;
     390                 :            : 
     391                 :          1 :   return (GIPropertyInfo *) gi_base_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info,
     392                 :            :                                               rinfo->typelib, offset);
     393                 :            : }
     394                 :            : 
     395                 :            : /**
     396                 :            :  * gi_object_info_get_n_methods:
     397                 :            :  * @info: a #GIObjectInfo
     398                 :            :  *
     399                 :            :  * Obtain the number of methods that this object type has.
     400                 :            :  *
     401                 :            :  * Returns: number of methods
     402                 :            :  * Since: 2.80
     403                 :            :  */
     404                 :            : unsigned int
     405                 :          2 : gi_object_info_get_n_methods (GIObjectInfo *info)
     406                 :            : {
     407                 :          2 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     408                 :            :   ObjectBlob *blob;
     409                 :            : 
     410                 :          2 :   g_return_val_if_fail (info != NULL, 0);
     411                 :          2 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
     412                 :            : 
     413                 :          2 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     414                 :            : 
     415                 :          2 :   return blob->n_methods;
     416                 :            : }
     417                 :            : 
     418                 :            : /**
     419                 :            :  * gi_object_info_get_method:
     420                 :            :  * @info: a #GIObjectInfo
     421                 :            :  * @n: index of method to get
     422                 :            :  *
     423                 :            :  * Obtain an object type method at index @n.
     424                 :            :  *
     425                 :            :  * Returns: (transfer full): The [class@GIRepository.FunctionInfo]. Free the
     426                 :            :  *   struct by calling [method@GIRepository.BaseInfo.unref] when done.
     427                 :            :  * Since: 2.80
     428                 :            :  */
     429                 :            : GIFunctionInfo *
     430                 :          2 : gi_object_info_get_method (GIObjectInfo *info,
     431                 :            :                            unsigned int  n)
     432                 :            : {
     433                 :            :   size_t offset;
     434                 :          2 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     435                 :            :   Header *header;
     436                 :            :   ObjectBlob *blob;
     437                 :            : 
     438                 :          2 :   g_return_val_if_fail (info != NULL, NULL);
     439                 :          2 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
     440                 :          2 :   g_return_val_if_fail (n <= G_MAXUINT16, NULL);
     441                 :            : 
     442                 :          2 :   header = (Header *)rinfo->typelib->data;
     443                 :          2 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     444                 :            : 
     445                 :            : 
     446                 :          2 :   offset = rinfo->offset + header->object_blob_size
     447                 :          2 :     + (blob->n_interfaces + blob->n_interfaces % 2) * 2
     448                 :          2 :     + blob->n_fields * header->field_blob_size
     449                 :          2 :     + blob->n_field_callbacks * header->callback_blob_size
     450                 :          2 :     + blob->n_properties * header->property_blob_size
     451                 :          2 :     + n * header->function_blob_size;
     452                 :            : 
     453                 :          2 :     return (GIFunctionInfo *) gi_base_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
     454                 :            :                                                 rinfo->typelib, offset);
     455                 :            : }
     456                 :            : 
     457                 :            : /**
     458                 :            :  * gi_object_info_find_method:
     459                 :            :  * @info: a #GIObjectInfo
     460                 :            :  * @name: name of method to obtain
     461                 :            :  *
     462                 :            :  * Obtain a method of the object type given a @name.
     463                 :            :  *
     464                 :            :  * `NULL` will be returned if there’s no method available with that name.
     465                 :            :  *
     466                 :            :  * Returns: (transfer full) (nullable): The [class@GIRepository.FunctionInfo],
     467                 :            :  *   or `NULL` if no method could be found. Free the struct by calling
     468                 :            :  *   [method@GIRepository.BaseInfo.unref] when done.
     469                 :            :  * Since: 2.80
     470                 :            :  */
     471                 :            : GIFunctionInfo *
     472                 :         12 : gi_object_info_find_method (GIObjectInfo *info,
     473                 :            :                             const char   *name)
     474                 :            : {
     475                 :            :   size_t offset;
     476                 :         12 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     477                 :            :   Header *header;
     478                 :            :   ObjectBlob *blob;
     479                 :            : 
     480                 :         12 :   g_return_val_if_fail (info != NULL, 0);
     481                 :         12 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
     482                 :            : 
     483                 :         12 :   header = (Header *)rinfo->typelib->data;
     484                 :         12 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     485                 :            : 
     486                 :         12 :   offset = rinfo->offset + header->object_blob_size
     487                 :         12 :     + (blob->n_interfaces + blob->n_interfaces % 2) * 2
     488                 :         12 :     + blob->n_fields * header->field_blob_size +
     489                 :         12 :     + blob->n_field_callbacks * header->callback_blob_size
     490                 :         12 :     + blob->n_properties * header->property_blob_size;
     491                 :            : 
     492                 :         12 :   return gi_base_info_find_method ((GIBaseInfo*)info, offset, blob->n_methods, name);
     493                 :            : }
     494                 :            : 
     495                 :            : /**
     496                 :            :  * gi_object_info_find_method_using_interfaces:
     497                 :            :  * @info: a #GIObjectInfo
     498                 :            :  * @name: name of method to obtain
     499                 :            :  * @declarer: (out) (transfer full) (optional) (nullable): The
     500                 :            :  *   [class@GIRepository.ObjectInfo] or [class@GIRepository.InterfaceInfo] which
     501                 :            :  *   declares the method, or `NULL` to ignore. If no method is found, this will
     502                 :            :  *   return `NULL`.
     503                 :            :  *
     504                 :            :  * Obtain a method of the object given a @name, searching both the
     505                 :            :  * object @info and any interfaces it implements.
     506                 :            :  *
     507                 :            :  * `NULL` will be returned if there’s no method available with that name.
     508                 :            :  *
     509                 :            :  * Note that this function does *not* search parent classes; you will have
     510                 :            :  * to chain up if that’s desired.
     511                 :            :  *
     512                 :            :  * Returns: (transfer full) (nullable): The [class@GIRepository.FunctionInfo],
     513                 :            :  *   or `NULL` if none was found. Free the struct by calling
     514                 :            :  *   [method@GIRepository.BaseInfo.unref] when done.
     515                 :            :  * Since: 2.80
     516                 :            :  */
     517                 :            : GIFunctionInfo *
     518                 :          1 : gi_object_info_find_method_using_interfaces (GIObjectInfo  *info,
     519                 :            :                                              const char    *name,
     520                 :            :                                              GIBaseInfo   **declarer)
     521                 :            : {
     522                 :          1 :   GIFunctionInfo *result = NULL;
     523                 :          1 :   GIBaseInfo *declarer_result = NULL;
     524                 :            : 
     525                 :          1 :   result = gi_object_info_find_method (info, name);
     526         [ -  + ]:          1 :   if (result)
     527                 :          0 :     declarer_result = gi_base_info_ref (info);
     528                 :            : 
     529         [ +  - ]:          1 :   if (result == NULL)
     530                 :            :     {
     531                 :            :       int n_interfaces;
     532                 :            :       int i;
     533                 :            : 
     534                 :          1 :       n_interfaces = gi_object_info_get_n_interfaces (info);
     535         [ +  - ]:          3 :       for (i = 0; i < n_interfaces; ++i)
     536                 :            :         {
     537                 :            :           GIInterfaceInfo *iface_info;
     538                 :            : 
     539                 :          3 :           iface_info = gi_object_info_get_interface (info, i);
     540                 :            : 
     541                 :          3 :           result = gi_interface_info_find_method (iface_info, name);
     542                 :            : 
     543         [ +  + ]:          3 :           if (result != NULL)
     544                 :            :             {
     545                 :          1 :               declarer_result = GI_BASE_INFO (g_steal_pointer (&iface_info));
     546                 :          1 :               break;
     547                 :            :             }
     548                 :          2 :           gi_base_info_unref ((GIBaseInfo*) iface_info);
     549                 :            :         }
     550                 :            :     }
     551                 :            : 
     552         [ +  - ]:          1 :   if (declarer)
     553                 :          1 :     *declarer = g_steal_pointer (&declarer_result);
     554                 :            : 
     555                 :          1 :   g_clear_pointer (&declarer_result, gi_base_info_unref);
     556                 :            : 
     557                 :          1 :   return g_steal_pointer (&result);
     558                 :            : }
     559                 :            : 
     560                 :            : /**
     561                 :            :  * gi_object_info_get_n_signals:
     562                 :            :  * @info: a #GIObjectInfo
     563                 :            :  *
     564                 :            :  * Obtain the number of signals that this object type has.
     565                 :            :  *
     566                 :            :  * Returns: number of signals
     567                 :            :  * Since: 2.80
     568                 :            :  */
     569                 :            : unsigned int
     570                 :          3 : gi_object_info_get_n_signals (GIObjectInfo *info)
     571                 :            : {
     572                 :          3 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     573                 :            :   ObjectBlob *blob;
     574                 :            : 
     575                 :          3 :   g_return_val_if_fail (info != NULL, 0);
     576                 :          3 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
     577                 :            : 
     578                 :          3 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     579                 :            : 
     580                 :          3 :   return blob->n_signals;
     581                 :            : }
     582                 :            : 
     583                 :            : /**
     584                 :            :  * gi_object_info_get_signal:
     585                 :            :  * @info: a #GIObjectInfo
     586                 :            :  * @n: index of signal to get
     587                 :            :  *
     588                 :            :  * Obtain an object type signal at index @n.
     589                 :            :  *
     590                 :            :  * Returns: (transfer full): The [class@GIRepository.SignalInfo]. Free the
     591                 :            :  *   struct by calling [method@GIRepository.BaseInfo.unref] when done.
     592                 :            :  * Since: 2.80
     593                 :            :  */
     594                 :            : GISignalInfo *
     595                 :          3 : gi_object_info_get_signal (GIObjectInfo *info,
     596                 :            :                            unsigned int  n)
     597                 :            : {
     598                 :            :   size_t offset;
     599                 :          3 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     600                 :            :   Header *header;
     601                 :            :   ObjectBlob *blob;
     602                 :            : 
     603                 :          3 :   g_return_val_if_fail (info != NULL, NULL);
     604                 :          3 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
     605                 :          3 :   g_return_val_if_fail (n <= G_MAXUINT16, NULL);
     606                 :            : 
     607                 :          3 :   header = (Header *)rinfo->typelib->data;
     608                 :          3 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     609                 :            : 
     610                 :          3 :   offset = rinfo->offset + header->object_blob_size
     611                 :          3 :     + (blob->n_interfaces + blob->n_interfaces % 2) * 2
     612                 :          3 :     + blob->n_fields * header->field_blob_size
     613                 :          3 :     + blob->n_field_callbacks * header->callback_blob_size
     614                 :          3 :     + blob->n_properties * header->property_blob_size
     615                 :          3 :     + blob->n_methods * header->function_blob_size
     616                 :          3 :     + n * header->signal_blob_size;
     617                 :            : 
     618                 :          3 :   return (GISignalInfo *) gi_base_info_new (GI_INFO_TYPE_SIGNAL, (GIBaseInfo*)info,
     619                 :            :                                             rinfo->typelib, offset);
     620                 :            : }
     621                 :            : 
     622                 :            : /**
     623                 :            :  * gi_object_info_find_signal:
     624                 :            :  * @info: a #GIObjectInfo
     625                 :            :  * @name: name of signal
     626                 :            :  *
     627                 :            :  * Obtain a signal of the object type given a @name.
     628                 :            :  *
     629                 :            :  * `NULL` will be returned if there’s no signal available with that name.
     630                 :            :  *
     631                 :            :  * Returns: (transfer full) (nullable): The [class@GIRepository.SignalInfo],
     632                 :            :  *   or `NULL` if no signal could be found. Free the struct by calling
     633                 :            :  *   [method@GIRepository.BaseInfo.unref] when done.
     634                 :            :  * Since: 2.80
     635                 :            :  */
     636                 :            : GISignalInfo *
     637                 :          3 : gi_object_info_find_signal (GIObjectInfo *info,
     638                 :            :                             const char   *name)
     639                 :            : {
     640                 :            :   size_t n_signals;
     641                 :            : 
     642                 :          3 :   n_signals = gi_object_info_get_n_signals (info);
     643         [ +  - ]:          3 :   for (size_t i = 0; i < n_signals; i++)
     644                 :            :     {
     645                 :          3 :       GISignalInfo *siginfo = gi_object_info_get_signal (info, i);
     646                 :            : 
     647         [ -  + ]:          3 :       if (g_strcmp0 (gi_base_info_get_name ((GIBaseInfo *) siginfo), name) != 0)
     648                 :            :         {
     649                 :          0 :           gi_base_info_unref ((GIBaseInfo*)siginfo);
     650                 :          0 :           continue;
     651                 :            :         }
     652                 :            : 
     653                 :          3 :       return siginfo;
     654                 :            :     }
     655                 :          0 :   return NULL;
     656                 :            : }
     657                 :            : 
     658                 :            : 
     659                 :            : /**
     660                 :            :  * gi_object_info_get_n_vfuncs:
     661                 :            :  * @info: a #GIObjectInfo
     662                 :            :  *
     663                 :            :  * Obtain the number of virtual functions that this object type has.
     664                 :            :  *
     665                 :            :  * Returns: number of virtual functions
     666                 :            :  * Since: 2.80
     667                 :            :  */
     668                 :            : unsigned int
     669                 :          0 : gi_object_info_get_n_vfuncs (GIObjectInfo *info)
     670                 :            : {
     671                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     672                 :            :   ObjectBlob *blob;
     673                 :            : 
     674                 :          0 :   g_return_val_if_fail (info != NULL, 0);
     675                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
     676                 :            : 
     677                 :          0 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     678                 :            : 
     679                 :          0 :   return blob->n_vfuncs;
     680                 :            : }
     681                 :            : 
     682                 :            : /**
     683                 :            :  * gi_object_info_get_vfunc:
     684                 :            :  * @info: a #GIObjectInfo
     685                 :            :  * @n: index of virtual function to get
     686                 :            :  *
     687                 :            :  * Obtain an object type virtual function at index @n.
     688                 :            :  *
     689                 :            :  * Returns: (transfer full): The [class@GIRepository.VFuncInfo]. Free the struct
     690                 :            :  *   by calling [method@GIRepository.BaseInfo.unref] when done.
     691                 :            :  * Since: 2.80
     692                 :            :  */
     693                 :            : GIVFuncInfo *
     694                 :          0 : gi_object_info_get_vfunc (GIObjectInfo *info,
     695                 :            :                           unsigned int  n)
     696                 :            : {
     697                 :            :   size_t offset;
     698                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     699                 :            :   Header *header;
     700                 :            :   ObjectBlob *blob;
     701                 :            : 
     702                 :          0 :   g_return_val_if_fail (info != NULL, NULL);
     703                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
     704                 :          0 :   g_return_val_if_fail (n <= G_MAXUINT16, NULL);
     705                 :            : 
     706                 :          0 :   header = (Header *)rinfo->typelib->data;
     707                 :          0 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     708                 :            : 
     709                 :          0 :   offset = rinfo->offset + header->object_blob_size
     710                 :          0 :     + (blob->n_interfaces + blob->n_interfaces % 2) * 2
     711                 :          0 :     + blob->n_fields * header->field_blob_size
     712                 :          0 :     + blob->n_field_callbacks * header->callback_blob_size
     713                 :          0 :     + blob->n_properties * header->property_blob_size
     714                 :          0 :     + blob->n_methods * header->function_blob_size
     715                 :          0 :     + blob->n_signals * header->signal_blob_size
     716                 :          0 :     + n * header->vfunc_blob_size;
     717                 :            : 
     718                 :          0 :   return (GIVFuncInfo *) gi_base_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*)info,
     719                 :            :                                            rinfo->typelib, offset);
     720                 :            : }
     721                 :            : 
     722                 :            : /**
     723                 :            :  * gi_object_info_find_vfunc:
     724                 :            :  * @info: a #GIObjectInfo
     725                 :            :  * @name: the name of a virtual function to find.
     726                 :            :  *
     727                 :            :  * Locate a virtual function slot with name @name.
     728                 :            :  *
     729                 :            :  * Note that the namespace for virtuals is distinct from that of methods; there
     730                 :            :  * may or may not be a concrete method associated for a virtual. If there is
     731                 :            :  * one, it may be retrieved using [method@GIRepository.VFuncInfo.get_invoker],
     732                 :            :  * otherwise that method will return `NULL`.
     733                 :            :  *
     734                 :            :  * See the documentation for [method@GIRepository.VFuncInfo.get_invoker] for
     735                 :            :  * more information on invoking virtuals.
     736                 :            :  *
     737                 :            :  * Returns: (transfer full) (nullable): The [class@GIRepository.VFuncInfo], or
     738                 :            :  *   `NULL` if none is found. Free it with [method@GIRepository.BaseInfo.unref]
     739                 :            :  *   when done.
     740                 :            :  * Since: 2.80
     741                 :            :  */
     742                 :            : GIVFuncInfo *
     743                 :          3 : gi_object_info_find_vfunc (GIObjectInfo *info,
     744                 :            :                            const char   *name)
     745                 :            : {
     746                 :            :   size_t offset;
     747                 :          3 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     748                 :            :   Header *header;
     749                 :            :   ObjectBlob *blob;
     750                 :            : 
     751                 :          3 :   g_return_val_if_fail (info != NULL, NULL);
     752                 :          3 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
     753                 :            : 
     754                 :          3 :   header = (Header *)rinfo->typelib->data;
     755                 :          3 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     756                 :            : 
     757                 :          3 :   offset = rinfo->offset + header->object_blob_size
     758                 :          3 :     + (blob->n_interfaces + blob->n_interfaces % 2) * 2
     759                 :          3 :     + blob->n_fields * header->field_blob_size
     760                 :          3 :     + blob->n_field_callbacks * header->callback_blob_size
     761                 :          3 :     + blob->n_properties * header->property_blob_size
     762                 :          3 :     + blob->n_methods * header->function_blob_size
     763                 :          3 :     + blob->n_signals * header->signal_blob_size;
     764                 :            : 
     765                 :          3 :   return gi_base_info_find_vfunc (rinfo, offset, blob->n_vfuncs, name);
     766                 :            : }
     767                 :            : 
     768                 :            : /**
     769                 :            :  * gi_object_info_find_vfunc_using_interfaces:
     770                 :            :  * @info: a #GIObjectInfo
     771                 :            :  * @name: name of vfunc to obtain
     772                 :            :  * @declarer: (out) (transfer full) (optional) (nullable): The
     773                 :            :  *   [class@GIRepository.ObjectInfo] or [class@GIRepository.InterfaceInfo] which
     774                 :            :  *   declares the vfunc, or `NULL` to ignore. If no vfunc is found, this will
     775                 :            :  *   return `NULL`.
     776                 :            :  *
     777                 :            :  * Locate a virtual function slot with name @name, searching both the object
     778                 :            :  * @info and any interfaces it implements.
     779                 :            :  *
     780                 :            :  * `NULL` will be returned if there’s no vfunc available with that name.
     781                 :            :  *
     782                 :            :  * Note that the namespace for virtuals is distinct from that of methods; there
     783                 :            :  * may or may not be a concrete method associated for a virtual. If there is
     784                 :            :  * one, it may be retrieved using [method@GIRepository.VFuncInfo.get_invoker],
     785                 :            :  * otherwise that method will return `NULL`.
     786                 :            :  *
     787                 :            :  * Note that this function does *not* search parent classes; you will have
     788                 :            :  * to chain up if that’s desired.
     789                 :            :  *
     790                 :            :  * Returns: (transfer full) (nullable): The [class@GIRepository.VFuncInfo],
     791                 :            :  *   or `NULL` if none was found. Free the struct by calling
     792                 :            :  *   [method@GIRepository.BaseInfo.unref] when done.
     793                 :            :  * Since: 2.80
     794                 :            :  */
     795                 :            : GIVFuncInfo *
     796                 :          1 : gi_object_info_find_vfunc_using_interfaces (GIObjectInfo  *info,
     797                 :            :                                             const char    *name,
     798                 :            :                                             GIBaseInfo   **declarer)
     799                 :            : {
     800                 :          1 :   GIVFuncInfo *result = NULL;
     801                 :          1 :   GIBaseInfo *declarer_result = NULL;
     802                 :            : 
     803                 :          1 :   result = gi_object_info_find_vfunc (info, name);
     804         [ +  - ]:          1 :   if (result)
     805                 :          1 :     declarer_result = gi_base_info_ref (info);
     806                 :            : 
     807         [ -  + ]:          1 :   if (result == NULL)
     808                 :            :     {
     809                 :            :       int n_interfaces;
     810                 :            :       int i;
     811                 :            : 
     812                 :          0 :       n_interfaces = gi_object_info_get_n_interfaces (info);
     813         [ #  # ]:          0 :       for (i = 0; i < n_interfaces; ++i)
     814                 :            :         {
     815                 :            :           GIInterfaceInfo *iface_info;
     816                 :            : 
     817                 :          0 :           iface_info = gi_object_info_get_interface (info, i);
     818                 :            : 
     819                 :          0 :           result = gi_interface_info_find_vfunc (iface_info, name);
     820                 :            : 
     821         [ #  # ]:          0 :           if (result != NULL)
     822                 :            :             {
     823                 :          0 :               declarer_result = GI_BASE_INFO (g_steal_pointer (&iface_info));
     824                 :          0 :               break;
     825                 :            :             }
     826                 :          0 :           gi_base_info_unref ((GIBaseInfo*) iface_info);
     827                 :            :         }
     828                 :            :     }
     829                 :            : 
     830         [ +  - ]:          1 :   if (declarer)
     831                 :          1 :     *declarer = g_steal_pointer (&declarer_result);
     832                 :            : 
     833                 :          1 :   g_clear_pointer (&declarer_result, gi_base_info_unref);
     834                 :            : 
     835                 :          1 :   return g_steal_pointer (&result);
     836                 :            : }
     837                 :            : 
     838                 :            : /**
     839                 :            :  * gi_object_info_get_n_constants:
     840                 :            :  * @info: a #GIObjectInfo
     841                 :            :  *
     842                 :            :  * Obtain the number of constants that this object type has.
     843                 :            :  *
     844                 :            :  * Returns: number of constants
     845                 :            :  * Since: 2.80
     846                 :            :  */
     847                 :            : unsigned int
     848                 :          0 : gi_object_info_get_n_constants (GIObjectInfo *info)
     849                 :            : {
     850                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     851                 :            :   ObjectBlob *blob;
     852                 :            : 
     853                 :          0 :   g_return_val_if_fail (info != NULL, 0);
     854                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), 0);
     855                 :            : 
     856                 :          0 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     857                 :            : 
     858                 :          0 :   return blob->n_constants;
     859                 :            : }
     860                 :            : 
     861                 :            : /**
     862                 :            :  * gi_object_info_get_constant:
     863                 :            :  * @info: a #GIObjectInfo
     864                 :            :  * @n: index of constant to get
     865                 :            :  *
     866                 :            :  * Obtain an object type constant at index @n.
     867                 :            :  *
     868                 :            :  * Returns: (transfer full): The [class@GIRepository.ConstantInfo]. Free the
     869                 :            :  *   struct by calling [method@GIRepository.BaseInfo.unref] when done.
     870                 :            :  * Since: 2.80
     871                 :            :  */
     872                 :            : GIConstantInfo *
     873                 :          0 : gi_object_info_get_constant (GIObjectInfo *info,
     874                 :            :                              unsigned int  n)
     875                 :            : {
     876                 :            :   size_t offset;
     877                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     878                 :            :   Header *header;
     879                 :            :   ObjectBlob *blob;
     880                 :            : 
     881                 :          0 :   g_return_val_if_fail (info != NULL, NULL);
     882                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
     883                 :          0 :   g_return_val_if_fail (n <= G_MAXUINT16, NULL);
     884                 :            : 
     885                 :          0 :   header = (Header *)rinfo->typelib->data;
     886                 :          0 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     887                 :            : 
     888                 :          0 :   offset = rinfo->offset + header->object_blob_size
     889                 :          0 :     + (blob->n_interfaces + blob->n_interfaces % 2) * 2
     890                 :          0 :     + blob->n_fields * header->field_blob_size
     891                 :          0 :     + blob->n_field_callbacks * header->callback_blob_size
     892                 :          0 :     + blob->n_properties * header->property_blob_size
     893                 :          0 :     + blob->n_methods * header->function_blob_size
     894                 :          0 :     + blob->n_signals * header->signal_blob_size
     895                 :          0 :     + blob->n_vfuncs * header->vfunc_blob_size
     896                 :          0 :     + n * header->constant_blob_size;
     897                 :            : 
     898                 :          0 :   return (GIConstantInfo *) gi_base_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info,
     899                 :            :                                               rinfo->typelib, offset);
     900                 :            : }
     901                 :            : 
     902                 :            : /**
     903                 :            :  * gi_object_info_get_class_struct:
     904                 :            :  * @info: a #GIObjectInfo
     905                 :            :  *
     906                 :            :  * Every [class@GObject.Object] has two structures; an instance structure and a
     907                 :            :  * class structure.  This function returns the metadata for the class structure.
     908                 :            :  *
     909                 :            :  * Returns: (transfer full) (nullable): The [class@GIRepository.StructInfo] or
     910                 :            :  *   `NULL` if it’s unknown. Free with [method@GIRepository.BaseInfo.unref] when
     911                 :            :  *   done.
     912                 :            :  * Since: 2.80
     913                 :            :  */
     914                 :            : GIStructInfo *
     915                 :          0 : gi_object_info_get_class_struct (GIObjectInfo *info)
     916                 :            : {
     917                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     918                 :            :   ObjectBlob *blob;
     919                 :            : 
     920                 :          0 :   g_return_val_if_fail (info != NULL, NULL);
     921                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
     922                 :            : 
     923                 :          0 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     924                 :            : 
     925         [ #  # ]:          0 :   if (blob->gtype_struct)
     926                 :          0 :     return (GIStructInfo *) gi_info_from_entry (rinfo->repository,
     927                 :          0 :                                                 rinfo->typelib, blob->gtype_struct);
     928                 :            :   else
     929                 :          0 :     return NULL;
     930                 :            : }
     931                 :            : 
     932                 :            : typedef const char* (*SymbolGetter) (GIObjectInfo *info);
     933                 :            : 
     934                 :            : static void *
     935                 :          1 : _get_func(GIObjectInfo *info,
     936                 :            :           SymbolGetter getter)
     937                 :            : {
     938                 :            :   const char* symbol;
     939                 :          1 :   GSList *parents = NULL, *l;
     940                 :            :   GIObjectInfo *parent_info;
     941                 :          1 :   void *func = NULL;
     942                 :            : 
     943                 :          1 :   parent_info = (GIObjectInfo *) gi_base_info_ref ((GIBaseInfo *) info);
     944         [ +  + ]:          2 :   while (parent_info != NULL)
     945                 :            :     {
     946                 :          1 :       parents = g_slist_prepend (parents, parent_info);
     947                 :          1 :       parent_info = gi_object_info_get_parent (parent_info);
     948                 :            :     }
     949                 :            : 
     950         [ +  - ]:          1 :   for (l = parents; l; l = l->next)
     951                 :            :     {
     952                 :          1 :       parent_info = l->data;
     953                 :          1 :       symbol = getter (parent_info);
     954         [ -  + ]:          1 :       if (symbol == NULL)
     955                 :          0 :         continue;
     956                 :            : 
     957                 :          1 :       gi_typelib_symbol (((GIRealInfo *)parent_info)->typelib, symbol, (gpointer*) &func);
     958         [ +  - ]:          1 :       if (func)
     959                 :          1 :         break;
     960                 :            :     }
     961                 :            : 
     962                 :          1 :   g_slist_free_full (parents, (GDestroyNotify) gi_base_info_unref);
     963                 :          1 :   return func;
     964                 :            : }
     965                 :            : 
     966                 :            : /**
     967                 :            :  * gi_object_info_get_ref_function_name:
     968                 :            :  * @info: a #GIObjectInfo
     969                 :            :  *
     970                 :            :  * Obtain the symbol name of the function that should be called to ref this
     971                 :            :  * object type.
     972                 :            :  *
     973                 :            :  * It’s mainly used for fundamental types. The type signature for
     974                 :            :  * the symbol is [type@GIRepository.ObjectInfoRefFunction]. To fetch the
     975                 :            :  * function pointer see
     976                 :            :  * [method@GIRepository.ObjectInfo.get_ref_function_pointer].
     977                 :            :  *
     978                 :            :  * Returns: (nullable): the symbol, or `NULL` if the object type has no ref
     979                 :            :  *   function
     980                 :            :  * Since: 2.80
     981                 :            :  */
     982                 :            : const char *
     983                 :          1 : gi_object_info_get_ref_function_name (GIObjectInfo *info)
     984                 :            : {
     985                 :          1 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     986                 :            :   ObjectBlob *blob;
     987                 :            : 
     988                 :          1 :   g_return_val_if_fail (info != NULL, NULL);
     989                 :          1 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
     990                 :            : 
     991                 :          1 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
     992                 :            : 
     993         [ +  - ]:          1 :   if (blob->ref_func)
     994                 :          1 :     return gi_typelib_get_string (rinfo->typelib, blob->ref_func);
     995                 :            : 
     996                 :          0 :   return NULL;
     997                 :            : }
     998                 :            : 
     999                 :            : /**
    1000                 :            :  * gi_object_info_get_ref_function_pointer: (skip)
    1001                 :            :  * @info: a #GIObjectInfo
    1002                 :            :  *
    1003                 :            :  * Obtain a pointer to a function which can be used to
    1004                 :            :  * increase the reference count an instance of this object type.
    1005                 :            :  *
    1006                 :            :  * This takes derivation into account and will reversely traverse
    1007                 :            :  * the base classes of this type, starting at the top type.
    1008                 :            :  *
    1009                 :            :  * Returns: (nullable): the function pointer, or `NULL` if the object type has
    1010                 :            :  *   no ref function
    1011                 :            :  * Since: 2.80
    1012                 :            :  */
    1013                 :            : GIObjectInfoRefFunction
    1014                 :          1 : gi_object_info_get_ref_function_pointer (GIObjectInfo *info)
    1015                 :            : {
    1016                 :          1 :   g_return_val_if_fail (info != NULL, NULL);
    1017                 :          1 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
    1018                 :            : 
    1019                 :          1 :   return (GIObjectInfoRefFunction)_get_func(info, (SymbolGetter)gi_object_info_get_ref_function_name);
    1020                 :            : }
    1021                 :            : 
    1022                 :            : /**
    1023                 :            :  * gi_object_info_get_unref_function_name:
    1024                 :            :  * @info: a #GIObjectInfo
    1025                 :            :  *
    1026                 :            :  * Obtain the symbol name of the function that should be called to unref this
    1027                 :            :  * object type.
    1028                 :            :  *
    1029                 :            :  * It’s mainly used for fundamental types. The type signature for the symbol is
    1030                 :            :  * [type@GIRepository.ObjectInfoUnrefFunction]. To fetch the function pointer
    1031                 :            :  * see [method@GIRepository.ObjectInfo.get_unref_function_pointer].
    1032                 :            :  *
    1033                 :            :  * Returns: (nullable): the symbol, or `NULL` if the object type has no unref
    1034                 :            :  *   function
    1035                 :            :  * Since: 2.80
    1036                 :            :  */
    1037                 :            : const char *
    1038                 :          0 : gi_object_info_get_unref_function_name (GIObjectInfo *info)
    1039                 :            : {
    1040                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
    1041                 :            :   ObjectBlob *blob;
    1042                 :            : 
    1043                 :          0 :   g_return_val_if_fail (info != NULL, NULL);
    1044                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
    1045                 :            : 
    1046                 :          0 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
    1047                 :            : 
    1048         [ #  # ]:          0 :   if (blob->unref_func)
    1049                 :          0 :     return gi_typelib_get_string (rinfo->typelib, blob->unref_func);
    1050                 :            : 
    1051                 :          0 :   return NULL;
    1052                 :            : }
    1053                 :            : 
    1054                 :            : /**
    1055                 :            :  * gi_object_info_get_unref_function_pointer: (skip)
    1056                 :            :  * @info: a #GIObjectInfo
    1057                 :            :  *
    1058                 :            :  * Obtain a pointer to a function which can be used to
    1059                 :            :  * decrease the reference count an instance of this object type.
    1060                 :            :  *
    1061                 :            :  * This takes derivation into account and will reversely traverse
    1062                 :            :  * the base classes of this type, starting at the top type.
    1063                 :            :  *
    1064                 :            :  * Returns: (nullable): the function pointer, or `NULL` if the object type has
    1065                 :            :  *   no unref function
    1066                 :            :  * Since: 2.80
    1067                 :            :  */
    1068                 :            : GIObjectInfoUnrefFunction
    1069                 :          0 : gi_object_info_get_unref_function_pointer (GIObjectInfo *info)
    1070                 :            : {
    1071                 :          0 :   g_return_val_if_fail (info != NULL, NULL);
    1072                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
    1073                 :            : 
    1074                 :          0 :   return (GIObjectInfoUnrefFunction)_get_func(info, (SymbolGetter)gi_object_info_get_unref_function_name);
    1075                 :            : }
    1076                 :            : 
    1077                 :            : /**
    1078                 :            :  * gi_object_info_get_set_value_function_name:
    1079                 :            :  * @info: a #GIObjectInfo
    1080                 :            :  *
    1081                 :            :  * Obtain the symbol name of the function that should be called to set a
    1082                 :            :  * [type@GObject.Value], given an object instance pointer of this object type.
    1083                 :            :  *
    1084                 :            :  * It’s mainly used for fundamental types. The type signature for the symbol
    1085                 :            :  * is [type@GIRepository.ObjectInfoSetValueFunction]. To fetch the function
    1086                 :            :  * pointer see [method@GIRepository.ObjectInfo.get_set_value_function_pointer].
    1087                 :            :  *
    1088                 :            :  * Returns: (nullable): the symbol, or `NULL` if the object type has no
    1089                 :            :  *   set-value function
    1090                 :            :  * Since: 2.80
    1091                 :            :  */
    1092                 :            : const char *
    1093                 :          0 : gi_object_info_get_set_value_function_name (GIObjectInfo *info)
    1094                 :            : {
    1095                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
    1096                 :            :   ObjectBlob *blob;
    1097                 :            : 
    1098                 :          0 :   g_return_val_if_fail (info != NULL, NULL);
    1099                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
    1100                 :            : 
    1101                 :          0 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
    1102                 :            : 
    1103         [ #  # ]:          0 :   if (blob->set_value_func)
    1104                 :          0 :     return gi_typelib_get_string (rinfo->typelib, blob->set_value_func);
    1105                 :            : 
    1106                 :          0 :   return NULL;
    1107                 :            : }
    1108                 :            : 
    1109                 :            : /**
    1110                 :            :  * gi_object_info_get_set_value_function_pointer: (skip)
    1111                 :            :  * @info: a #GIObjectInfo
    1112                 :            :  *
    1113                 :            :  * Obtain a pointer to a function which can be used to set a
    1114                 :            :  * [type@GObject.Value], given an instance of this object type.
    1115                 :            :  *
    1116                 :            :  * This takes derivation into account and will reversely traverse
    1117                 :            :  * the base classes of this type, starting at the top type.
    1118                 :            :  *
    1119                 :            :  * Returns: (nullable): the function pointer, or `NULL` if the object type has
    1120                 :            :  *   no set-value function
    1121                 :            :  * Since: 2.80
    1122                 :            :  */
    1123                 :            : GIObjectInfoSetValueFunction
    1124                 :          0 : gi_object_info_get_set_value_function_pointer (GIObjectInfo *info)
    1125                 :            : {
    1126                 :          0 :   g_return_val_if_fail (info != NULL, NULL);
    1127                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
    1128                 :            : 
    1129                 :          0 :   return (GIObjectInfoSetValueFunction)_get_func(info, (SymbolGetter)gi_object_info_get_set_value_function_name);
    1130                 :            : }
    1131                 :            : 
    1132                 :            : /**
    1133                 :            :  * gi_object_info_get_get_value_function_name:
    1134                 :            :  * @info: a #GIObjectInfo
    1135                 :            :  *
    1136                 :            :  * Obtain the symbol name of the function that should be called to convert
    1137                 :            :  * an object instance pointer of this object type to a [type@GObject.Value].
    1138                 :            :  *
    1139                 :            :  * It’s mainly used for fundamental types. The type signature for the symbol
    1140                 :            :  * is [type@GIRepository.ObjectInfoGetValueFunction]. To fetch the function
    1141                 :            :  * pointer see [method@GIRepository.ObjectInfo.get_get_value_function_pointer].
    1142                 :            :  *
    1143                 :            :  * Returns: (nullable): the symbol, or `NULL` if the object type has no
    1144                 :            :  *   get-value function
    1145                 :            :  * Since: 2.80
    1146                 :            :  */
    1147                 :            : const char *
    1148                 :          0 : gi_object_info_get_get_value_function_name (GIObjectInfo *info)
    1149                 :            : {
    1150                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
    1151                 :            :   ObjectBlob *blob;
    1152                 :            : 
    1153                 :          0 :   g_return_val_if_fail (info != NULL, NULL);
    1154                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
    1155                 :            : 
    1156                 :          0 :   blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset];
    1157                 :            : 
    1158         [ #  # ]:          0 :   if (blob->get_value_func)
    1159                 :          0 :     return gi_typelib_get_string (rinfo->typelib, blob->get_value_func);
    1160                 :            : 
    1161                 :          0 :   return NULL;
    1162                 :            : }
    1163                 :            : 
    1164                 :            : /**
    1165                 :            :  * gi_object_info_get_get_value_function_pointer: (skip)
    1166                 :            :  * @info: a #GIObjectInfo
    1167                 :            :  *
    1168                 :            :  * Obtain a pointer to a function which can be used to extract an instance of
    1169                 :            :  * this object type out of a [type@GObject.Value].
    1170                 :            :  *
    1171                 :            :  * This takes derivation into account and will reversely traverse
    1172                 :            :  * the base classes of this type, starting at the top type.
    1173                 :            :  *
    1174                 :            :  * Returns: (nullable): the function pointer, or `NULL` if the object type has
    1175                 :            :  *   no get-value function
    1176                 :            :  * Since: 2.80
    1177                 :            :  */
    1178                 :            : GIObjectInfoGetValueFunction
    1179                 :          0 : gi_object_info_get_get_value_function_pointer (GIObjectInfo *info)
    1180                 :            : {
    1181                 :          0 :   g_return_val_if_fail (info != NULL, NULL);
    1182                 :          0 :   g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL);
    1183                 :            : 
    1184                 :          0 :   return (GIObjectInfoGetValueFunction)_get_func(info, (SymbolGetter)gi_object_info_get_get_value_function_name);
    1185                 :            : }
    1186                 :            : 
    1187                 :            : void
    1188                 :          4 : gi_object_info_class_init (gpointer g_class,
    1189                 :            :                            gpointer class_data)
    1190                 :            : {
    1191                 :          4 :   GIBaseInfoClass *info_class = g_class;
    1192                 :            : 
    1193                 :          4 :   info_class->info_type = GI_INFO_TYPE_OBJECT;
    1194                 :          4 : }

Generated by: LCOV version 1.14