_eina_value_type_blob_pget
};
+static Eina_Bool
+_eina_value_type_value_setup(const Eina_Value_Type *type EINA_UNUSED, void *mem)
+{
+ Eina_Value *v = mem;
+ memset(v, 0, sizeof(Eina_Value));
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+_eina_value_type_value_flush(const Eina_Value_Type *type EINA_UNUSED, void *mem)
+{
+ Eina_Value *v = mem;
+ eina_value_flush(v);
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+_eina_value_type_value_copy(const Eina_Value_Type *type EINA_UNUSED, const void *src, void *dst)
+{
+ const Eina_Value *v_src = src;
+ Eina_Value *v_dst = dst;
+ return eina_value_copy(v_src, v_dst);
+}
+
+static int
+_eina_value_type_value_compare(const Eina_Value_Type *type EINA_UNUSED, const void *a, const void *b)
+{
+ const Eina_Value *v1 = a;
+ const Eina_Value *v2 = b;
+ return eina_value_compare(v1, v2);
+}
+
+static Eina_Bool
+_eina_value_type_value_convert_to(const Eina_Value_Type *type EINA_UNUSED, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
+{
+ const Eina_Value *v = type_mem;
+ return eina_value_type_convert_to(v->type, convert, eina_value_memory_get(v), convert_mem);
+}
+
+static Eina_Bool
+_eina_value_type_value_convert_from(const Eina_Value_Type *type EINA_UNUSED, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem)
+{
+ Eina_Value *v = type_mem;
+ return eina_value_type_convert_from(v->type, convert, eina_value_memory_get(v), convert_mem);
+}
+
+static Eina_Bool
+_eina_value_type_value_vset(const Eina_Value_Type *type EINA_UNUSED, void *mem, va_list args)
+{
+ Eina_Value *dst = mem;
+ Eina_Value src = va_arg(args, Eina_Value);
+ return eina_value_copy(&src, dst);
+}
+
+static Eina_Bool
+_eina_value_type_value_pset(const Eina_Value_Type *type EINA_UNUSED, void *mem, const void *ptr)
+{
+ Eina_Value *dst = mem;
+ const Eina_Value *src = ptr;
+ return eina_value_copy(src, dst);
+}
+
+static Eina_Bool
+_eina_value_type_value_pget(const Eina_Value_Type *type EINA_UNUSED, const void *mem, void *ptr)
+{
+ const Eina_Value *src = mem;
+ Eina_Value *dst = ptr;
+ return eina_value_copy(src, dst);
+}
+
+static const Eina_Value_Type _EINA_VALUE_TYPE_VALUE = {
+ EINA_VALUE_TYPE_VERSION,
+ sizeof(Eina_Value),
+ "Eina_Value",
+ _eina_value_type_value_setup,
+ _eina_value_type_value_flush,
+ _eina_value_type_value_copy,
+ _eina_value_type_value_compare,
+ _eina_value_type_value_convert_to,
+ _eina_value_type_value_convert_from,
+ _eina_value_type_value_vset,
+ _eina_value_type_value_pset,
+ _eina_value_type_value_pget
+};
+
static int
_eina_value_struct_operations_binsearch_cmp(const void *pa, const void *pb)
{
EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH = &_EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH;
EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE = &_EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE;
+ EINA_VALUE_TYPE_VALUE = &_EINA_VALUE_TYPE_VALUE;
+
+
return EINA_TRUE;
on_init_fail_hash:
EAPI const Eina_Value_Type *_EINA_VALUE_TYPE_BASICS_START = NULL;
EAPI const Eina_Value_Type *_EINA_VALUE_TYPE_BASICS_END = NULL;
+EAPI const Eina_Value_Type *EINA_VALUE_TYPE_VALUE = NULL;
EAPI const Eina_Value_Type *EINA_VALUE_TYPE_ERROR = NULL;
EAPI const Eina_Value_Type *EINA_VALUE_TYPE_UCHAR = NULL;
EAPI const Eina_Value_Type *EINA_VALUE_TYPE_USHORT = NULL;
EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ERROR;
/**
+ * @var EINA_VALUE_TYPE_VALUE
+ * manages Eina_Value values.
+ * This value will hold an Eina_Value,
+ * which can be usefull for storing data
+ * inside an #Eina_Value_Array.
+ *
+ * @since 1.21
+ */
+EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_VALUE;
+
+/**
* @var EINA_VALUE_TYPE_UCHAR
* manages unsigned char type.
*
* The variable argument is dependent on chosen type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value
* @li EINA_VALUE_TYPE_ERROR: Eina_Error
* @li EINA_VALUE_TYPE_UCHAR: unsigned char
* @li EINA_VALUE_TYPE_USHORT: unsigned short
* The variable argument is dependent on chosen type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The pointer type is dependent on chosen value type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The pointer type is dependent on chosen value type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The variable argument is dependent on chosen subtype. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value
* @li EINA_VALUE_TYPE_ERROR: Eina_Error
* @li EINA_VALUE_TYPE_UCHAR: unsigned char
* @li EINA_VALUE_TYPE_USHORT: unsigned short
* The variable argument is dependent on chosen subtype. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The variable argument is dependent on chosen subtype. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value
* @li EINA_VALUE_TYPE_ERROR: Eina_Error
* @li EINA_VALUE_TYPE_UCHAR: unsigned char
* @li EINA_VALUE_TYPE_USHORT: unsigned short
* The variable argument is dependent on chosen subtype. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value
* @li EINA_VALUE_TYPE_ERROR: Eina_Error
* @li EINA_VALUE_TYPE_UCHAR: unsigned char
* @li EINA_VALUE_TYPE_USHORT: unsigned short
* The pointer type is dependent on chosen value type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The pointer type is dependent on chosen value type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The pointer type is dependent on chosen value type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The pointer type is dependent on chosen value type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The variable argument is dependent on chosen subtype. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value
* @li EINA_VALUE_TYPE_ERROR: Eina_Error
* @li EINA_VALUE_TYPE_UCHAR: unsigned char
* @li EINA_VALUE_TYPE_USHORT: unsigned short
* The variable argument is dependent on chosen subtype. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The variable argument is dependent on chosen subtype. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value
* @li EINA_VALUE_TYPE_ERROR: Eina_Error
* @li EINA_VALUE_TYPE_UCHAR: unsigned char
* @li EINA_VALUE_TYPE_USHORT: unsigned short
* The variable argument is dependent on chosen subtype. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value
* @li EINA_VALUE_TYPE_ERROR: Eina_Error
* @li EINA_VALUE_TYPE_UCHAR: unsigned char
* @li EINA_VALUE_TYPE_USHORT: unsigned short
* The pointer type is dependent on chosen value type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The pointer type is dependent on chosen value type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The pointer type is dependent on chosen value type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The pointer type is dependent on chosen value type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The variable argument is dependent on chosen subtype. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value
* @li EINA_VALUE_TYPE_ERROR: Eina_Error
* @li EINA_VALUE_TYPE_UCHAR: unsigned char
* @li EINA_VALUE_TYPE_USHORT: unsigned short
* The variable argument is dependent on chosen subtype. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The pointer type is dependent on chosen value type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The pointer type is dependent on chosen value type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The variable argument is dependent on chosen member type. The list
* for basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value
* @li EINA_VALUE_TYPE_ERROR: Eina_Error
* @li EINA_VALUE_TYPE_UCHAR: unsigned char
* @li EINA_VALUE_TYPE_USHORT: unsigned short
* The variable argument is dependent on chosen member type. The list
* for basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The pointer type is dependent on chosen value type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
* The pointer type is dependent on chosen value type. The list for
* basic types:
*
+ * @li EINA_VALUE_TYPE_VALUE: Eina_Value*
* @li EINA_VALUE_TYPE_ERROR: Eina_Error*
* @li EINA_VALUE_TYPE_UCHAR: unsigned char*
* @li EINA_VALUE_TYPE_USHORT: unsigned short*
}
END_TEST
+START_TEST(eina_value_test_value)
+{
+ Eina_Value composed, v;
+ const int ivalue = 3500;
+ int i;
+ const char *str;
+
+ eina_init();
+
+ fail_if(!eina_value_setup(&composed, EINA_VALUE_TYPE_VALUE));
+ fail_if(!eina_value_setup(&v, EINA_VALUE_TYPE_INT));
+ fail_if(!eina_value_set(&v, ivalue));
+ fail_if(!eina_value_set(&composed, v));
+
+ fail_if(!eina_value_get(&composed, &v));
+ fail_if(!eina_value_get(&v, &i));
+ fail_if(i != ivalue);
+
+ eina_value_flush(&v);
+ fail_if(!eina_value_setup(&v, EINA_VALUE_TYPE_STRING));
+ fail_if(!eina_value_convert(&composed, &v));
+ fail_if(!eina_value_get(&v, &str));
+ ck_assert_str_eq(str, "3500");
+
+ eina_value_flush(&v);
+ fail_if(!eina_value_copy(&composed, &v));
+ fail_if(eina_value_compare(&composed, &v));
+
+ eina_value_flush(&v);
+ eina_value_flush(&composed);
+ eina_shutdown();
+}
+END_TEST
+
+START_TEST(eina_value_test_value_string)
+{
+ Eina_Value composed, v, str_v;
+ const char *msg = "A string", *str;
+
+ eina_init();
+
+ fail_if(!eina_value_setup(&composed, EINA_VALUE_TYPE_VALUE));
+ fail_if(!eina_value_setup(&v, EINA_VALUE_TYPE_STRING));
+ fail_if(!eina_value_set(&v, msg));
+ fail_if(!eina_value_set(&composed, v));
+
+ eina_value_flush(&v);
+ fail_if(!eina_value_copy(&composed, &v));
+ fail_if(eina_value_compare(&composed, &v));
+
+ fail_if(!eina_value_get(&composed, &str_v));
+ fail_if(!eina_value_get(&str_v, &str));
+ ck_assert_str_eq(str, msg);
+ eina_value_flush(&str_v);
+
+ str = NULL;
+ fail_if(!eina_value_get(&v, &str_v));
+ fail_if(!eina_value_get(&str_v, &str));
+ ck_assert_str_eq(str, msg);
+
+ eina_value_flush(&str_v);
+ eina_value_flush(&composed);
+ eina_value_flush(&v);
+ eina_shutdown();
+}
+END_TEST
+
void
eina_test_value(TCase *tc)
{
tcase_add_test(tc, eina_value_test_optional_int);
tcase_add_test(tc, eina_value_test_optional_string);
tcase_add_test(tc, eina_value_test_optional_struct_members);
+ tcase_add_test(tc, eina_value_test_value);
+ tcase_add_test(tc, eina_value_test_value_string);
}