summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-08-23 17:18:03 -0300
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-08-23 18:32:13 -0300
commit39acaab5e9d5b49c7f87c529bab0eae5e1d5a3a7 (patch)
treead7d3b383cf2c7dd1d213c8d283fda1d0977c77d
parent6cbfe100d5f2d6771e9f68883a5c81ee8735e710 (diff)
eina_value_util: remove "_util" from names.
these utilities are very useful, but names became too long. Since they do not conflict with anything else, shorten them. Since they were available before as inline function, provide a macro to rename them for old source that's compiled against newer library.
-rw-r--r--src/lib/eina/eina_inline_value_util.x120
1 files changed, 97 insertions, 23 deletions
diff --git a/src/lib/eina/eina_inline_value_util.x b/src/lib/eina/eina_inline_value_util.x
index 3b0a3563d8..2d5c264442 100644
--- a/src/lib/eina/eina_inline_value_util.x
+++ b/src/lib/eina/eina_inline_value_util.x
@@ -25,15 +25,85 @@
25#include <time.h> 25#include <time.h>
26#include <string.h> 26#include <string.h>
27 27
28/* original names were too long, _util was removed.
29 * since they were static inline, a macro is enough
30 */
31
32/**
33 * Legacy compat: calls eina_value_type_size()
34 * @deprecated
35 * @since 1.12
36 */
37#define eina_value_util_type_size eina_value_type_size
38/**
39 * Legacy compat: calls eina_value_type_offset()
40 * @deprecated
41 * @since 1.12
42 */
43#define eina_value_util_type_offset eina_value_type_offset
44/**
45 * Legacy compat: calls eina_value_int_new()
46 * @deprecated
47 * @since 1.12
48 */
49#define eina_value_util_int_new eina_value_int_new
50/**
51 * Legacy compat: calls eina_value_double_new()
52 * @deprecated
53 * @since 1.12
54 */
55#define eina_value_util_double_new eina_value_double_new
56/**
57 * Legacy compat: calls eina_value_bool_new()
58 * @deprecated
59 * @since 1.12
60 */
61#define eina_value_util_bool_new eina_value_bool_new
62/**
63 * Legacy compat: calls eina_value_string_new()
64 * @deprecated
65 * @since 1.12
66 */
67#define eina_value_util_string_new eina_value_string_new
68/**
69 * Legacy compat: calls eina_value_stringshare_new()
70 * @deprecated
71 * @since 1.12
72 */
73#define eina_value_util_stringshare_new eina_value_stringshare_new
74/**
75 * Legacy compat: calls eina_value_time_new()
76 * @deprecated
77 * @since 1.12
78 */
79#define eina_value_util_time_new eina_value_time_new
80/**
81 * Legacy compat: calls eina_value_dup()
82 * @deprecated
83 * @since 1.12
84 */
85#define eina_value_util_dup eina_value_dup
86/**
87 * Legacy compat: calls eina_value_stringshare_copy()
88 * @deprecated
89 * @since 1.12
90 */
91#define eina_value_util_stringshare_copy eina_value_stringshare_copy
92/**
93 * Legacy compat: calls eina_value_string_copy()
94 * @deprecated
95 * @since 1.12
96 */
97#define eina_value_util_string_copy eina_value_string_copy
28 98
29/** 99/**
30 * @brief Get size of #Eina_Value_Type based on C type 100 * @brief Get size of #Eina_Value_Type based on C type
31 * @param type The type to get the size of 101 * @param type The type to get the size of
32 * @return The size of the type 102 * @return The size of the type
33 * @since 1.12 103 * @since 1.21
34 */ 104 */
35static inline size_t 105static inline size_t
36eina_value_util_type_size(const Eina_Value_Type *type) 106eina_value_type_size(const Eina_Value_Type *type)
37{ 107{
38 if (type) return type->value_size; 108 if (type) return type->value_size;
39 return 0; 109 return 0;
@@ -44,13 +114,13 @@ eina_value_util_type_size(const Eina_Value_Type *type)
44 * @param type The type to get the offset of 114 * @param type The type to get the offset of
45 * @param base The existing base size 115 * @param base The existing base size
46 * @return The offset of the type 116 * @return The offset of the type
47 * @since 1.12 117 * @since 1.21
48 */ 118 */
49static inline unsigned int 119static inline unsigned int
50eina_value_util_type_offset(const Eina_Value_Type *type, unsigned int base) 120eina_value_type_offset(const Eina_Value_Type *type, unsigned int base)
51{ 121{
52 unsigned size, padding; 122 unsigned size, padding;
53 size = eina_value_util_type_size(type); 123 size = eina_value_type_size(type);
54 if (!(base % size)) 124 if (!(base % size))
55 return base; 125 return base;
56 padding = ( (base > size) ? (base - size) : (size - base)); 126 padding = ( (base > size) ? (base - size) : (size - base));
@@ -61,10 +131,10 @@ eina_value_util_type_offset(const Eina_Value_Type *type, unsigned int base)
61 * @brief Create a new #Eina_Value containing the passed parameter 131 * @brief Create a new #Eina_Value containing the passed parameter
62 * @param i The value to use 132 * @param i The value to use
63 * @return The #Eina_Value 133 * @return The #Eina_Value
64 * @since 1.12 134 * @since 1.21
65 */ 135 */
66static inline Eina_Value * 136static inline Eina_Value *
67eina_value_util_int_new(int i) 137eina_value_int_new(int i)
68{ 138{
69 Eina_Value *v; 139 Eina_Value *v;
70 140
@@ -77,10 +147,10 @@ eina_value_util_int_new(int i)
77 * @brief Create a new #Eina_Value containing the passed parameter 147 * @brief Create a new #Eina_Value containing the passed parameter
78 * @param d The value to use 148 * @param d The value to use
79 * @return The #Eina_Value 149 * @return The #Eina_Value
80 * @since 1.12 150 * @since 1.21
81 */ 151 */
82static inline Eina_Value * 152static inline Eina_Value *
83eina_value_util_double_new(double d) 153eina_value_double_new(double d)
84{ 154{
85 Eina_Value *v; 155 Eina_Value *v;
86 156
@@ -93,10 +163,10 @@ eina_value_util_double_new(double d)
93 * @brief Create a new #Eina_Value containing the passed parameter 163 * @brief Create a new #Eina_Value containing the passed parameter
94 * @param b The value to use 164 * @param b The value to use
95 * @return The #Eina_Value 165 * @return The #Eina_Value
96 * @since 1.12 166 * @since 1.21
97 */ 167 */
98static inline Eina_Value * 168static inline Eina_Value *
99eina_value_util_bool_new(Eina_Bool b) 169eina_value_bool_new(Eina_Bool b)
100{ 170{
101 Eina_Value *v; 171 Eina_Value *v;
102 172
@@ -109,10 +179,10 @@ eina_value_util_bool_new(Eina_Bool b)
109 * @brief Create a new #Eina_Value containing the passed parameter 179 * @brief Create a new #Eina_Value containing the passed parameter
110 * @param str The value to use 180 * @param str The value to use
111 * @return The #Eina_Value 181 * @return The #Eina_Value
112 * @since 1.12 182 * @since 1.21
113 */ 183 */
114static inline Eina_Value * 184static inline Eina_Value *
115eina_value_util_string_new(const char *str) 185eina_value_string_new(const char *str)
116{ 186{
117 Eina_Value *v; 187 Eina_Value *v;
118 188
@@ -125,10 +195,10 @@ eina_value_util_string_new(const char *str)
125 * @brief Create a new #Eina_Value containing the passed parameter 195 * @brief Create a new #Eina_Value containing the passed parameter
126 * @param str The value to use 196 * @param str The value to use
127 * @return The #Eina_Value 197 * @return The #Eina_Value
128 * @since 1.12 198 * @since 1.21
129 */ 199 */
130static inline Eina_Value * 200static inline Eina_Value *
131eina_value_util_stringshare_new(const char *str) 201eina_value_stringshare_new(const char *str)
132{ 202{
133 Eina_Value *v; 203 Eina_Value *v;
134 204
@@ -141,10 +211,10 @@ eina_value_util_stringshare_new(const char *str)
141 * @brief Create a new #Eina_Value containing the passed parameter 211 * @brief Create a new #Eina_Value containing the passed parameter
142 * @param t The value to use 212 * @param t The value to use
143 * @return The #Eina_Value 213 * @return The #Eina_Value
144 * @since 1.12 214 * @since 1.21
145 */ 215 */
146static inline Eina_Value * 216static inline Eina_Value *
147eina_value_util_time_new(time_t t) 217eina_value_time_new(time_t t)
148{ 218{
149 Eina_Value *v; 219 Eina_Value *v;
150 220
@@ -157,10 +227,10 @@ eina_value_util_time_new(time_t t)
157 * @brief Create a new #Eina_Value containing the passed parameter 227 * @brief Create a new #Eina_Value containing the passed parameter
158 * @param val The value to use 228 * @param val The value to use
159 * @return The #Eina_Value 229 * @return The #Eina_Value
160 * @since 1.12 230 * @since 1.21
161 */ 231 */
162static inline Eina_Value * 232static inline Eina_Value *
163eina_value_util_dup(const Eina_Value *val) 233eina_value_dup(const Eina_Value *val)
164{ 234{
165 Eina_Value *v; 235 Eina_Value *v;
166 236
@@ -175,13 +245,15 @@ eina_value_util_dup(const Eina_Value *val)
175 * @param val The value to copy 245 * @param val The value to copy
176 * @param str The pointer to copy the stringshare to 246 * @param str The pointer to copy the stringshare to
177 * @return @c EINA_TRUE on success 247 * @return @c EINA_TRUE on success
178 * @since 1.12 248 * @since 1.21
179 */ 249 */
180static inline Eina_Bool 250static inline Eina_Bool
181eina_value_util_stringshare_copy(const Eina_Value *val, Eina_Stringshare **str) 251eina_value_stringshare_copy(const Eina_Value *val, Eina_Stringshare **str)
182{ 252{
183 EINA_SAFETY_ON_NULL_RETURN_VAL(val, EINA_FALSE); 253 EINA_SAFETY_ON_NULL_RETURN_VAL(val, EINA_FALSE);
184 EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE); 254 EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
255 *str = NULL;
256 EINA_SAFETY_ON_FALSE_RETURN_VAL(val->type == EINA_VALUE_TYPE_STRINGSHARE, EINA_FALSE);
185 if (!eina_value_get(val, str)) return EINA_FALSE; 257 if (!eina_value_get(val, str)) return EINA_FALSE;
186 eina_stringshare_ref(*str); 258 eina_stringshare_ref(*str);
187 return EINA_TRUE; 259 return EINA_TRUE;
@@ -192,14 +264,16 @@ eina_value_util_stringshare_copy(const Eina_Value *val, Eina_Stringshare **str)
192 * @param val The value to copy 264 * @param val The value to copy
193 * @param str The pointer to copy the string to 265 * @param str The pointer to copy the string to
194 * @return @c EINA_TRUE on success 266 * @return @c EINA_TRUE on success
195 * @since 1.12 267 * @since 1.21
196 */ 268 */
197static inline Eina_Bool 269static inline Eina_Bool
198eina_value_util_string_copy(const Eina_Value *val, char **str) 270eina_value_string_copy(const Eina_Value *val, char **str)
199{ 271{
200 char *s; 272 char *s;
201 EINA_SAFETY_ON_NULL_RETURN_VAL(val, EINA_FALSE); 273 EINA_SAFETY_ON_NULL_RETURN_VAL(val, EINA_FALSE);
202 EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE); 274 EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
275 *str = NULL;
276 EINA_SAFETY_ON_FALSE_RETURN_VAL((val->type == EINA_VALUE_TYPE_STRINGSHARE || val->type == EINA_VALUE_TYPE_STRING), EINA_FALSE);
203 if (!eina_value_get(val, &s)) return EINA_FALSE; 277 if (!eina_value_get(val, &s)) return EINA_FALSE;
204 *str = s ? strdup(s) : NULL; 278 *str = s ? strdup(s) : NULL;
205 return EINA_TRUE; 279 return EINA_TRUE;