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
The following commit(s) were added to refs/heads/feature/export_headers by this
push:
new 770fb8b5 Revert "Apply clang-format on lib dfi headers"
770fb8b5 is described below
commit 770fb8b5f74298624662cd10dec8fa13a12bc214
Author: Pepijn Noltes <[email protected]>
AuthorDate: Mon Apr 17 20:41:50 2023 +0200
Revert "Apply clang-format on lib dfi headers"
This reverts commit ab09c3f775fbc8d82d71bba5767e0ffb3b5816cf.
---
libs/dfi/include/avrobin_serializer.h | 21 ++---
libs/dfi/include/dfi_log_util.h | 64 ++++++-------
libs/dfi/include/dyn_common.h | 25 +++--
libs/dfi/include/dyn_function.h | 58 +++++-------
libs/dfi/include/dyn_interface.h | 52 ++++------
libs/dfi/include/dyn_message.h | 38 +++-----
libs/dfi/include/dyn_type.h | 173 ++++++++++++++--------------------
libs/dfi/include/json_rpc.h | 19 ++--
libs/dfi/include/json_serializer.h | 24 ++---
9 files changed, 191 insertions(+), 283 deletions(-)
diff --git a/libs/dfi/include/avrobin_serializer.h
b/libs/dfi/include/avrobin_serializer.h
index eb06d8bd..c4f81c20 100644
--- a/libs/dfi/include/avrobin_serializer.h
+++ b/libs/dfi/include/avrobin_serializer.h
@@ -19,33 +19,26 @@
#ifndef __AVROBIN_SERIALIZER_H_
#define __AVROBIN_SERIALIZER_H_
-#include "celix_dfi_export.h"
#include "dfi_log_util.h"
+#include "dyn_type.h"
#include "dyn_function.h"
#include "dyn_interface.h"
-#include "dyn_type.h"
+#include "celix_dfi_export.h"
#ifdef __cplusplus
extern "C" {
#endif
-// logging
+//logging
DFI_SETUP_LOG_HEADER(avrobinSerializer);
-CELIX_DFI_DEPRECATED_EXPORT 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);
-CELIX_DFI_DEPRECATED_EXPORT 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);
-CELIX_DFI_DEPRECATED_EXPORT int avrobinSerializer_generateSchema(dyn_type*
type,
- char**
output);
+CELIX_DFI_DEPRECATED_EXPORT int avrobinSerializer_generateSchema(dyn_type
*type, char **output);
-CELIX_DFI_DEPRECATED_EXPORT 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/dfi_log_util.h b/libs/dfi/include/dfi_log_util.h
index c67bbda5..2f3294b4 100644
--- a/libs/dfi/include/dfi_log_util.h
+++ b/libs/dfi/include/dfi_log_util.h
@@ -26,55 +26,51 @@
extern "C" {
#endif
-typedef void (*logf_ft)(void* handle, int level, const char* file, int line,
- const char* format, ...);
+typedef void (*logf_ft)(void *handle, int level, const char *file, int line,
const char *format, ...);
-#define DFI_SETUP_LOG_HEADER(cmp)
\
- void cmp##_logSetup(logf_ft logf, void* handle, int currentLogLevel);
+#define DFI_SETUP_LOG_HEADER(cmp) \
+ void cmp ## _logSetup(logf_ft logf, void *handle, int currentLogLevel);
-#define DFI_SETUP_LOG(cmp)
\
- static logf_ft g_logf = NULL;
\
- static void* g_logHandle = NULL;
\
- static int g_currentLogLevel = 1;
\
-
\
- CELIX_DFI_EXPORT void cmp##_logSetup(logf_ft logf, void* handle,
\
- int currentLogLevel) {
\
- g_currentLogLevel = currentLogLevel;
\
- g_logHandle = handle;
\
- g_logf = logf;
\
+#define DFI_SETUP_LOG(cmp) \
+ static logf_ft g_logf = NULL; \
+ static void *g_logHandle = NULL; \
+ static int g_currentLogLevel = 1; \
+ \
+ CELIX_DFI_EXPORT void cmp ## _logSetup(logf_ft logf, void *handle, int
currentLogLevel) { \
+ g_currentLogLevel = currentLogLevel; \
+ g_logHandle = handle; \
+ g_logf = logf; \
}
-#define LOG_LVL_ERROR 1
-#define LOG_LVL_WARNING 2
-#define LOG_LVL_INFO 3
-#define LOG_LVL_DEBUG 4
+#define LOG_LVL_ERROR 1
+#define LOG_LVL_WARNING 2
+#define LOG_LVL_INFO 3
+#define LOG_LVL_DEBUG 4
-#define LOG_ERROR(msg, ...)
\
- if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_ERROR) {
\
- g_logf(g_logHandle, LOG_LVL_ERROR, __FILE__, __LINE__, (msg),
\
- ##__VA_ARGS__);
\
+#define LOG_ERROR(msg, ...) \
+ if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_ERROR) { \
+ g_logf(g_logHandle, LOG_LVL_ERROR, __FILE__, __LINE__, (msg),
##__VA_ARGS__); \
}
-#define LOG_WARNING(msg, ...)
\
- if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_WARNING) {
\
- g_logf(g_logHandle, LOG_LVL_WARNING, __FILE__, __LINE__, (msg),
\
- ##__VA_ARGS__);
\
+#define LOG_WARNING(msg, ...) \
+ if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_WARNING) { \
+ g_logf(g_logHandle, LOG_LVL_WARNING, __FILE__, __LINE__, (msg),
##__VA_ARGS__); \
}
-#define LOG_INFO(msg, ...)
\
- if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_INFO) {
\
- g_logf(g_logHandle, LOG_LVL_INFO, __FILE__, __LINE__, (msg),
\
- ##__VA_ARGS__);
\
+#define LOG_INFO(msg, ...) \
+ if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_INFO) { \
+ g_logf(g_logHandle, LOG_LVL_INFO, __FILE__, __LINE__, (msg),
##__VA_ARGS__); \
}
-#define LOG_DEBUG(msg, ...)
\
- if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_DEBUG) {
\
- g_logf(g_logHandle, LOG_LVL_DEBUG, __FILE__, __LINE__, (msg),
\
- ##__VA_ARGS__);
\
+#define LOG_DEBUG(msg, ...) \
+ if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_DEBUG) { \
+ g_logf(g_logHandle, LOG_LVL_DEBUG, __FILE__, __LINE__, (msg),
##__VA_ARGS__); \
}
+
#ifdef __cplusplus
}
#endif
+
#endif
diff --git a/libs/dfi/include/dyn_common.h b/libs/dfi/include/dyn_common.h
index c53c073f..e40bb543 100644
--- a/libs/dfi/include/dyn_common.h
+++ b/libs/dfi/include/dyn_common.h
@@ -25,36 +25,33 @@
#include <string.h>
#include <sys/queue.h>
-#include "celix_dfi_export.h"
#include "dfi_log_util.h"
+#include "celix_dfi_export.h"
#ifdef __cplusplus
extern "C" {
#endif
-// logging
-DFI_SETUP_LOG_HEADER(dynCommon);
+//logging
+DFI_SETUP_LOG_HEADER(dynCommon) ;
TAILQ_HEAD(namvals_head, namval_entry);
struct namval_entry {
- char* name;
- char* value;
+ char *name;
+ char *value;
TAILQ_ENTRY(namval_entry) entries;
};
-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);
+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);
-CELIX_DFI_EXPORT void dynCommon_clearNamValHead(struct namvals_head* head);
+CELIX_DFI_EXPORT void dynCommon_clearNamValHead(struct namvals_head *head);
#ifdef __cplusplus
}
#endif
-#endif
+#endif
diff --git a/libs/dfi/include/dyn_function.h b/libs/dfi/include/dyn_function.h
index 659d233b..36bf8f5a 100644
--- a/libs/dfi/include/dyn_function.h
+++ b/libs/dfi/include/dyn_function.h
@@ -20,9 +20,9 @@
#ifndef __DYN_FUNCTION_H_
#define __DYN_FUNCTION_H_
-#include "celix_dfi_export.h"
-#include "dfi_log_util.h"
#include "dyn_type.h"
+#include "dfi_log_util.h"
+#include "celix_dfi_export.h"
#ifdef __cplusplus
extern "C" {
@@ -32,15 +32,15 @@ extern "C" {
* Uses the following schema
* (Name)([Type]*)Type
*
- * Dyn function argument meta (am) as meta info, with the following possible
- * values am=handle #void pointer for the handle am=pre #output pointer with
- * memory pre-allocated am=out #output pointer
+ * Dyn function argument meta (am) as meta info, with the following possible
values
+ * am=handle #void pointer for the handle
+ * am=pre #output pointer with memory pre-allocated
+ * am=out #output pointer
*
* text argument (t) can also be annotated to be considered const string.
- * Normally a text argument will be handled as char*, meaning that the callee
is
- * expected to take of ownership. If a const=true annotation is used the text
- * argument will be handled as a const char*, meaning that the caller keeps
- * ownership of the string.
+ * Normally a text argument will be handled as char*, meaning that the callee
is expected to take of ownership.
+ * If a const=true annotation is used the text argument will be handled as a
const char*, meaning that the caller
+ * keeps ownership of the string.
*/
typedef struct _dyn_function_type dyn_function_type;
@@ -55,43 +55,29 @@ enum dyn_function_argument_meta {
DYN_FUNCTION_ARGUMENT_META__OUTPUT = 3
};
-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);
+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);
-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);
+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);
-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);
+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);
-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));
+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.
*/
-CELIX_DFI_EXPORT bool dynFunction_hasReturn(dyn_function_type* dynFunction);
+CELIX_DFI_EXPORT bool dynFunction_hasReturn(dyn_function_type *dynFunction);
// Avpr parsing
-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);
+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_interface.h b/libs/dfi/include/dyn_interface.h
index 522d8c27..c05d6b0a 100644
--- a/libs/dfi/include/dyn_interface.h
+++ b/libs/dfi/include/dyn_interface.h
@@ -20,12 +20,12 @@
#ifndef __DYN_INTERFACE_H_
#define __DYN_INTERFACE_H_
-#include "celix_dfi_export.h"
-#include "celix_version.h"
-#include "dfi_log_util.h"
#include "dyn_common.h"
-#include "dyn_function.h"
#include "dyn_type.h"
+#include "dyn_function.h"
+#include "dfi_log_util.h"
+#include "celix_version.h"
+#include "celix_dfi_export.h"
#ifdef __cplusplus
extern "C" {
@@ -36,8 +36,7 @@ DFI_SETUP_LOG_HEADER(dynAvprInterface);
/* Description string
*
- * Descriptor (interface) = HeaderSection AnnotationSection TypesSection
- * MethodsSection
+ * Descriptor (interface) = HeaderSection AnnotationSection TypesSection
MethodsSection
*
* HeaderSection=
* ':header\n' [NameValue]*
@@ -51,38 +50,27 @@ typedef struct _dyn_interface_type dyn_interface_type;
TAILQ_HEAD(methods_head, method_entry);
struct method_entry {
int index;
- char* id;
- char* name;
- dyn_function_type* dynFunc;
+ char *id;
+ char *name;
+ dyn_function_type *dynFunc;
- TAILQ_ENTRY(method_entry) entries;
+ TAILQ_ENTRY(method_entry) entries;
};
-CELIX_DFI_EXPORT int dynInterface_parse(FILE* descriptor,
- dyn_interface_type** out);
-CELIX_DFI_EXPORT void dynInterface_destroy(dyn_interface_type* intf);
+CELIX_DFI_EXPORT int dynInterface_parse(FILE *descriptor, dyn_interface_type
**out);
+CELIX_DFI_EXPORT void dynInterface_destroy(dyn_interface_type *intf);
-CELIX_DFI_EXPORT int dynInterface_getName(dyn_interface_type* intf,
- char** name);
-CELIX_DFI_EXPORT int dynInterface_getVersion(dyn_interface_type* intf,
- celix_version_t** version);
-CELIX_DFI_EXPORT int dynInterface_getVersionString(dyn_interface_type* intf,
- char** version);
-CELIX_DFI_EXPORT int dynInterface_getHeaderEntry(dyn_interface_type* intf,
- const char* name,
- char** value);
-CELIX_DFI_EXPORT int dynInterface_getAnnotationEntry(dyn_interface_type* intf,
- const char* name,
- char** value);
-CELIX_DFI_EXPORT int dynInterface_methods(dyn_interface_type* intf,
- struct methods_head** list);
-CELIX_DFI_EXPORT int dynInterface_nrOfMethods(dyn_interface_type* intf);
+CELIX_DFI_EXPORT int dynInterface_getName(dyn_interface_type *intf, char
**name);
+CELIX_DFI_EXPORT int dynInterface_getVersion(dyn_interface_type *intf,
celix_version_t** version);
+CELIX_DFI_EXPORT int dynInterface_getVersionString(dyn_interface_type *intf,
char **version);
+CELIX_DFI_EXPORT int dynInterface_getHeaderEntry(dyn_interface_type *intf,
const char *name, char **value);
+CELIX_DFI_EXPORT int dynInterface_getAnnotationEntry(dyn_interface_type *intf,
const char *name, char **value);
+CELIX_DFI_EXPORT int dynInterface_methods(dyn_interface_type *intf, struct
methods_head **list);
+CELIX_DFI_EXPORT int dynInterface_nrOfMethods(dyn_interface_type *intf);
// Avpr parsing
-CELIX_DFI_DEPRECATED_EXPORT dyn_interface_type* dynInterface_parseAvprWithStr(
- const char* avpr);
-CELIX_DFI_DEPRECATED_EXPORT dyn_interface_type* dynInterface_parseAvpr(
- FILE* avprStream);
+CELIX_DFI_DEPRECATED_EXPORT dyn_interface_type *
dynInterface_parseAvprWithStr(const char * avpr);
+CELIX_DFI_DEPRECATED_EXPORT dyn_interface_type * dynInterface_parseAvpr(FILE *
avprStream);
#ifdef __cplusplus
}
diff --git a/libs/dfi/include/dyn_message.h b/libs/dfi/include/dyn_message.h
index 3c1a2678..b31892df 100644
--- a/libs/dfi/include/dyn_message.h
+++ b/libs/dfi/include/dyn_message.h
@@ -20,11 +20,11 @@
#ifndef __DYN_MESSAGE_H_
#define __DYN_MESSAGE_H_
-#include "celix_dfi_export.h"
-#include "celix_version.h"
-#include "dfi_log_util.h"
#include "dyn_common.h"
#include "dyn_type.h"
+#include "dfi_log_util.h"
+#include "celix_version.h"
+#include "celix_dfi_export.h"
#ifdef __cplusplus
extern "C" {
@@ -34,8 +34,7 @@ DFI_SETUP_LOG_HEADER(dynMessage);
/* Description string
*
- * Descriptor (message) = HeaderSection AnnotationSection TypesSection
- * MessageSection
+ * Descriptor (message) = HeaderSection AnnotationSection TypesSection
MessageSection
*
* HeaderSection=
* ':header\n' [NameValue]*
@@ -46,27 +45,20 @@ DFI_SETUP_LOG_HEADER(dynMessage);
*/
typedef struct _dyn_message_type dyn_message_type;
-CELIX_DFI_EXPORT int dynMessage_parse(FILE* descriptor, dyn_message_type**
out);
-CELIX_DFI_EXPORT void dynMessage_destroy(dyn_message_type* msg);
-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);
+CELIX_DFI_EXPORT int dynMessage_parse(FILE *descriptor, dyn_message_type
**out);
+CELIX_DFI_EXPORT void dynMessage_destroy(dyn_message_type *msg);
+
+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
-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);
+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 32579ca0..c0f708c3 100644
--- a/libs/dfi/include/dyn_type.h
+++ b/libs/dfi/include/dyn_type.h
@@ -20,36 +20,35 @@
#ifndef _DYN_TYPE_H_
#define _DYN_TYPE_H_
-#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
#include <sys/queue.h>
+#include <stdbool.h>
+#include <stdint.h>
-#include "celix_dfi_export.h"
#include "dfi_log_util.h"
+#include "celix_dfi_export.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(NO_MEMSTREAM_AVAILABLE)
-#include "memstream/fmemopen.h"
#include "memstream/open_memstream.h"
+#include "memstream/fmemopen.h"
#endif
/**
- * dyn type (dynamic type) represent a structure in memory. It can be used to
- * calculate the needed memory size, the size and offset of struct members and
- * can be used to dynamically alloc, initialize, dealloc, read & write
structure
+ * dyn type (dynamic type) represent a structure in memory. It can be used to
calculate the needed memory size, the size
+ * and offset of struct members and can be used to dynamically alloc,
initialize, dealloc, read & write structure
* in memory. In other words it can be used for reflection.
*
* Dyn types can be created by parsing a dyn type descriptor string.
* Dyn type descriptor strings are very compact description of a C structure.
*
* Descriptor strings grammar:
- * Type = [TypeDef]* (MetaInfo)* (SimpleType | ComplexType | SequenceType |
- * TypedPointer | PointerReference ) [TypeDef]* Name = alpha[(alpha|numeric)*]
- * SPACE = ' '
+ * Type = [TypeDef]* (MetaInfo)* (SimpleType | ComplexType | SequenceType |
TypedPointer | PointerReference ) [TypeDef]*
+ * Name = alpha[(alpha|numeric)*]
+ * SPACE = ' '
*
* SimplesTypes (based on java bytecode method signatures)
* //Java based:
@@ -57,9 +56,9 @@ extern "C" {
* C (not supported)
* D double
* F float
- * I int32_t
- * J int64_t
- * S int16_t
+ * I int32_t
+ * J int64_t
+ * S int16_t
* V void
* Z boolean
* //Extended
@@ -73,7 +72,7 @@ extern "C" {
* E enum (int) + meta infos #EnumName=#EnumValue (e.g. #e1=v1;#e2=v2;E)
*
* < Array //TODO
- * <(size)[Type] //TODO
+ * <(size)[Type] //TODO
*
* ComplexTypes (Struct)
* {[Type]+ [(Name)(SPACE)]+}
@@ -84,11 +83,11 @@ extern "C" {
* PointerReference -> note shortcut for *l(name);
* L(Name);
*
- * TypeDef
+ * TypeDef
* T(Name)=Type;
*
- * #OMG style sequence. Struct with uint32_t cap, uint32_t len and a <itemtype>
- * buf[] fields. SequenceType
+ * #OMG style sequence. Struct with uint32_t cap, uint32_t len and a
<itemtype> buf[] fields.
+ * SequenceType
* [(Type)
*
* TypedPointer
@@ -100,9 +99,8 @@ extern "C" {
*
*
* examples
- * "{DDII a b c d}" -> struct { double a; double b; int c; int d; };
- * "{DD{FF c1 c2} a b c}" -> struct { double a; double b; struct c { float c1;
- * float c2; }; };
+ * "{DDII a b c d}" -> struct { double a; double b; int c; int d; };
+ * "{DD{FF c1 c2} a b c}" -> struct { double a; double b; struct c { float c1;
float c2; }; };
*
*
*/
@@ -119,78 +117,68 @@ typedef struct _dyn_type dyn_type;
TAILQ_HEAD(types_head, type_entry);
struct type_entry {
- dyn_type* type;
+ dyn_type *type;
TAILQ_ENTRY(type_entry) entries;
};
TAILQ_HEAD(complex_type_entries_head, complex_type_entry);
struct complex_type_entry {
- dyn_type* type;
- char* name;
+ dyn_type *type;
+ char *name;
TAILQ_ENTRY(complex_type_entry) entries;
};
TAILQ_HEAD(meta_properties_head, meta_entry);
struct meta_entry {
- char* name;
- char* value;
+ char *name;
+ char *value;
TAILQ_ENTRY(meta_entry) entries;
};
-// logging
+//logging
DFI_SETUP_LOG_HEADER(dynType);
DFI_SETUP_LOG_HEADER(dynAvprType);
/**
* Parses a descriptor stream and creates a dyn_type (dynamic type).
* If successful the type output argument points to the newly created dyn type.
- * The caller is the owner of the dyn type and use dynType_destroy deallocate
- * the memory.
+ * The caller is the owner of the dyn type and use dynType_destroy deallocate
the memory.
*
* @param descriptorStream Stream to the descriptor.
- * @param name name for the dyn_type. This can be used in
- * references to dyn types.
+ * @param name name for the dyn_type. This can be used in
references to dyn types.
* @param refTypes A list if reference-able dyn types.
* @param type Output argument for the parsed dyn type.
* @return 0 if successful.
*/
-CELIX_DFI_EXPORT 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).
* If successful the type output argument points to the newly created dyn type.
- * The caller is the owner of the dyn type and use dynType_destroy deallocate
- * the memory.
+ * The caller is the owner of the dyn type and use dynType_destroy deallocate
the memory.
*
* @param descriptor The descriptor.
- * @param name name for the dyn_type. This can be used in
- * references to dyn types.
+ * @param name name for the dyn_type. This can be used in
references to dyn types.
* @param refTypes A list if reference-able dyn types.
* @param type Output argument for the parsed dyn type.
* @return 0 if successful.
*/
-CELIX_DFI_EXPORT 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.
*/
-CELIX_DFI_EXPORT 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).
+ * Allocates memory for a type instance described by a dyn type. The memory
will be 0 allocated (calloc).
* @param type The dyn type for which structure to allocate.
* @param instance The output argument for the allocated memory.
* @return 0 on success.
*/
-CELIX_DFI_EXPORT 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.
@@ -199,24 +187,23 @@ CELIX_DFI_EXPORT 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.
*/
-CELIX_DFI_EXPORT 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).
*/
-CELIX_DFI_EXPORT 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.
- * This this _not_ includes sizes of data where is only pointed to (i.e.
content
- * of sequences, strings, etc).
+ * This this _not_ includes sizes of data where is only pointed to (i.e.
content of sequences, strings, etc).
*
* @param type The dyn type.
* @return The size of the type instance described by dyn type.
*/
-CELIX_DFI_EXPORT size_t dynType_size(dyn_type* type);
+CELIX_DFI_EXPORT size_t dynType_size(dyn_type *type);
/**
* The type of the dyn type
@@ -224,7 +211,7 @@ CELIX_DFI_EXPORT size_t dynType_size(dyn_type* type);
* @param type The dyn type
* @return The type of the dyn type.
*/
-CELIX_DFI_EXPORT int dynType_type(dyn_type* type);
+CELIX_DFI_EXPORT int dynType_type(dyn_type *type);
/**
* Returns the char identifier of the dyn type type.
@@ -232,81 +219,70 @@ CELIX_DFI_EXPORT int dynType_type(dyn_type* type);
* @param type The dyn type
* @return The descriptor of the dyn type.
*/
-CELIX_DFI_EXPORT 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.
* @param type The dyn type.
* @param name The name of the requested meta information.
- * @return The meta information or NULL if the meta information is not
- * present.
+ * @return The meta information or NULL if the meta information is not
present.
*/
-CELIX_DFI_EXPORT 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.
- * Note that dyn type is owner of the entries. Traversing the entries is not
- * thread safe.
+ * Note that dyn type is owner of the entries. Traversing the entries is not
thread safe.
* @param type The dyn type.
* @param entries The output arguments for the meta entries.
* @return 0 on success.
*/
-CELIX_DFI_EXPORT 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.
*/
-CELIX_DFI_EXPORT const char* dynType_getName(dyn_type* type);
+CELIX_DFI_EXPORT const char * dynType_getName(dyn_type *type);
+
/**
* Returns the field index for a complex type.
*
- * e.g. for a struct { int a; int b; }, a will have an index of 0 and b an
index
- * of 1.
+ * e.g. for a struct { int a; int b; }, a will have an index of 0 and b an
index of 1.
* @param type The dyn type. Must be a complex type.
* @param name The field name.
* @return The field index or -1 if no field with the name was found.
*/
-CELIX_DFI_EXPORT 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.
*
* @param type The dyn type. Must be a complex type.
- * @param index The field index for which field the dyn type should be
- * returned. The field index must be correct.
+ * @param index The field index for which field the dyn type should be
returned. The field index must be correct.
* @param subType The field dyn type as output.
* exists.
* @return 0 if successful.
*/
-CELIX_DFI_EXPORT 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);
-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);
+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
+//sequence
/**
* Initialize a sequence struct with a cap & len of 0 and the buf to NULL.
*/
-CELIX_DFI_EXPORT 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
*/
-CELIX_DFI_EXPORT 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
@@ -314,36 +290,29 @@ CELIX_DFI_EXPORT int dynType_sequence_alloc(dyn_type*
type, void* inst,
* Keeps the len value.
* Note will not decrease the allocated memory
*/
-CELIX_DFI_EXPORT 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);
-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);
+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
-CELIX_DFI_EXPORT int dynType_typedPointer_getTypedType(dyn_type* type,
- dyn_type** typedType);
+//typed pointer
+CELIX_DFI_EXPORT int dynType_typedPointer_getTypedType(dyn_type *type,
dyn_type **typedType);
-// text
-CELIX_DFI_EXPORT int dynType_text_allocAndInit(dyn_type* type, void* textLoc,
- const char* value);
+//text
+CELIX_DFI_EXPORT int dynType_text_allocAndInit(dyn_type *type, void *textLoc,
const char *value);
-// simple
-CELIX_DFI_EXPORT void dynType_simple_setValue(dyn_type* type, void* inst,
- void* in);
+//simple
+CELIX_DFI_EXPORT void dynType_simple_setValue(dyn_type *type, void *inst, void
*in);
// avpr parsing
-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);
+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
}
#endif
-#endif //_DYN_TYPE_H_
+#endif //_DYN_TYPE_H_
diff --git a/libs/dfi/include/json_rpc.h b/libs/dfi/include/json_rpc.h
index 45154fdd..95bdb84a 100644
--- a/libs/dfi/include/json_rpc.h
+++ b/libs/dfi/include/json_rpc.h
@@ -21,29 +21,24 @@
#define __JSON_RPC_H_
#include <jansson.h>
-
-#include "celix_dfi_export.h"
#include "dfi_log_util.h"
+#include "dyn_type.h"
#include "dyn_function.h"
#include "dyn_interface.h"
-#include "dyn_type.h"
+#include "celix_dfi_export.h"
#ifdef __cplusplus
extern "C" {
#endif
-// logging
+//logging
DFI_SETUP_LOG_HEADER(jsonRpc);
-CELIX_DFI_EXPORT int jsonRpc_call(dyn_interface_type* intf, void* service,
- const char* request, char** out);
+CELIX_DFI_EXPORT int jsonRpc_call(dyn_interface_type *intf, void *service,
const char *request, char **out);
+
-CELIX_DFI_EXPORT int jsonRpc_prepareInvokeRequest(dyn_function_type* func,
- const char* id, void* args[],
- char** out);
-CELIX_DFI_EXPORT int jsonRpc_handleReply(dyn_function_type* func,
- const char* reply, void* args[],
- int* rsErrno);
+CELIX_DFI_EXPORT int jsonRpc_prepareInvokeRequest(dyn_function_type *func,
const char *id, void *args[], char **out);
+CELIX_DFI_EXPORT int jsonRpc_handleReply(dyn_function_type *func, const char
*reply, void *args[], int *rsErrno);
#ifdef __cplusplus
}
diff --git a/libs/dfi/include/json_serializer.h
b/libs/dfi/include/json_serializer.h
index 8a8c5060..abaf7971 100644
--- a/libs/dfi/include/json_serializer.h
+++ b/libs/dfi/include/json_serializer.h
@@ -21,32 +21,24 @@
#define __JSON_SERIALIZER_H_
#include <jansson.h>
-
-#include "celix_dfi_export.h"
#include "dfi_log_util.h"
+#include "dyn_type.h"
#include "dyn_function.h"
#include "dyn_interface.h"
-#include "dyn_type.h"
+#include "celix_dfi_export.h"
#ifdef __cplusplus
extern "C" {
#endif
-// logging
+//logging
DFI_SETUP_LOG_HEADER(jsonSerializer);
-CELIX_DFI_EXPORT int jsonSerializer_deserialize(dyn_type* type,
- const char* input,
- size_t length, void** result);
-CELIX_DFI_EXPORT int jsonSerializer_deserializeJson(dyn_type* type,
- json_t* input,
- void** result);
-
-CELIX_DFI_EXPORT int jsonSerializer_serialize(dyn_type* type, const void*
input,
- char** output);
-CELIX_DFI_EXPORT int jsonSerializer_serializeJson(dyn_type* type,
- const void* input,
- json_t** out);
+CELIX_DFI_EXPORT int jsonSerializer_deserialize(dyn_type *type, const char
*input, size_t length, void **result);
+CELIX_DFI_EXPORT int jsonSerializer_deserializeJson(dyn_type *type, json_t
*input, void **result);
+
+CELIX_DFI_EXPORT int jsonSerializer_serialize(dyn_type *type, const void*
input, char **output);
+CELIX_DFI_EXPORT int jsonSerializer_serializeJson(dyn_type *type, const void*
input, json_t **out);
#ifdef __cplusplus
}