This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/export_headers in repository https://gitbox.apache.org/repos/asf/celix.git
commit 860f7a87a4e9e38a5ff3dfab8ebdd166bac03fdc Author: Pepijn Noltes <[email protected]> AuthorDate: Sun Apr 16 10:34:25 2023 +0200 Add export header for dfi --- libs/dfi/CMakeLists.txt | 24 ++++++++----- libs/dfi/include/avrobin_serializer.h | 9 ++--- libs/dfi/include/dyn_common.h | 13 +++---- libs/dfi/include/dyn_function.h | 29 +++++++-------- libs/dfi/include/dyn_message.h | 22 ++++++------ libs/dfi/include/dyn_type.h | 68 +++++++++++++++++------------------ 6 files changed, 88 insertions(+), 77 deletions(-) diff --git a/libs/dfi/CMakeLists.txt b/libs/dfi/CMakeLists.txt index f011f3f3..d74950f0 100644 --- a/libs/dfi/CMakeLists.txt +++ b/libs/dfi/CMakeLists.txt @@ -36,19 +36,27 @@ if (CELIX_DFI) ) add_library(dfi SHARED ${SOURCES}) - set_target_properties(dfi PROPERTIES OUTPUT_NAME "celix_dfi") target_include_directories(dfi PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> - $<INSTALL_INTERFACE:include/celix/dfi> - ) - target_link_libraries(dfi PRIVATE libffi::libffi) + $<INSTALL_INTERFACE:include/celix/dfi>) + target_link_libraries(dfi PRIVATE libffi::libffi Celix::utils) target_link_libraries(dfi PUBLIC jansson::jansson) - target_link_libraries(dfi PRIVATE Celix::utils) - set_target_properties(dfi PROPERTIES "SOVERSION" 1) + set_target_properties(dfi PROPERTIES + C_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON + VERSION "1.0.0" + "SOVERSION" 1 + OUTPUT_NAME "celix_dfi") + + generate_export_header(utils_obj + BASE_NAME "CELIX_DFI" + EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/celix/gen/includes/dfi/celix_dfi_export.h") + target_include_directories(utils_obj PUBLIC $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/celix/gen/includes/dfi>) install(TARGETS dfi EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dfi - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/dfi) - install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/dfi COMPONENT dfi) + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix_dfi) + install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix_dfi COMPONENT dfi) + install(DIRECTORY ${CMAKE_BINARY_DIR}/celix/gen/includes/dfi/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix_dfi COMPONENT dfi) #Alias setup to match external usage add_library(Celix::dfi ALIAS dfi) diff --git a/libs/dfi/include/avrobin_serializer.h b/libs/dfi/include/avrobin_serializer.h index 5a38e03a..b9a2e4c7 100644 --- a/libs/dfi/include/avrobin_serializer.h +++ b/libs/dfi/include/avrobin_serializer.h @@ -23,6 +23,7 @@ #include "dyn_type.h" #include "dyn_function.h" #include "dyn_interface.h" +#include "celix_df_export.h" #ifdef __cplusplus extern "C" { @@ -31,13 +32,13 @@ extern "C" { //logging DFI_SETUP_LOG_HEADER(avrobinSerializer); -int avrobinSerializer_deserialize(dyn_type *type, const uint8_t *input, size_t inlen, void **result); +CELIX_DFI_DEPRECATED_EXPORT int avrobinSerializer_deserialize(dyn_type *type, const uint8_t *input, size_t inlen, void **result); -int avrobinSerializer_serialize(dyn_type *type, const void *input, uint8_t **output, size_t *outlen); +CELIX_DFI_DEPRECATED_EXPORT int avrobinSerializer_serialize(dyn_type *type, const void *input, uint8_t **output, size_t *outlen); -int avrobinSerializer_generateSchema(dyn_type *type, char **output); +CELIX_DFI_DEPRECATED_EXPORT int avrobinSerializer_generateSchema(dyn_type *type, char **output); -int avrobinSerializer_saveFile(const char *filename, const char *schema, const uint8_t *serdata, size_t serdatalen); +CELIX_DFI_DEPRECATED_EXPORT int avrobinSerializer_saveFile(const char *filename, const char *schema, const uint8_t *serdata, size_t serdatalen); #ifdef __cplusplus } diff --git a/libs/dfi/include/dyn_common.h b/libs/dfi/include/dyn_common.h index 01adcf35..294048b8 100644 --- a/libs/dfi/include/dyn_common.h +++ b/libs/dfi/include/dyn_common.h @@ -26,6 +26,7 @@ #include <sys/queue.h> #include "dfi_log_util.h" +#include "celix_df_export.h" #ifdef __cplusplus extern "C" { @@ -36,18 +37,18 @@ DFI_SETUP_LOG_HEADER(dynCommon) ; TAILQ_HEAD(namvals_head, namval_entry); -struct namval_entry { +struct CELIX_DFI_EXPORT namval_entry { char *name; char *value; TAILQ_ENTRY(namval_entry) entries; }; -int dynCommon_parseName(FILE *stream, char **result); -int dynCommon_parseNameAlsoAccept(FILE *stream, const char *acceptedChars, char **result); -int dynCommon_parseNameValue(FILE *stream, char **name, char **value); -int dynCommon_eatChar(FILE *stream, int c); +CELIX_DFI_EXPORT int dynCommon_parseName(FILE *stream, char **result); +CELIX_DFI_EXPORT int dynCommon_parseNameAlsoAccept(FILE *stream, const char *acceptedChars, char **result); +CELIX_DFI_EXPORT int dynCommon_parseNameValue(FILE *stream, char **name, char **value); +CELIX_DFI_EXPORT int dynCommon_eatChar(FILE *stream, int c); -void dynCommon_clearNamValHead(struct namvals_head *head); +CELIX_DFI_EXPORT void dynCommon_clearNamValHead(struct namvals_head *head); #ifdef __cplusplus } diff --git a/libs/dfi/include/dyn_function.h b/libs/dfi/include/dyn_function.h index d9ec07c6..1f59e981 100644 --- a/libs/dfi/include/dyn_function.h +++ b/libs/dfi/include/dyn_function.h @@ -22,6 +22,7 @@ #include "dyn_type.h" #include "dfi_log_util.h" +#include "celix_df_export.h" #ifdef __cplusplus extern "C" { @@ -47,36 +48,36 @@ typedef struct _dyn_function_type dyn_function_type; DFI_SETUP_LOG_HEADER(dynFunction); DFI_SETUP_LOG_HEADER(dynAvprFunction); -enum dyn_function_argument_meta { +enum CELIX_DFI_EXPORT dyn_function_argument_meta { DYN_FUNCTION_ARGUMENT_META__STD = 0, DYN_FUNCTION_ARGUMENT_META__HANDLE = 1, DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT = 2, DYN_FUNCTION_ARGUMENT_META__OUTPUT = 3 }; -int dynFunction_parse(FILE *descriptorStream, struct types_head *refTypes, dyn_function_type **dynFunc); -int dynFunction_parseWithStr(const char *descriptor, struct types_head *refTypes, dyn_function_type **dynFunc); +CELIX_DFI_EXPORT int dynFunction_parse(FILE *descriptorStream, struct types_head *refTypes, dyn_function_type **dynFunc); +CELIX_DFI_EXPORT int dynFunction_parseWithStr(const char *descriptor, struct types_head *refTypes, dyn_function_type **dynFunc); -int dynFunction_nrOfArguments(dyn_function_type *dynFunc); -dyn_type *dynFunction_argumentTypeForIndex(dyn_function_type *dynFunc, int argumentNr); -enum dyn_function_argument_meta dynFunction_argumentMetaForIndex(dyn_function_type *dynFunc, int argumentNr); -dyn_type * dynFunction_returnType(dyn_function_type *dynFunction); +CELIX_DFI_EXPORT int dynFunction_nrOfArguments(dyn_function_type *dynFunc); +CELIX_DFI_EXPORT dyn_type *dynFunction_argumentTypeForIndex(dyn_function_type *dynFunc, int argumentNr); +CELIX_DFI_EXPORT enum dyn_function_argument_meta dynFunction_argumentMetaForIndex(dyn_function_type *dynFunc, int argumentNr); +CELIX_DFI_EXPORT dyn_type * dynFunction_returnType(dyn_function_type *dynFunction); -void dynFunction_destroy(dyn_function_type *dynFunc); -int dynFunction_call(dyn_function_type *dynFunc, void(*fn)(void), void *returnValue, void **argValues); +CELIX_DFI_EXPORT void dynFunction_destroy(dyn_function_type *dynFunc); +CELIX_DFI_EXPORT int dynFunction_call(dyn_function_type *dynFunc, void(*fn)(void), void *returnValue, void **argValues); -int dynFunction_createClosure(dyn_function_type *func, void (*bind)(void *, void **, void*), void *userData, void(**fn)(void)); -int dynFunction_getFnPointer(dyn_function_type *func, void (**fn)(void)); +CELIX_DFI_EXPORT int dynFunction_createClosure(dyn_function_type *func, void (*bind)(void *, void **, void*), void *userData, void(**fn)(void)); +CELIX_DFI_EXPORT int dynFunction_getFnPointer(dyn_function_type *func, void (**fn)(void)); /** * Returns whether the function has a return type. * Will return false if return is void. */ -bool dynFunction_hasReturn(dyn_function_type *dynFunction); +CELIX_DFI_EXPORT bool dynFunction_hasReturn(dyn_function_type *dynFunction); // Avpr parsing -dyn_function_type * dynFunction_parseAvprWithStr(const char * avpr, const char * fqn); -dyn_function_type * dynFunction_parseAvpr(FILE * avprStream, const char * fqn); +CELIX_DFI_DEPRECATED_EXPORT dyn_function_type * dynFunction_parseAvprWithStr(const char * avpr, const char * fqn); +CELIX_DFI_DEPRECATED_EXPORT dyn_function_type * dynFunction_parseAvpr(FILE * avprStream, const char * fqn); #ifdef __cplusplus } diff --git a/libs/dfi/include/dyn_message.h b/libs/dfi/include/dyn_message.h index 4baf24ce..6b3deeba 100644 --- a/libs/dfi/include/dyn_message.h +++ b/libs/dfi/include/dyn_message.h @@ -23,8 +23,8 @@ #include "dyn_common.h" #include "dyn_type.h" #include "dfi_log_util.h" - #include "celix_version.h" +#include "celix_df_export.h" #ifdef __cplusplus extern "C" { @@ -46,19 +46,19 @@ DFI_SETUP_LOG_HEADER(dynMessage); typedef struct _dyn_message_type dyn_message_type; -int dynMessage_parse(FILE *descriptor, dyn_message_type **out); -void dynMessage_destroy(dyn_message_type *msg); +CELIX_DFI_EXPORT int dynMessage_parse(FILE *descriptor, dyn_message_type **out); +CELIX_DFI_EXPORT void dynMessage_destroy(dyn_message_type *msg); -int dynMessage_getName(dyn_message_type *msg, char **name); -int dynMessage_getVersion(dyn_message_type *msg, celix_version_t** version); -int dynMessage_getVersionString(dyn_message_type *msg, char **version); -int dynMessage_getHeaderEntry(dyn_message_type *msg, const char *name, char **value); -int dynMessage_getAnnotationEntry(dyn_message_type *msg, const char *name, char **value); -int dynMessage_getMessageType(dyn_message_type *msg, dyn_type **type); +CELIX_DFI_EXPORT int dynMessage_getName(dyn_message_type *msg, char **name); +CELIX_DFI_EXPORT int dynMessage_getVersion(dyn_message_type *msg, celix_version_t** version); +CELIX_DFI_EXPORT int dynMessage_getVersionString(dyn_message_type *msg, char **version); +CELIX_DFI_EXPORT int dynMessage_getHeaderEntry(dyn_message_type *msg, const char *name, char **value); +CELIX_DFI_EXPORT int dynMessage_getAnnotationEntry(dyn_message_type *msg, const char *name, char **value); +CELIX_DFI_EXPORT int dynMessage_getMessageType(dyn_message_type *msg, dyn_type **type); // avpr parsing -dyn_message_type * dynMessage_parseAvpr(FILE *avprDescriptorStream, const char *fqn); -dyn_message_type * dynMessage_parseAvprWithStr(const char *avprDescriptor, const char *fqn); +CELIX_DFI_DEPRECATED_EXPORT dyn_message_type * dynMessage_parseAvpr(FILE *avprDescriptorStream, const char *fqn); +CELIX_DFI_DEPRECATED_EXPORT dyn_message_type * dynMessage_parseAvprWithStr(const char *avprDescriptor, const char *fqn); #ifdef __cplusplus } diff --git a/libs/dfi/include/dyn_type.h b/libs/dfi/include/dyn_type.h index 3e63b321..676a68eb 100644 --- a/libs/dfi/include/dyn_type.h +++ b/libs/dfi/include/dyn_type.h @@ -23,10 +23,10 @@ #include <stdio.h> #include <sys/queue.h> #include <stdbool.h> - #include <stdint.h> #include "dfi_log_util.h" +#include "celix_df_export.h" #ifdef __cplusplus extern "C" { @@ -116,20 +116,20 @@ extern "C" { typedef struct _dyn_type dyn_type; TAILQ_HEAD(types_head, type_entry); -struct type_entry { +struct CELIX_DFI_EXPORT type_entry { dyn_type *type; TAILQ_ENTRY(type_entry) entries; }; TAILQ_HEAD(complex_type_entries_head, complex_type_entry); -struct complex_type_entry { +struct CELIX_DFI_EXPORT complex_type_entry { dyn_type *type; char *name; TAILQ_ENTRY(complex_type_entry) entries; }; TAILQ_HEAD(meta_properties_head, meta_entry); -struct meta_entry { +struct CELIX_DFI_EXPORT meta_entry { char *name; char *value; TAILQ_ENTRY(meta_entry) entries; @@ -150,7 +150,7 @@ DFI_SETUP_LOG_HEADER(dynAvprType); * @param type Output argument for the parsed dyn type. * @return 0 if successful. */ -int dynType_parse(FILE *descriptorStream, const char *name, struct types_head *refTypes, dyn_type **type); +CELIX_DFI_EXPORT int dynType_parse(FILE *descriptorStream, const char *name, struct types_head *refTypes, dyn_type **type); /** * Parses a descriptor string and creates a dyn_type (dynamic type). @@ -163,13 +163,13 @@ int dynType_parse(FILE *descriptorStream, const char *name, struct types_head *r * @param type Output argument for the parsed dyn type. * @return 0 if successful. */ -int dynType_parseWithStr(const char *descriptor, const char *name, struct types_head *refTypes, dyn_type **type); +CELIX_DFI_EXPORT int dynType_parseWithStr(const char *descriptor, const char *name, struct types_head *refTypes, dyn_type **type); /** * Destroy a dyn type and de-allocates the memory. * @param type The dyn type to destroy. */ -void dynType_destroy(dyn_type *type); +CELIX_DFI_EXPORT void dynType_destroy(dyn_type *type); /** * Allocates memory for a type instance described by a dyn type. The memory will be 0 allocated (calloc). @@ -178,7 +178,7 @@ void dynType_destroy(dyn_type *type); * @param instance The output argument for the allocated memory. * @return 0 on success. */ -int dynType_alloc(dyn_type *type, void **instance); +CELIX_DFI_EXPORT int dynType_alloc(dyn_type *type, void **instance); /** * free the memory for a type instance described by a dyn type. @@ -187,14 +187,14 @@ int dynType_alloc(dyn_type *type, void **instance); * @param type The dyn type for which structure to allocate. * @param instance The memory location of the type instance. */ -void dynType_free(dyn_type *type, void *instance); +CELIX_DFI_EXPORT void dynType_free(dyn_type *type, void *instance); /** * Prints the dyn type information to the provided output stream. * @param type The dyn type to print. * @param stream The output stream (e.g. stdout). */ -void dynType_print(dyn_type *type, FILE *stream); +CELIX_DFI_EXPORT void dynType_print(dyn_type *type, FILE *stream); /** * Return the size of the structure descripbed by the dyn type. @@ -203,7 +203,7 @@ void dynType_print(dyn_type *type, FILE *stream); * @param type The dyn type. * @return The size of the type instance described by dyn type. */ -size_t dynType_size(dyn_type *type); +CELIX_DFI_EXPORT size_t dynType_size(dyn_type *type); /** * The type of the dyn type @@ -211,7 +211,7 @@ size_t dynType_size(dyn_type *type); * @param type The dyn type * @return The type of the dyn type. */ -int dynType_type(dyn_type *type); +CELIX_DFI_EXPORT int dynType_type(dyn_type *type); /** * Returns the char identifier of the dyn type type. @@ -219,7 +219,7 @@ int dynType_type(dyn_type *type); * @param type The dyn type * @return The descriptor of the dyn type. */ -char dynType_descriptorType(dyn_type *type); +CELIX_DFI_EXPORT char dynType_descriptorType(dyn_type *type); /** * Get the dyn type meta information for the provided name. @@ -227,7 +227,7 @@ char dynType_descriptorType(dyn_type *type); * @param name The name of the requested meta information. * @return The meta information or NULL if the meta information is not present. */ -const char * dynType_getMetaInfo(dyn_type *type, const char *name); +CELIX_DFI_EXPORT const char * dynType_getMetaInfo(dyn_type *type, const char *name); /** * Returns a list of meta entries. @@ -236,12 +236,12 @@ const char * dynType_getMetaInfo(dyn_type *type, const char *name); * @param entries The output arguments for the meta entries. * @return 0 on success. */ -int dynType_metaEntries(dyn_type *type, struct meta_properties_head **entries); +CELIX_DFI_EXPORT int dynType_metaEntries(dyn_type *type, struct meta_properties_head **entries); /** * Returns the name of the dyn type. Name can be NULL. */ -const char * dynType_getName(dyn_type *type); +CELIX_DFI_EXPORT const char * dynType_getName(dyn_type *type); /** @@ -252,7 +252,7 @@ const char * dynType_getName(dyn_type *type); * @param name The field name. * @return The field index or -1 if no field with the name was found. */ -int dynType_complex_indexForName(dyn_type *type, const char *name); +CELIX_DFI_EXPORT int dynType_complex_indexForName(dyn_type *type, const char *name); /** * Returns the field dyn type for a given complex type and a field index. @@ -263,26 +263,26 @@ int dynType_complex_indexForName(dyn_type *type, const char *name); * exists. * @return 0 if successful. */ -int dynType_complex_dynTypeAt(dyn_type *type, int index, dyn_type **subType); +CELIX_DFI_EXPORT int dynType_complex_dynTypeAt(dyn_type *type, int index, dyn_type **subType); -int dynType_complex_setValueAt(dyn_type *type, int index, void *inst, void *in); -int dynType_complex_valLocAt(dyn_type *type, int index, void *inst, void **valLoc); -int dynType_complex_entries(dyn_type *type, struct complex_type_entries_head **entries); -size_t dynType_complex_nrOfEntries(dyn_type *type); +CELIX_DFI_EXPORT int dynType_complex_setValueAt(dyn_type *type, int index, void *inst, void *in); +CELIX_DFI_EXPORT int dynType_complex_valLocAt(dyn_type *type, int index, void *inst, void **valLoc); +CELIX_DFI_EXPORT int dynType_complex_entries(dyn_type *type, struct complex_type_entries_head **entries); +CELIX_DFI_EXPORT size_t dynType_complex_nrOfEntries(dyn_type *type); //sequence /** * Initialize a sequence struct with a cap & len of 0 and the buf to NULL. */ -void dynType_sequence_init(dyn_type *type, void *inst); +CELIX_DFI_EXPORT void dynType_sequence_init(dyn_type *type, void *inst); /** * Allocates memory for a sequence with capacity cap. * Will not free if the existing buf. * Sets len to 0 */ -int dynType_sequence_alloc(dyn_type *type, void *inst, uint32_t cap); +CELIX_DFI_EXPORT int dynType_sequence_alloc(dyn_type *type, void *inst, uint32_t cap); /** * Reserve a sequence capacity of cap @@ -290,25 +290,25 @@ int dynType_sequence_alloc(dyn_type *type, void *inst, uint32_t cap); * Keeps the len value. * Note will not decrease the allocated memory */ -int dynType_sequence_reserve(dyn_type *type, void *inst, uint32_t cap); +CELIX_DFI_EXPORT int dynType_sequence_reserve(dyn_type *type, void *inst, uint32_t cap); -int dynType_sequence_locForIndex(dyn_type *type, void *seqLoc, int index, void **valLoc); -int dynType_sequence_increaseLengthAndReturnLastLoc(dyn_type *type, void *seqLoc, void **valLoc); -dyn_type * dynType_sequence_itemType(dyn_type *type); -uint32_t dynType_sequence_length(void *seqLoc); +CELIX_DFI_EXPORT int dynType_sequence_locForIndex(dyn_type *type, void *seqLoc, int index, void **valLoc); +CELIX_DFI_EXPORT int dynType_sequence_increaseLengthAndReturnLastLoc(dyn_type *type, void *seqLoc, void **valLoc); +CELIX_DFI_EXPORT dyn_type * dynType_sequence_itemType(dyn_type *type); +CELIX_DFI_EXPORT uint32_t dynType_sequence_length(void *seqLoc); //typed pointer -int dynType_typedPointer_getTypedType(dyn_type *type, dyn_type **typedType); +CELIX_DFI_EXPORT int dynType_typedPointer_getTypedType(dyn_type *type, dyn_type **typedType); //text -int dynType_text_allocAndInit(dyn_type *type, void *textLoc, const char *value); +CELIX_DFI_EXPORT int dynType_text_allocAndInit(dyn_type *type, void *textLoc, const char *value); //simple -void dynType_simple_setValue(dyn_type *type, void *inst, void *in); +CELIX_DFI_EXPORT void dynType_simple_setValue(dyn_type *type, void *inst, void *in); // avpr parsing -dyn_type * dynType_parseAvpr(FILE *avprStream, const char *fqn); -dyn_type * dynType_parseAvprWithStr(const char *avpr, const char *fqn); +CELIX_DFI_DEPRECATED_EXPORT dyn_type * dynType_parseAvpr(FILE *avprStream, const char *fqn); +CELIX_DFI_DEPRECATED_EXPORT dyn_type * dynType_parseAvprWithStr(const char *avpr, const char *fqn); #ifdef __cplusplus
