forked from enlightenment/efl
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.
This commit is contained in:
parent
7683780351
commit
9ac1cb4fad
|
@ -1413,6 +1413,19 @@ eina_value_struct_setup(Eina_Value *value, const Eina_Value_Struct_Desc *sdesc)
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline const Eina_Value_Struct_Desc *
|
||||||
|
eina_value_struct_desc_get(const Eina_Value *value)
|
||||||
|
{
|
||||||
|
const Eina_Value_Struct *st;
|
||||||
|
|
||||||
|
EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, NULL);
|
||||||
|
st = (const Eina_Value_Struct *)eina_value_memory_get(value);
|
||||||
|
if ((!st) || (!st->desc))
|
||||||
|
return NULL;
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(st->desc->version == EINA_VALUE_STRUCT_DESC_VERSION, NULL);
|
||||||
|
return st->desc;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void *
|
static inline void *
|
||||||
eina_value_struct_member_memory_get(const Eina_Value_Struct *st, const Eina_Value_Struct_Member *member)
|
eina_value_struct_member_memory_get(const Eina_Value_Struct *st, const Eina_Value_Struct_Member *member)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3046,6 +3046,16 @@ EAPI Eina_Value *eina_value_struct_new(const Eina_Value_Struct_Desc *desc) EINA_
|
||||||
static inline Eina_Bool eina_value_struct_setup(Eina_Value *value,
|
static inline Eina_Bool eina_value_struct_setup(Eina_Value *value,
|
||||||
const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1, 2);
|
const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1, 2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Checks for a struct and get its description.
|
||||||
|
* @param value Value object
|
||||||
|
* @return structure description, with all members and size.
|
||||||
|
* on failure, #NULL is returned.
|
||||||
|
*
|
||||||
|
* @since 1.21
|
||||||
|
*/
|
||||||
|
static inline const Eina_Value_Struct_Desc *eina_value_struct_desc_get(const Eina_Value *value) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the generic value in an struct member.
|
* @brief Sets the generic value in an struct member.
|
||||||
* @param value Source value object
|
* @param value Source value object
|
||||||
|
|
Loading…
Reference in New Issue