OSFI-C++  3.10.0
OpenSF Integration Library
ffi_base.h
Go to the documentation of this file.
1 /*
2  * openSF Integration Libraries (OSFI)
3  * Deimos Space, S.L.U.
4  *
5  * This file is part of OSFI. OSFI is free software; you can redistribute it
6  * and/or modify it under the terms of the 'ESA Software Community Licence Permissive' as
7  * published by the European Space Agency; either version 2.4 of the License,
8  * or (at your option) any later version. You should have received a
9  * copy of the 'ESA Software Community Licence Permissive - v2.4' along with this program
10  * or one can be found at <http://eop-cfi.esa.int/index.php/docs-and-mission-data/licensing-documents>.
11  */
12 
23 #ifndef OSFI_FFI_BASE_H
24 #define OSFI_FFI_BASE_H
25 
29 #if __cplusplus >= 201103L || __STDC_VERSION__ >= 202311L
30  #define OSFI_FFI_NORETURN [[noreturn]] // C++11 or C23: attribute
31 #elif __STDC_VERSION__ >= 201112L
32  #define OSFI_FFI_NORETURN _Noreturn // C11: keyword
33 #else
34  #define OSFI_FFI_NORETURN
35 #endif
36 
37 #if __cplusplus >= 201402L || __STDC_VERSION__ >= 202311L
38  #define OSFI_FFI_DEPRECATED(reason) [[deprecated(reason)]] // C++14 or C23: attribute
39 #else
40  #define OSFI_FFI_DEPRECATED(reason)
41 #endif
42 
43 #ifndef __cplusplus
44  #include <stdbool.h>
45 #endif
46 
47 // These are required because directly using a##b does not replace a,b first
48 #define CONCAT_(A,B) A##B
49 #define CONCAT(A,B) CONCAT_(A,B)
52 #define OSFI_FFI_DECL_PLACEHOLDER(name) typedef struct CONCAT(name,_t) name
53 
54 #ifdef OSFI_FFI_IMPL // This macro is defined by the implementation of the FFI layer
55  #undef OSFI_FFI_DECL_PLACEHOLDER
56  #define OSFI_FFI_DECL_PLACEHOLDER(name) /* Empty in the implementation, which defines everything on its own */
57 #endif
58 
62 #define OSFI_VEC_T(Tname) OSFI_Vec_T##Tname
63 #ifndef OSFI_DECL_VEC_T
65  #define OSFI_DECL_VEC_T(Tname, Ttype) \
66  \
67  OSFI_FFI_DECL_PLACEHOLDER(OSFI_VEC_T(Tname))
68 #endif
69 
71 #define OSFI_DECL_VEC_GETTER_simple(Tname, Ttype) \
72  \
73  Ttype osfi_confm_vector_##Tname##_get(const OSFI_VEC_T(Tname) *v, int index); \
74  \
77  int osfi_confm_vector_##Tname##_copyall(const OSFI_VEC_T(Tname) *v, Ttype* arr, int length);
79 #define OSFI_DECL_VEC_GETTER_str(Tname, Ttype) \
80  \
82  int osfi_confm_vector_##Tname##_get(const OSFI_VEC_T(Tname) *v, int index, Ttype buf, int bufSz); \
83  \
87  bool osfi_confm_vector_##Tname##_copyall(const OSFI_VEC_T(Tname) *v, Ttype* strArr, int* itemSz, int* numItems);
88 
90 #define OSFI_DECL_VEC_OPER(Tname, Ttype, kind) \
91  \
92  int osfi_confm_vector_##Tname##_numel(const OSFI_VEC_T(Tname) *v); \
93  \
94  void osfi_confm_vector_##Tname##_destroy(OSFI_VEC_T(Tname) ** obj); \
95  OSFI_DECL_VEC_GETTER_ ## kind(Tname, Ttype);
96 
102 #define OSFI_DECL_VECTOR(Tname, Ttype, kind) \
103  OSFI_DECL_VEC_T(Tname, Ttype); \
104  OSFI_DECL_VEC_OPER(Tname, Ttype, kind)
107 // This is used only in ConFM, but it appears when declaring vector types
110 #endif /* OSFI_FFI_BASE_H */
#define OSFI_FFI_DECL_PLACEHOLDER(name)
Definition: ffi_base.h:52
struct OSFI_TimeValue_t OSFI_TimeValue
Definition: ffi_base.h:102