Commit 86e42864 authored by Cedric BAIL's avatar Cedric BAIL

This patch is a starting point for cleaning up eet_data.c.

It also add EET_G_VAR_ARRAY and EET_G_ARRAY thanks to
turran's (jorgeluis.zapata@gmail.com) last year patch.
Of course we have test code for it and eet_data.c code
is covered around 90.1%. We need to test with garbage
data for increasing it more.

WARNING: API of eet_data_descriptor_element_add is not
clean and we will need to break it, if we want a clean
API. So this is the plan for version 2.0.0.


SVN revision: 34919
parent 2b1156ef
......@@ -58,4 +58,10 @@
* Introduce tile support and the possibility to decompress eet
image inside an existing surface.
2008-06-26 Cedric BAIL
* Massiv code cleanup.
* Add EET_G_ARRAY and EET_G_VAR_ARRAY support.
* Plan for version 2.0 API break of eet_data_descriptor_element_add.
......@@ -200,6 +200,20 @@ else
AC_DEFINE(EET_OLD_EET_FILE_FORMAT, 0, [support old eet file format])
fi
dnl Assert or fail.
prefer_assert="no"
AC_ARG_ENABLE(assert,
AC_HELP_STRING(
[--enable-assert],
[enable assert, [[default=disabled]]]
),
[ prefer_assert=$enableval ]
)
AM_CONDITIONAL(EET_ASSERT, test "x$prefer_assert" = "xyes")
if test "x$prefer_assert" = "xno"; then
cflags="$cflags -DNDEBUG"
fi
#AM_CHECK_DOXYGEN()
AC_OUTPUT([
......
......@@ -889,7 +889,7 @@ extern "C" {
*
* @since 1.0.0
*/
EAPI void eet_data_descriptor_element_add(Eet_Data_Descriptor *edd, const char *name, int type, int group_type, int offset, int count, const char *counter_name, Eet_Data_Descriptor *subtype);
EAPI void eet_data_descriptor_element_add(Eet_Data_Descriptor *edd, const char *name, int type, int group_type, int offset, /* int count_offset, */int count, const char *counter_name, Eet_Data_Descriptor *subtype);
/**
* Read a data structure from an eet file and decodes it.
......@@ -1114,7 +1114,7 @@ eet_dictionary_string_check * example: values), and @p type is the basic data
\
eet_data_descriptor_element_add(edd, name, type, EET_G_UNKNOWN, \
(char *)(&(___ett.member)) - (char *)(&(___ett)), \
0, NULL, NULL); \
0, /* 0, */NULL, NULL); \
}
/**
......@@ -1139,7 +1139,7 @@ eet_dictionary_string_check * example: values), and @p type is the basic data
\
eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNKNOWN, \
(char *)(&(___ett.member)) - (char *)(&(___ett)), \
0, NULL, subtype); \
0, /* 0, */NULL, subtype); \
}
/**
......@@ -1163,7 +1163,7 @@ eet_dictionary_string_check * example: values), and @p type is the basic data
\
eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_LIST, \
(char *)(&(___ett.member)) - (char *)(&(___ett)), \
0, NULL, subtype); \
0, /* 0, */NULL, subtype); \
}
/**
......@@ -1187,7 +1187,55 @@ eet_dictionary_string_check * example: values), and @p type is the basic data
\
eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_HASH, \
(char *)(&(___ett.member)) - (char *)(&(___ett)), \
0, NULL, subtype); \
0, /* 0, */NULL, subtype); \
}
/**
* Add a fixed size array type to a data descriptor
* @param edd The data descriptor to add the type to.
* @param struct_type The type of the struct.
* @param name The string name to use to encode/decode this member (must be a constant global and never change).
* @param member The struct member itself to be encoded.
* @param subtype The type of hash member to add.
*
* This macro lets you easily add a fixed size array of other data types. All the
* parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with the
* @p subtype being the exception. This must be the data descriptor of the
* element that is in each member of the hash to be stored.
*
* @since 1.0.2
*/
#define EET_DATA_DESCRIPTOR_ADD_ARRAY(edd, struct_type, name, member, subtype) \
{ \
struct_type ___ett; \
\
eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_ARRAY, \
(char *)(&(___ett.member)) - (char *)(&(___ett)), \
/* 0, */sizeof(___ett.member)/sizeof(___ett.member[0]), NULL, subtype); \
}
/**
* Add a variable size array type to a data descriptor
* @param edd The data descriptor to add the type to.
* @param struct_type The type of the struct.
* @param name The string name to use to encode/decode this member (must be a constant global and never change).
* @param member The struct member itself to be encoded.
* @param subtype The type of hash member to add.
*
* This macro lets you easily add a fixed size array of other data types. All the
* parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with the
* @p subtype being the exception. This must be the data descriptor of the
* element that is in each member of the hash to be stored.
*
* @since 1.0.2
*/
#define EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(edd, struct_type, name, member, subtype) \
{ \
struct_type ___ett; \
\
eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_VAR_ARRAY, \
(char *)(&(___ett.member)) - (char *)(&(___ett)), \
(char *)(&(___ett.member ## _count)) - (char *)(&(___ett)), /* 0, */NULL, subtype); \
}
/***************************************************************************/
......
......@@ -74,4 +74,10 @@ void _eet_double_to_string_convert(char des[128], double d);
#define PATH_MAX 4096
#endif
#ifdef DNDEBUG
#define EET_ASSERT(Test, Do) if (Test == 0) Do;
#else
#define EET_ASSERT(Test, Do) if (Test == 0) abort();
#endif
#endif
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment