LCOV - code coverage report
Current view: top level - glib/girepository - girffi.h (source / functions) Hit Total Coverage
Test: unnamed Lines: 1 1 100.0 %
Date: 2024-05-07 05:15:23 Functions: 1 1 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
       2                 :            :  * GObject introspection: Helper functions for ffi integration
       3                 :            :  *
       4                 :            :  * Copyright (C) 2008 Red Hat, Inc
       5                 :            :  *
       6                 :            :  * SPDX-License-Identifier: LGPL-2.1-or-later
       7                 :            :  *
       8                 :            :  * This library is free software; you can redistribute it and/or
       9                 :            :  * modify it under the terms of the GNU Lesser General Public
      10                 :            :  * License as published by the Free Software Foundation; either
      11                 :            :  * version 2 of the License, or (at your option) any later version.
      12                 :            :  *
      13                 :            :  * This library is distributed in the hope that it will be useful,
      14                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      16                 :            :  * Lesser General Public License for more details.
      17                 :            :  *
      18                 :            :  * You should have received a copy of the GNU Lesser General Public
      19                 :            :  * License along with this library; if not, write to the
      20                 :            :  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      21                 :            :  * Boston, MA 02111-1307, USA.
      22                 :            :  */
      23                 :            : 
      24                 :            : #pragma once
      25                 :            : 
      26                 :            : #if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION)
      27                 :            : #error "Only <girepository.h> can be included directly."
      28                 :            : #endif
      29                 :            : 
      30                 :            : #include <ffi.h>
      31                 :            : #include "girepository.h"
      32                 :            : 
      33                 :            : G_BEGIN_DECLS
      34                 :            : 
      35                 :            : /**
      36                 :            :  * GIFFIClosureCallback:
      37                 :            :  * @cif: the `ffi_cif` passed to
      38                 :            :  *   [method@GIRepository.CallableInfo.create_closure]
      39                 :            :  * @ret: (out caller-allocates): a pointer to the memory used for the function’s
      40                 :            :  *   return value
      41                 :            :  * @args: a vector of pointers to memory holding the arguments to the function
      42                 :            :  * @user_data: the user data passed to
      43                 :            :  *   [method@GIRepository.CallableInfo.create_closure]
      44                 :            :  *
      45                 :            :  * The function which will be called when a closure created with
      46                 :            :  * [method@GIRepository.CallableInfo.create_closure] is invoked.
      47                 :            :  *
      48                 :            :  * The value of @ret is undefined if the function returns `void`.
      49                 :            :  *
      50                 :            :  * Since: 2.80
      51                 :            :  */
      52                 :            : typedef void (*GIFFIClosureCallback) (ffi_cif  *cif,
      53                 :            :                                       void     *ret,
      54                 :            :                                       void    **args,
      55                 :            :                                       void     *user_data);
      56                 :            : 
      57                 :            : /**
      58                 :            :  * GIFunctionInvoker:
      59                 :            :  * @cif: the cif
      60                 :            :  * @native_address: the native address
      61                 :            :  *
      62                 :            :  * Structure containing the data necessary to invoke a callable function.
      63                 :            :  *
      64                 :            :  * Since: 2.80
      65                 :            :  */
      66                 :            : typedef struct {
      67                 :            :   ffi_cif cif;
      68                 :            :   void *native_address;
      69                 :            :   /*< private >*/
      70                 :            :   void *padding[3];
      71                 :            : } GIFunctionInvoker;
      72                 :            : 
      73                 :            : /**
      74                 :            :  * GIFFIReturnValue:
      75                 :            :  *
      76                 :            :  * The type of a return value from a callable invocation closure.
      77                 :            :  *
      78                 :            :  * Since: 2.80
      79                 :            :  */
      80                 :            : typedef GIArgument GIFFIReturnValue;
      81                 :            : 
      82                 :            : GI_AVAILABLE_IN_ALL
      83                 :            : ffi_type *    gi_type_tag_get_ffi_type            (GITypeTag type_tag, gboolean is_pointer);
      84                 :            : 
      85                 :            : GI_AVAILABLE_IN_ALL
      86                 :            : ffi_type *    gi_type_info_get_ffi_type           (GITypeInfo           *info);
      87                 :            : 
      88                 :            : GI_AVAILABLE_IN_ALL
      89                 :            : void          gi_type_info_extract_ffi_return_value (GITypeInfo                  *return_info,
      90                 :            :                                                      GIFFIReturnValue            *ffi_value,
      91                 :            :                                                      GIArgument                  *arg);
      92                 :            : 
      93                 :            : GI_AVAILABLE_IN_ALL
      94                 :            : void          gi_type_tag_extract_ffi_return_value (GITypeTag         return_tag,
      95                 :            :                                                     GType             interface_type,
      96                 :            :                                                     GIFFIReturnValue *ffi_value,
      97                 :            :                                                     GIArgument       *arg);
      98                 :            : 
      99                 :            : GI_AVAILABLE_IN_ALL
     100                 :            : gboolean      gi_function_info_prep_invoker        (GIFunctionInfo       *info,
     101                 :            :                                                     GIFunctionInvoker    *invoker,
     102                 :            :                                                     GError              **error);
     103                 :            : 
     104                 :            : GI_AVAILABLE_IN_ALL
     105                 :            : gboolean      gi_function_invoker_new_for_address  (void                 *addr,
     106                 :            :                                                     GICallableInfo       *info,
     107                 :            :                                                     GIFunctionInvoker    *invoker,
     108                 :            :                                                     GError              **error);
     109                 :            : 
     110                 :            : GI_AVAILABLE_IN_ALL
     111                 :            : void          gi_function_invoker_clear            (GIFunctionInvoker    *invoker);
     112                 :            : 
     113                 :          1 : G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (GIFunctionInvoker, gi_function_invoker_clear)
     114                 :            : 
     115                 :            : GI_AVAILABLE_IN_ALL
     116                 :            : ffi_closure * gi_callable_info_create_closure (GICallableInfo       *callable_info,
     117                 :            :                                                ffi_cif              *cif,
     118                 :            :                                                GIFFIClosureCallback  callback,
     119                 :            :                                                void                 *user_data);
     120                 :            : 
     121                 :            : GI_AVAILABLE_IN_ALL
     122                 :            : void **    gi_callable_info_get_closure_native_address (GICallableInfo       *callable_info,
     123                 :            :                                                         ffi_closure          *closure);
     124                 :            : 
     125                 :            : GI_AVAILABLE_IN_ALL
     126                 :            : void          gi_callable_info_destroy_closure (GICallableInfo       *callable_info,
     127                 :            :                                                 ffi_closure          *closure);
     128                 :            : 
     129                 :            : G_END_DECLS

Generated by: LCOV version 1.14