OSFI-C++  3.9.2
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 #ifdef __cplusplus
30  // In C++ we don't really need (c)stdbool, it's builtin.
31  #if __cplusplus >= 201103L
32  #define OSFI_FFI_NORETURN [[noreturn]] /* In C++11: attribute */
33  #endif
34  #if __cplusplus >= 201402L
35  #define OSFI_FFI_DEPRECATED(reason) [[deprecated(reason)]]
36  #endif
37 #else
38  #include <stdbool.h>
39  #if __STDC_VERSION__ >= 201112L
40  #define OSFI_FFI_NORETURN _Noreturn /* In C11: keyword */
41  #endif
42  /* Deprecated attribute not implemented in standard C */
43 #endif
44 
45 #ifndef OSFI_FFI_NORETURN
46  #define OSFI_FFI_NORETURN
47 #endif
48 
49 #ifndef OSFI_FFI_DEPRECATED
50  #define OSFI_FFI_DEPRECATED(reason)
51 #endif
52 
53 // These are required because directly using a##b does not replace a,b first
54 #define CONCAT_(A,B) A##B
55 #define CONCAT(A,B) CONCAT_(A,B)
56 
58 #define OSFI_FFI_DECL_PLACEHOLDER(name) typedef struct CONCAT(name,_t) name
59 
60 #ifdef OSFI_FFI_IMPL // This macro is defined by the implementation of the FFI layer
61  #undef OSFI_FFI_DECL_PLACEHOLDER
62  #define OSFI_FFI_DECL_PLACEHOLDER(name) /* Empty in the implementation, which defines everything on its own */
63 #endif
64 
68 #define OSFI_VEC_T(Tname) OSFI_Vec_T##Tname
69 #ifndef OSFI_DECL_VEC_T
70 
71  #define OSFI_DECL_VEC_T(Tname, Ttype) \
72  \
73  OSFI_FFI_DECL_PLACEHOLDER(OSFI_VEC_T(Tname))
74 #endif
75 
77 #define OSFI_DECL_VEC_GETTER_simple(Tname, Ttype) \
78  \
79  Ttype osfi_confm_vector_##Tname##_get(const OSFI_VEC_T(Tname) *v, int index); \
80  \
83  int osfi_confm_vector_##Tname##_copyall(const OSFI_VEC_T(Tname) *v, Ttype* arr, int length);
84 
85 #define OSFI_DECL_VEC_GETTER_str(Tname, Ttype) \
86  \
88  int osfi_confm_vector_##Tname##_get(const OSFI_VEC_T(Tname) *v, int index, Ttype buf, int bufSz); \
89  \
93  bool osfi_confm_vector_##Tname##_copyall(const OSFI_VEC_T(Tname) *v, Ttype* strArr, int* itemSz, int* numItems);
94 
96 #define OSFI_DECL_VEC_OPER(Tname, Ttype, kind) \
97  \
98  int osfi_confm_vector_##Tname##_numel(const OSFI_VEC_T(Tname) *v); \
99  \
100  void osfi_confm_vector_##Tname##_destroy(OSFI_VEC_T(Tname) ** obj); \
101  OSFI_DECL_VEC_GETTER_ ## kind(Tname, Ttype);
102 
108 #define OSFI_DECL_VECTOR(Tname, Ttype, kind) \
109  OSFI_DECL_VEC_T(Tname, Ttype); \
110  OSFI_DECL_VEC_OPER(Tname, Ttype, kind)
111 
113 // This is used only in ConFM, but it appears when declaring vector types
116 #endif /* OSFI_FFI_BASE_H */
OSFI_TimeValue
struct OSFI_TimeValue_t OSFI_TimeValue
Definition: ffi_base.h:108
OSFI_FFI_DECL_PLACEHOLDER
#define OSFI_FFI_DECL_PLACEHOLDER(name)
Definition: ffi_base.h:58