LCOV - code coverage report
Current view: top level - glib/girepository - givalueinfo.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 4 12 33.3 %
Date: 2024-05-07 05:15:23 Functions: 1 2 50.0 %
Branches: 0 2 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
       2                 :            :  * GObject introspection: Enum 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 "givalueinfo.h"
      34                 :            : 
      35                 :            : /**
      36                 :            :  * GIValueInfo:
      37                 :            :  *
      38                 :            :  * A `GIValueInfo` represents a value in an enumeration.
      39                 :            :  *
      40                 :            :  * The `GIValueInfo` is fetched by calling
      41                 :            :  * [method@GIRepository.EnumInfo.get_value] on a [class@GIRepository.EnumInfo].
      42                 :            :  *
      43                 :            :  * Since: 2.80
      44                 :            :  */
      45                 :            : 
      46                 :            : /**
      47                 :            :  * gi_value_info_get_value:
      48                 :            :  * @info: a #GIValueInfo
      49                 :            :  *
      50                 :            :  * Obtain the enumeration value of the `GIValueInfo`.
      51                 :            :  *
      52                 :            :  * Returns: the enumeration value. This will always be representable
      53                 :            :  *   as a 32-bit signed or unsigned value. The use of `int64_t` as the
      54                 :            :  *   return type is to allow both.
      55                 :            :  * Since: 2.80
      56                 :            :  */
      57                 :            : int64_t
      58                 :          0 : gi_value_info_get_value (GIValueInfo *info)
      59                 :            : {
      60                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
      61                 :            :   ValueBlob *blob;
      62                 :            : 
      63                 :          0 :   g_return_val_if_fail (info != NULL, -1);
      64                 :          0 :   g_return_val_if_fail (GI_IS_VALUE_INFO (info), -1);
      65                 :            : 
      66                 :          0 :   blob = (ValueBlob *)&rinfo->typelib->data[rinfo->offset];
      67                 :            : 
      68         [ #  # ]:          0 :   if (blob->unsigned_value)
      69                 :          0 :     return (int64_t)(uint32_t)blob->value;
      70                 :            :   else
      71                 :          0 :     return (int64_t)blob->value;
      72                 :            : }
      73                 :            : 
      74                 :            : void
      75                 :          2 : gi_value_info_class_init (gpointer g_class,
      76                 :            :                           gpointer class_data)
      77                 :            : {
      78                 :          2 :   GIBaseInfoClass *info_class = g_class;
      79                 :            : 
      80                 :          2 :   info_class->info_type = GI_INFO_TYPE_VALUE;
      81                 :          2 : }

Generated by: LCOV version 1.14