From: Hwankyu Jhun Date: Thu, 30 Jan 2020 10:53:42 +0000 (+0900) Subject: Move macros to internal header X-Git-Tag: accepted/tizen/unified/20200204.125845~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F16%2F223516%2F3;p=platform%2Fcore%2Fbase%2Fbundle.git Move macros to internal header Adds: - bundle_private.h The API, likely and unlikey macros move to bundle_private.h header file. Change-Id: I0bc5ed51e00ac6a5e383f94d33703238aea290f3 Signed-off-by: Hwankyu Jhun --- diff --git a/include/bundle.h b/include/bundle.h index b51aa69..ada3158 100644 --- a/include/bundle.h +++ b/include/bundle.h @@ -35,10 +35,6 @@ extern "C" { # endif -#define API __attribute__((visibility("default"))) -#define likely(x) __builtin_expect(x, 1) -#define unlikely(x) __builtin_expect(x, 0) - /** * @brief Enumeration for error codes of Bundle. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif @@ -130,7 +126,7 @@ typedef void (*bundle_iterator_t) (const char *key, const int type, const bundle bundle_free(b); // Free the bundle * @endcode */ -API bundle *bundle_create(void); +bundle *bundle_create(void); /** @@ -149,7 +145,7 @@ API bundle *bundle_create(void); bundle_free(b); // Free the bundle * @endcode */ -API int bundle_free(bundle *b); +int bundle_free(bundle *b); /** @@ -175,7 +171,7 @@ API int bundle_free(bundle *b); bundle_free(b); * @endcode */ -API int bundle_add_str_array(bundle *b, const char *key, const char **str_array, const int len); +int bundle_add_str_array(bundle *b, const char *key, const char **str_array, const int len); /** @@ -198,7 +194,7 @@ API int bundle_add_str_array(bundle *b, const char *key, const char **str_array, bundle_free(b); * @endcode */ -API int bundle_del(bundle *b, const char *key); +int bundle_del(bundle *b, const char *key); /** @@ -232,7 +228,7 @@ API int bundle_del(bundle *b, const char *key); bundle_free(b); * @endcode */ -API const char **bundle_get_str_array(bundle *b, const char *key, int *len); +const char **bundle_get_str_array(bundle *b, const char *key, int *len); /** @@ -253,7 +249,7 @@ API const char **bundle_get_str_array(bundle *b, const char *key, int *len); bundle_free(b); * @endcode */ -API int bundle_get_count(bundle *b); +int bundle_get_count(bundle *b); /** @@ -269,7 +265,7 @@ API int bundle_get_count(bundle *b); * @pre @a b must be a valid bundle object. * @see bundle_type_t */ -API int bundle_get_type(bundle *b, const char *key); +int bundle_get_type(bundle *b, const char *key); /** @@ -294,7 +290,7 @@ API int bundle_get_type(bundle *b, const char *key); bundle_free(b_dup); * @endcode */ -API bundle *bundle_dup(bundle *b_from); +bundle *bundle_dup(bundle *b_from); /** @@ -350,7 +346,7 @@ API bundle *bundle_dup(bundle *b_from); } * @endcode */ -API void bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data); +void bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data); /** @@ -365,7 +361,7 @@ API void bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data); * @pre @a kv must be a valid bundle_keyval_t object. * @see bundle_foreach() */ -API int bundle_keyval_get_type(bundle_keyval_t *kv); +int bundle_keyval_get_type(bundle_keyval_t *kv); /** @@ -381,7 +377,7 @@ API int bundle_keyval_get_type(bundle_keyval_t *kv); * @pre @a kv must be a valid bundle_keyval_t object. * @see bundle_foreach() */ -API int bundle_keyval_type_is_array(bundle_keyval_t *kv); +int bundle_keyval_type_is_array(bundle_keyval_t *kv); /** @@ -398,7 +394,7 @@ API int bundle_keyval_type_is_array(bundle_keyval_t *kv); * @post @a val and @a size are set. * @see bundle_foreach() */ -API int bundle_keyval_get_basic_val(bundle_keyval_t *kv, void **val, size_t *size); +int bundle_keyval_get_basic_val(bundle_keyval_t *kv, void **val, size_t *size); /** @@ -415,7 +411,7 @@ API int bundle_keyval_get_basic_val(bundle_keyval_t *kv, void **val, size_t *siz * @post @a array_val, @a array_len, @a array_element_size are set. * @see bundle_foreach() */ -API int bundle_keyval_get_array_val(bundle_keyval_t *kv, void ***array_val, unsigned int *array_len, size_t **array_element_size); +int bundle_keyval_get_array_val(bundle_keyval_t *kv, void ***array_val, unsigned int *array_len, size_t **array_element_size); /** @@ -441,7 +437,7 @@ API int bundle_keyval_get_array_val(bundle_keyval_t *kv, void ***array_val, unsi bundle_free(b); * @endcode */ -API int bundle_encode(bundle *b, bundle_raw **r, int *len); +int bundle_encode(bundle *b, bundle_raw **r, int *len); /** @@ -474,7 +470,7 @@ API int bundle_encode(bundle *b, bundle_raw **r, int *len); bundle_free(b_dup); * @endcode */ -API bundle *bundle_decode(const bundle_raw *r, const int len); +bundle *bundle_decode(const bundle_raw *r, const int len); /** @@ -498,7 +494,7 @@ API bundle *bundle_decode(const bundle_raw *r, const int len); bundle_free(b); * @endcode */ -API int bundle_add_str(bundle *b, const char *key, const char *str); +int bundle_add_str(bundle *b, const char *key, const char *str); /** @@ -528,7 +524,7 @@ API int bundle_add_str(bundle *b, const char *key, const char *str); bundle_free(b); * @endcode */ -API int bundle_add_byte(bundle *b, const char *key, const void *bytes, const size_t size); +int bundle_add_byte(bundle *b, const char *key, const void *bytes, const size_t size); /** @@ -557,7 +553,7 @@ API int bundle_add_byte(bundle *b, const char *key, const void *bytes, const siz v = NULL; * @endcode */ -API int bundle_get_str(bundle *b, const char *key, char **str); +int bundle_get_str(bundle *b, const char *key, char **str); /** @@ -592,7 +588,7 @@ API int bundle_get_str(bundle *b, const char *key, char **str); bundle_free(b); // After freeing b, v and n become a dangling pointer * @endcode */ -API int bundle_get_byte(bundle *b, const char *key, void **bytes, size_t *size); +int bundle_get_byte(bundle *b, const char *key, void **bytes, size_t *size); /** * @brief Adds an 'array of byte sequences' type key-value pair into a bundle. @@ -613,7 +609,7 @@ API int bundle_get_byte(bundle *b, const char *key, void **bytes, size_t *size); * @see bundle_get_byte_array() * @see bundle_set_byte_array_element() */ -API int bundle_add_byte_array(bundle *b, const char *key, const unsigned int len); +int bundle_add_byte_array(bundle *b, const char *key, const unsigned int len); /** * @brief Sets an element of an array of byte sequences. @@ -636,7 +632,7 @@ API int bundle_add_byte_array(bundle *b, const char *key, const unsigned int len * @see bundle_add_byte_array() * @see bundle_get_byte_array() */ -API int bundle_set_byte_array_element(bundle *b, const char *key, const unsigned int idx, const void *bytes, const size_t size); +int bundle_set_byte_array_element(bundle *b, const char *key, const unsigned int idx, const void *bytes, const size_t size); /** * @brief Gets the array of byte sequences with the given key. @@ -658,7 +654,7 @@ API int bundle_set_byte_array_element(bundle *b, const char *key, const unsigned * @see bundle_add_byte_array() * @see bundle_set_byte_array_element() */ -API int bundle_get_byte_array(bundle *b, const char *key, void ***byte_array, unsigned int *len, unsigned int **array_element_size); +int bundle_get_byte_array(bundle *b, const char *key, void ***byte_array, unsigned int *len, unsigned int **array_element_size); #ifdef __cplusplus } diff --git a/include/bundle_internal.h b/include/bundle_internal.h index 90e76b6..a1b8676 100644 --- a/include/bundle_internal.h +++ b/include/bundle_internal.h @@ -27,7 +27,7 @@ * @{ */ -#include "bundle.h" +#include #ifdef __cplusplus extern "C" { @@ -62,7 +62,7 @@ typedef void (*bundle_iterate_cb_t) (const char *key, const char *val, void *dat bundle_free(b); @endcode */ -API int bundle_add(bundle *b, const char *key, const char *val); +int bundle_add(bundle *b, const char *key, const char *val); /** * @brief Gets a value with a given key. @@ -88,7 +88,7 @@ API int bundle_add(bundle *b, const char *key, const char *val); val = NULL; @endcode */ -API const char *bundle_get_val(bundle *b, const char *key); +const char *bundle_get_val(bundle *b, const char *key); /** * @brief Iterates a callback function for each key-value pairs in a given bundle. @@ -119,7 +119,7 @@ API const char *bundle_get_val(bundle *b, const char *key); } @endcode */ -API void bundle_iterate(bundle *b, bundle_iterate_cb_t callback, void *cb_data); +void bundle_iterate(bundle *b, bundle_iterate_cb_t callback, void *cb_data); /** * @brief Determines whether the type of a key-value pair is measurable. @@ -134,7 +134,7 @@ API void bundle_iterate(bundle *b, bundle_iterate_cb_t callback, void *cb_data); * @pre @a kv must be a valid bundle_keyval_t object. * @see bundle_foreach() */ -API int bundle_keyval_type_is_measurable(bundle_keyval_t *kv); +int bundle_keyval_type_is_measurable(bundle_keyval_t *kv); /** * @brief Duplicates key-value pair. @@ -144,7 +144,7 @@ API int bundle_keyval_type_is_measurable(bundle_keyval_t *kv); * @retval @c NULL - Failure * @pre @a kv must be a valid bundle_keyval_t object. */ -API bundle_keyval_t *bundle_keyval_dup(const bundle_keyval_t *kv); +bundle_keyval_t *bundle_keyval_dup(const bundle_keyval_t *kv); /** * @brief Frees the encoded rawdata. @@ -156,7 +156,7 @@ API bundle_keyval_t *bundle_keyval_dup(const bundle_keyval_t *kv); * @pre @a r is a valid rawdata generated by bundle_encode(). * @see bundle_encode() */ -API int bundle_free_encoded_rawdata(bundle_raw **r); +int bundle_free_encoded_rawdata(bundle_raw **r); /** * @brief Encodes a bundle to the bundle_raw format. @@ -181,7 +181,7 @@ API int bundle_free_encoded_rawdata(bundle_raw **r); bundle_free(b); @endcode */ -API int bundle_encode_raw(bundle *b, bundle_raw **r, int *len); +int bundle_encode_raw(bundle *b, bundle_raw **r, int *len); /** * @brief Deserializes bundle_raw and gets a bundle object. @@ -211,7 +211,7 @@ API int bundle_encode_raw(bundle *b, bundle_raw **r, int *len); bundle_free(b_dup); @endcode */ -API bundle *bundle_decode_raw(const bundle_raw *r, const int len); +bundle *bundle_decode_raw(const bundle_raw *r, const int len); /** * @brief Exports bundle to @a argv. @@ -248,7 +248,7 @@ API bundle *bundle_decode_raw(const bundle_raw *r, const int len); bundle_free(b); @endcode */ -API int bundle_export_to_argv(bundle *b, char ***argv); +int bundle_export_to_argv(bundle *b, char ***argv); /** * @brief Frees the exported @a argv. @@ -278,7 +278,7 @@ API int bundle_export_to_argv(bundle *b, char ***argv); bundle_free(b); @endcode */ -API int bundle_free_exported_argv(int argc, char ***argv); +int bundle_free_exported_argv(int argc, char ***argv); /** * @brief Imports a bundle from @a argv. @@ -306,7 +306,7 @@ API int bundle_free_exported_argv(int argc, char ***argv); } @endcode */ -API bundle *bundle_import_from_argv(int argc, char **argv); +bundle *bundle_import_from_argv(int argc, char **argv); /** * @brief Sets a value of string array elements. @@ -338,7 +338,7 @@ API bundle *bundle_import_from_argv(int argc, char **argv); bundle_free(b); @endcode */ -API int bundle_set_str_array_element(bundle *b, const char *key, const unsigned int idx, const char *val); +int bundle_set_str_array_element(bundle *b, const char *key, const unsigned int idx, const char *val); /** * @brief Creates a JSON data from bundle. @@ -368,7 +368,7 @@ API int bundle_set_str_array_element(bundle *b, const char *key, const unsigned free(json); @endcode */ -API int bundle_to_json(bundle *b, char **json); +int bundle_to_json(bundle *b, char **json); /** * @breif Creates a bundle object from json. @@ -392,7 +392,7 @@ API int bundle_to_json(bundle *b, char **json); bundle_free(b); @endcode */ -API int bundle_from_json(const char *json, bundle **b); +int bundle_from_json(const char *json, bundle **b); /** * @breif Compares the bundle 1, 2. @@ -404,7 +404,7 @@ API int bundle_from_json(const char *json, bundle **b); * @retval @c -1 Invalid parameter * @retval @c 1 It is not identical */ -API int bundle_compare(bundle *b1, bundle *b2); +int bundle_compare(bundle *b1, bundle *b2); /** * @brief Initializes a byte array type key-value pair into a bundle. @@ -423,7 +423,7 @@ API int bundle_compare(bundle *b1, bundle *b2); * * @see bundle_set_byte_array_element() */ -API int bundle_init_byte_array(bundle *b, const char *key, const unsigned int len); +int bundle_init_byte_array(bundle *b, const char *key, const unsigned int len); #ifdef __cplusplus } diff --git a/src/bundle.c b/src/bundle.c index 333536a..0ffa3fb 100644 --- a/src/bundle.c +++ b/src/bundle.c @@ -24,10 +24,11 @@ #include "bundle.h" #include "bundle_internal.h" +#include "bundle_log.h" +#include "bundle_private.h" #include "keyval.h" #include "keyval_array.h" #include "keyval_type.h" -#include "bundle_log.h" #define CHECKSUM_LENGTH 32 #define TAG_IMPORT_EXPORT_CHECK "`zaybxcwdveuftgsh`" @@ -167,7 +168,7 @@ static void _bundle_global_init(void) } /* APIs */ -bundle *bundle_create(void) +API bundle *bundle_create(void) { bundle *b = NULL; @@ -188,7 +189,7 @@ exception: return NULL; } -int bundle_free(bundle *b) +API int bundle_free(bundle *b) { keyval_t *kv; keyval_t *tmp_kv; @@ -212,25 +213,25 @@ int bundle_free(bundle *b) return BUNDLE_ERROR_NONE; } -int bundle_add_str(bundle *b, const char *key, const char *str) +API int bundle_add_str(bundle *b, const char *key, const char *str) { if (!str) return BUNDLE_ERROR_INVALID_PARAMETER; return _bundle_add_kv(b, key, str, strlen(str) + 1, BUNDLE_TYPE_STR, 1); } -int bundle_get_str(bundle *b, const char *key, char **str) +API int bundle_get_str(bundle *b, const char *key, char **str) { return _bundle_get_val(b, key, BUNDLE_TYPE_STR, (void **)str, NULL, NULL, NULL); } -int bundle_add(bundle *b, const char *key, const char *val) +API int bundle_add(bundle *b, const char *key, const char *val) { return bundle_add_str(b, key, val); } -int bundle_del(bundle *b, const char *key) +API int bundle_del(bundle *b, const char *key) { keyval_t *kv; keyval_t *prev_kv = NULL; @@ -264,7 +265,7 @@ int bundle_del(bundle *b, const char *key) return BUNDLE_ERROR_NONE; } -const char *bundle_get_val(bundle *b, const char *key) +API const char *bundle_get_val(bundle *b, const char *key) { char *val = NULL; int ret = BUNDLE_ERROR_NONE; @@ -285,7 +286,7 @@ static void _bundle_get_count_iter(const char *k, const int type, *count += 1; } -int bundle_get_count(bundle *b) +API int bundle_get_count(bundle *b) { int count = 0; @@ -295,7 +296,7 @@ int bundle_get_count(bundle *b) return count; } -void bundle_iterate(bundle *b, bundle_iterate_cb_t callback, void *data) +API void bundle_iterate(bundle *b, bundle_iterate_cb_t callback, void *data) { keyval_t *kv; @@ -313,7 +314,7 @@ void bundle_iterate(bundle *b, bundle_iterate_cb_t callback, void *data) set_last_result(BUNDLE_ERROR_NONE); } -void bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data) +API void bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data) { keyval_t *kv; @@ -332,7 +333,7 @@ void bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data) } /* keyval functions */ -int bundle_keyval_get_type(bundle_keyval_t *kv) +API int bundle_keyval_get_type(bundle_keyval_t *kv) { if (kv == NULL) { set_last_result(BUNDLE_ERROR_INVALID_PARAMETER); @@ -342,7 +343,7 @@ int bundle_keyval_get_type(bundle_keyval_t *kv) return kv->type; } -int bundle_keyval_type_is_array(bundle_keyval_t *kv) +API int bundle_keyval_type_is_array(bundle_keyval_t *kv) { if (kv == NULL) { set_last_result(BUNDLE_ERROR_INVALID_PARAMETER); @@ -352,7 +353,7 @@ int bundle_keyval_type_is_array(bundle_keyval_t *kv) return keyval_type_is_array(kv->type); } -int bundle_keyval_type_is_measurable(bundle_keyval_t *kv) +API int bundle_keyval_type_is_measurable(bundle_keyval_t *kv) { if (kv == NULL) { set_last_result(BUNDLE_ERROR_INVALID_PARAMETER); @@ -362,19 +363,20 @@ int bundle_keyval_type_is_measurable(bundle_keyval_t *kv) return keyval_type_is_measurable(kv->type); } -int bundle_keyval_get_basic_val(bundle_keyval_t *kv, void **val, size_t *size) +API int bundle_keyval_get_basic_val(bundle_keyval_t *kv, void **val, + size_t *size) { return keyval_get_data(kv, NULL, val, size); } -int bundle_keyval_get_array_val(bundle_keyval_t *kv, void ***array_val, +API int bundle_keyval_get_array_val(bundle_keyval_t *kv, void ***array_val, unsigned int *array_len, size_t **array_item_size) { return keyval_array_get_data((keyval_array_t *)kv, NULL, array_val, array_len, array_item_size); } -bundle_keyval_t *bundle_keyval_dup(const bundle_keyval_t *kv) +API bundle_keyval_t *bundle_keyval_dup(const bundle_keyval_t *kv) { bundle_keyval_t *ret_kv = NULL; void *byte = NULL; @@ -408,7 +410,7 @@ bundle_keyval_t *bundle_keyval_dup(const bundle_keyval_t *kv) return ret_kv; } -bundle *bundle_dup(bundle *b_from) +API bundle *bundle_dup(bundle *b_from) { bundle *b_to; keyval_t *kv_from; @@ -460,7 +462,7 @@ err: return NULL; } -int bundle_encode(bundle *b, bundle_raw **r, int *len) +API int bundle_encode(bundle *b, bundle_raw **r, int *len) { keyval_t *kv; unsigned char *m; @@ -517,7 +519,7 @@ int bundle_encode(bundle *b, bundle_raw **r, int *len) return BUNDLE_ERROR_NONE; } -int bundle_free_encoded_rawdata(bundle_raw **r) +API int bundle_free_encoded_rawdata(bundle_raw **r) { if (!*r) return BUNDLE_ERROR_INVALID_PARAMETER; /* TC_FIX - double free sigabrt handling */ @@ -527,7 +529,7 @@ int bundle_free_encoded_rawdata(bundle_raw **r) return BUNDLE_ERROR_NONE; } -bundle *bundle_decode(const bundle_raw *r, const int data_size) +API bundle *bundle_decode(const bundle_raw *r, const int data_size) { bundle *b; bundle_raw *p_r; @@ -641,7 +643,7 @@ struct _argv_idx { int idx; }; -int bundle_encode_raw(bundle *b, bundle_raw **r, int *len) +API int bundle_encode_raw(bundle *b, bundle_raw **r, int *len) { keyval_t *kv = NULL; unsigned char *m = NULL; @@ -694,7 +696,7 @@ int bundle_encode_raw(bundle *b, bundle_raw **r, int *len) return BUNDLE_ERROR_NONE; } -bundle *bundle_decode_raw(const bundle_raw *r, const int data_size) +API bundle *bundle_decode_raw(const bundle_raw *r, const int data_size) { bundle *b = NULL; bundle_raw *p_r = NULL; @@ -810,7 +812,7 @@ void _iter_export_to_argv(const char *key, const int type, const keyval_t *kv, free(byte); } -int bundle_export_to_argv(bundle *b, char ***argv) +API int bundle_export_to_argv(bundle *b, char ***argv) { struct _argv_idx vi; int argc; @@ -842,7 +844,7 @@ int bundle_export_to_argv(bundle *b, char ***argv) return argc; } -int bundle_free_exported_argv(int argc, char ***argv) +API int bundle_free_exported_argv(int argc, char ***argv) { int i; @@ -860,7 +862,7 @@ int bundle_free_exported_argv(int argc, char ***argv) return BUNDLE_ERROR_NONE; } -bundle *bundle_import_from_argv(int argc, char **argv) +API bundle *bundle_import_from_argv(int argc, char **argv) { int idx; int type; @@ -937,7 +939,7 @@ bundle *bundle_import_from_argv(int argc, char **argv) return b; } -int bundle_get_type(bundle *b, const char *key) +API int bundle_get_type(bundle *b, const char *key) { keyval_t *kv = _bundle_find_kv(b, key); @@ -998,7 +1000,7 @@ static int bundle_set_array_val(bundle *b, const char *key, const int type, return keyval_array_set_element(kva, idx, (void *)val, size); } -int bundle_add_str_array(bundle *b, const char *key, const char **str_array, +API int bundle_add_str_array(bundle *b, const char *key, const char **str_array, const int len) { return _bundle_add_kv(b, key, str_array, 0, BUNDLE_TYPE_STR_ARRAY, len); @@ -1013,7 +1015,7 @@ int bundle_get_val_array(bundle *b, const char *key, char ***str_array, } /* LCOV_EXCL_STOP */ -const char **bundle_get_str_array(bundle *b, const char *key, int *len) +API const char **bundle_get_str_array(bundle *b, const char *key, int *len) { int ret = BUNDLE_ERROR_NONE; const char **arr_val = NULL; @@ -1025,7 +1027,7 @@ const char **bundle_get_str_array(bundle *b, const char *key, int *len) } /* LCOV_EXCL_START */ -int bundle_compare(bundle *b1, bundle *b2) +API int bundle_compare(bundle *b1, bundle *b2) { keyval_t *kv1; keyval_t *kv2; @@ -1048,7 +1050,7 @@ int bundle_compare(bundle *b1, bundle *b2) } /* LCOV_EXCL_STOP */ -int bundle_set_str_array_element(bundle *b, const char *key, +API int bundle_set_str_array_element(bundle *b, const char *key, const unsigned int idx, const char *val) { if (!val) @@ -1058,36 +1060,42 @@ int bundle_set_str_array_element(bundle *b, const char *key, idx, val, strlen(val) + 1); } -int bundle_add_byte(bundle *b, const char *key, const void *bytes, +API int bundle_add_byte(bundle *b, const char *key, const void *bytes, const size_t size) { return _bundle_add_kv(b, key, bytes, size, BUNDLE_TYPE_BYTE, 1); } -int bundle_get_byte(bundle *b, const char *key, void **bytes, size_t *size) +API int bundle_get_byte(bundle *b, const char *key, void **bytes, size_t *size) { return _bundle_get_val(b, key, BUNDLE_TYPE_BYTE, (void **)bytes, size, NULL, NULL); } -int bundle_add_byte_array(bundle *b, const char *key, const unsigned int len) +API int bundle_add_byte_array(bundle *b, const char *key, + const unsigned int len) { return bundle_init_byte_array(b, key, len); } -int bundle_init_byte_array(bundle *b, const char *key, const unsigned int len) +API int bundle_init_byte_array(bundle *b, const char *key, + const unsigned int len) { return _bundle_add_kv(b, key, NULL, 0, BUNDLE_TYPE_BYTE_ARRAY, len); } -int bundle_get_byte_array(bundle *b, const char *key, void ***byte_array, +API int bundle_get_byte_array(bundle *b, const char *key, void ***byte_array, unsigned int *len, unsigned int **array_element_size) { - return _bundle_get_val(b, key, BUNDLE_TYPE_BYTE_ARRAY, - (void **)byte_array, NULL, len, (size_t **)array_element_size); + int ret; + + ret = _bundle_get_val(b, key, BUNDLE_TYPE_BYTE_ARRAY, + (void **)byte_array, NULL, len, + (size_t **)array_element_size); + return ret; } -int bundle_set_byte_array_element(bundle *b, const char *key, +API int bundle_set_byte_array_element(bundle *b, const char *key, const unsigned int idx, const void *bytes, const size_t size) { return bundle_set_array_val(b, key, BUNDLE_TYPE_BYTE_ARRAY, diff --git a/src/bundle_json.c b/src/bundle_json.c index 8dad013..38be1a4 100644 --- a/src/bundle_json.c +++ b/src/bundle_json.c @@ -21,6 +21,7 @@ #include "bundle.h" #include "bundle_internal.h" +#include "bundle_private.h" static void __add_json_data_from_bundle(const char *key, const int type, @@ -64,7 +65,7 @@ static void __add_json_data_from_bundle(const char *key, } } -int bundle_to_json(bundle *b, char **json) +API int bundle_to_json(bundle *b, char **json) { JsonObject *object; JsonNode *node; @@ -161,7 +162,7 @@ static void __add_bundle_data_from_json(JsonObject *object, } } -int bundle_from_json(const char *json, bundle **b) +API int bundle_from_json(const char *json, bundle **b) { GError *error = NULL; JsonParser *parser; diff --git a/src/bundle_private.h b/src/bundle_private.h new file mode 100644 index 0000000..486d513 --- /dev/null +++ b/src/bundle_private.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __BUNDLE_PRIVATE_H__ +#define __BUNDLE_PRIVATE_H__ + +#ifdef API +#undef API +#endif +#define API __attribute__((visibility("default"))) + +#ifdef likely +#undef likely +#endif +#define likely(x) __builtin_expect(x, 1) + +#ifdef unlikely +#undef unlikely +#endif +#define unlikely(x) __builtin_expect(x, 0) + +#endif /* __BUNDLE_PRIVATE_H__ */ diff --git a/src/keyval_array.c b/src/keyval_array.c index 6dddc35..843cd7b 100644 --- a/src/keyval_array.c +++ b/src/keyval_array.c @@ -23,11 +23,12 @@ #include #include -#include "keyval_array.h" -#include "keyval.h" -#include "keyval_type.h" #include "bundle.h" #include "bundle_log.h" +#include "bundle_private.h" +#include "keyval.h" +#include "keyval_array.h" +#include "keyval_type.h" static keyval_method_collection_t method = { (keyval_method_free_t) keyval_array_free,