LCOV - code coverage report
Current view: top level - glib/girepository - gisignalinfo.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 23 39 59.0 %
Date: 2024-05-07 05:15:23 Functions: 2 4 50.0 %
Branches: 7 16 43.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
       2                 :            :  * GObject introspection: Signal 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 "gisignalinfo.h"
      34                 :            : 
      35                 :            : /**
      36                 :            :  * GISignalInfo:
      37                 :            :  *
      38                 :            :  * `GISignalInfo` represents a signal.
      39                 :            :  *
      40                 :            :  * It’s a sub-struct of [class@GIRepository.CallableInfo] and contains a set of
      41                 :            :  * flags and a class closure.
      42                 :            :  *
      43                 :            :  * See [class@GIRepository.CallableInfo] for information on how to retrieve
      44                 :            :  * arguments and other metadata from the signal.
      45                 :            :  *
      46                 :            :  * Since: 2.80
      47                 :            :  */
      48                 :            : 
      49                 :            : /**
      50                 :            :  * gi_signal_info_get_flags:
      51                 :            :  * @info: a #GISignalInfo
      52                 :            :  *
      53                 :            :  * Obtain the flags for this signal info.
      54                 :            :  *
      55                 :            :  * See [flags@GObject.SignalFlags] for more information about possible flag
      56                 :            :  * values.
      57                 :            :  *
      58                 :            :  * Returns: the flags
      59                 :            :  * Since: 2.80
      60                 :            :  */
      61                 :            : GSignalFlags
      62                 :          1 : gi_signal_info_get_flags (GISignalInfo *info)
      63                 :            : {
      64                 :            :   GSignalFlags flags;
      65                 :          1 :   GIRealInfo *rinfo = (GIRealInfo *)info;
      66                 :            :   SignalBlob *blob;
      67                 :            : 
      68                 :          1 :   g_return_val_if_fail (info != NULL, 0);
      69                 :          1 :   g_return_val_if_fail (GI_IS_SIGNAL_INFO (info), 0);
      70                 :            : 
      71                 :          1 :   blob = (SignalBlob *)&rinfo->typelib->data[rinfo->offset];
      72                 :          1 :   flags = 0;
      73                 :            : 
      74         [ +  - ]:          1 :   if (blob->run_first)
      75                 :          1 :     flags = flags | G_SIGNAL_RUN_FIRST;
      76                 :            : 
      77         [ -  + ]:          1 :   if (blob->run_last)
      78                 :          0 :     flags = flags | G_SIGNAL_RUN_LAST;
      79                 :            : 
      80         [ -  + ]:          1 :   if (blob->run_cleanup)
      81                 :          0 :     flags = flags | G_SIGNAL_RUN_CLEANUP;
      82                 :            : 
      83         [ +  - ]:          1 :   if (blob->no_recurse)
      84                 :          1 :     flags = flags | G_SIGNAL_NO_RECURSE;
      85                 :            : 
      86         [ +  - ]:          1 :   if (blob->detailed)
      87                 :          1 :     flags = flags | G_SIGNAL_DETAILED;
      88                 :            : 
      89         [ +  - ]:          1 :   if (blob->action)
      90                 :          1 :     flags = flags | G_SIGNAL_ACTION;
      91                 :            : 
      92         [ +  - ]:          1 :   if (blob->no_hooks)
      93                 :          1 :     flags = flags | G_SIGNAL_NO_HOOKS;
      94                 :            : 
      95                 :          1 :   return flags;
      96                 :            : }
      97                 :            : 
      98                 :            : /**
      99                 :            :  * gi_signal_info_get_class_closure:
     100                 :            :  * @info: a #GISignalInfo
     101                 :            :  *
     102                 :            :  * Obtain the class closure for this signal if one is set.
     103                 :            :  *
     104                 :            :  * The class closure is a virtual function on the type that the signal belongs
     105                 :            :  * to. If the signal lacks a closure, `NULL` will be returned.
     106                 :            :  *
     107                 :            :  * Returns: (transfer full) (nullable): the class closure, or `NULL` if none is
     108                 :            :  *   set
     109                 :            :  * Since: 2.80
     110                 :            :  */
     111                 :            : GIVFuncInfo *
     112                 :          0 : gi_signal_info_get_class_closure (GISignalInfo *info)
     113                 :            : {
     114                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     115                 :            :   SignalBlob *blob;
     116                 :            : 
     117                 :          0 :   g_return_val_if_fail (info != NULL, 0);
     118                 :          0 :   g_return_val_if_fail (GI_IS_SIGNAL_INFO (info), 0);
     119                 :            : 
     120                 :          0 :   blob = (SignalBlob *)&rinfo->typelib->data[rinfo->offset];
     121                 :            : 
     122         [ #  # ]:          0 :   if (blob->has_class_closure)
     123                 :          0 :     return gi_interface_info_get_vfunc ((GIInterfaceInfo *)rinfo->container, blob->class_closure);
     124                 :            : 
     125                 :          0 :   return NULL;
     126                 :            : }
     127                 :            : 
     128                 :            : /**
     129                 :            :  * gi_signal_info_true_stops_emit:
     130                 :            :  * @info: a #GISignalInfo
     131                 :            :  *
     132                 :            :  * Obtain if the returning `TRUE` in the signal handler will stop the emission
     133                 :            :  * of the signal.
     134                 :            :  *
     135                 :            :  * Returns: `TRUE` if returning `TRUE` stops the signal emission
     136                 :            :  * Since: 2.80
     137                 :            :  */
     138                 :            : gboolean
     139                 :          0 : gi_signal_info_true_stops_emit (GISignalInfo *info)
     140                 :            : {
     141                 :          0 :   GIRealInfo *rinfo = (GIRealInfo *)info;
     142                 :            :   SignalBlob *blob;
     143                 :            : 
     144                 :          0 :   g_return_val_if_fail (info != NULL, 0);
     145                 :          0 :   g_return_val_if_fail (GI_IS_SIGNAL_INFO (info), 0);
     146                 :            : 
     147                 :          0 :   blob = (SignalBlob *)&rinfo->typelib->data[rinfo->offset];
     148                 :            : 
     149                 :          0 :   return blob->true_stops_emit;
     150                 :            : }
     151                 :            : 
     152                 :            : void
     153                 :          2 : gi_signal_info_class_init (gpointer g_class,
     154                 :            :                            gpointer class_data)
     155                 :            : {
     156                 :          2 :   GIBaseInfoClass *info_class = g_class;
     157                 :            : 
     158                 :          2 :   info_class->info_type = GI_INFO_TYPE_SIGNAL;
     159                 :          2 : }

Generated by: LCOV version 1.14