cedric pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=3a3ae49afde1712f4f972d8f3dc4b2feaa5579c7
commit 3a3ae49afde1712f4f972d8f3dc4b2feaa5579c7 Author: Cedric BAIL <ced...@osg.samsung.com> Date: Wed Sep 27 16:30:31 2017 -0700 eina: add an helper to setup Eina_Value structure description. This is particularly useful on system like Windows who doesn't allow setting pointer at compile time in static const structure. --- src/lib/eina/eina_value.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/lib/eina/eina_value.h b/src/lib/eina/eina_value.h index 7ee3249098..ee3f84e59f 100644 --- a/src/lib/eina/eina_value.h +++ b/src/lib/eina/eina_value.h @@ -3066,6 +3066,28 @@ struct _Eina_Value_Struct void *memory; /**< The managed structure memory */ }; +#define EINA_VALUE_STRUCT_DESC_DEFINE(Name, Ops, Size, ...) \ + static Eina_Value_Struct_Desc * \ + Name(void) \ + { \ + Eina_Value_Struct_Member tmp[] = { __VA_ARGS__ }; \ + static Eina_Value_Struct_Member members[EINA_C_ARRAY_LENGTH(tmp) + 1] = { { "", NULL, 0 } }; \ + static Eina_Value_Struct_Desc r = { \ + EINA_VALUE_STRUCT_DESC_VERSION, \ + NULL, \ + members, \ + EINA_C_ARRAY_LENGTH(tmp), \ + Size \ + }; \ + \ + if (members[0].name) \ + { \ + r.ops = Ops; \ + memcpy(members, tmp, sizeof(tmp)); \ + } \ + return &r; \ + } + /** * @brief Creates generic value storage of type struct. * @param desc How to manage this struct members. --