summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-08-24 11:13:56 -0300
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-08-24 11:13:56 -0300
commit9ac1cb4fadadb667483845a1471f091f6a60780c (patch)
treeb5f758ac9eaaf185578f3a7dcbb10e9e21ce9dd3
parent7683780351b91709469e3fb2b824f7c1bb8dade8 (diff)
eina_value: add helper: eina_value_struct_desc_get().
this helper will validate a struct and fetch its description, also checking if the user version matches.
-rw-r--r--src/lib/eina/eina_inline_value.x13
-rw-r--r--src/lib/eina/eina_value.h10
2 files changed, 23 insertions, 0 deletions
diff --git a/src/lib/eina/eina_inline_value.x b/src/lib/eina/eina_inline_value.x
index b8614c7ea9..17f9cc4b5b 100644
--- a/src/lib/eina/eina_inline_value.x
+++ b/src/lib/eina/eina_inline_value.x
@@ -1413,6 +1413,19 @@ eina_value_struct_setup(Eina_Value *value, const Eina_Value_Struct_Desc *sdesc)
1413 return EINA_TRUE; 1413 return EINA_TRUE;
1414} 1414}
1415 1415
1416static inline const Eina_Value_Struct_Desc *
1417eina_value_struct_desc_get(const Eina_Value *value)
1418{
1419 const Eina_Value_Struct *st;
1420
1421 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, NULL);
1422 st = (const Eina_Value_Struct *)eina_value_memory_get(value);
1423 if ((!st) || (!st->desc))
1424 return NULL;
1425 EINA_SAFETY_ON_FALSE_RETURN_VAL(st->desc->version == EINA_VALUE_STRUCT_DESC_VERSION, NULL);
1426 return st->desc;
1427}
1428
1416static inline void * 1429static inline void *
1417eina_value_struct_member_memory_get(const Eina_Value_Struct *st, const Eina_Value_Struct_Member *member) 1430eina_value_struct_member_memory_get(const Eina_Value_Struct *st, const Eina_Value_Struct_Member *member)
1418{ 1431{
diff --git a/src/lib/eina/eina_value.h b/src/lib/eina/eina_value.h
index a1ed51df5f..3617bfbea6 100644
--- a/src/lib/eina/eina_value.h
+++ b/src/lib/eina/eina_value.h
@@ -3047,6 +3047,16 @@ static inline Eina_Bool eina_value_struct_setup(Eina_Value *value,
3047 const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1, 2); 3047 const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1, 2);
3048 3048
3049/** 3049/**
3050 * @brief Checks for a struct and get its description.
3051 * @param value Value object
3052 * @return structure description, with all members and size.
3053 * on failure, #NULL is returned.
3054 *
3055 * @since 1.21
3056 */
3057static inline const Eina_Value_Struct_Desc *eina_value_struct_desc_get(const Eina_Value *value) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
3058
3059/**
3050 * @brief Sets the generic value in an struct member. 3060 * @brief Sets the generic value in an struct member.
3051 * @param value Source value object 3061 * @param value Source value object
3052 * @param name Name to find the member 3062 * @param name Name to find the member