summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2019-01-22 12:59:06 +0000
committerCedric BAIL <cedric.bail@free.fr>2019-01-23 10:54:13 -0800
commita50edaf17b9f2eda6b2e73339a069c1158c160e4 (patch)
treedec39947da1439eeafabc9e1028d8dfa33e76731 /src/lib/eina
parent06604d5d25b57a9b277f148267cb98b6ea00a295 (diff)
eina: refactor eina_value_*_new.
Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es> Differential Revision: https://phab.enlightenment.org/D7701
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_inline_value_util.x301
1 files changed, 33 insertions, 268 deletions
diff --git a/src/lib/eina/eina_inline_value_util.x b/src/lib/eina/eina_inline_value_util.x
index 6d8583da1c..09a7996087 100644
--- a/src/lib/eina/eina_inline_value_util.x
+++ b/src/lib/eina/eina_inline_value_util.x
@@ -131,277 +131,42 @@ eina_value_type_offset(const Eina_Value_Type *type, unsigned int base)
131 return base + padding; 131 return base + padding;
132} 132}
133 133
134/// @brief For internal use only.
135/// @hideinitializer
136#define EINA_VALUE_NEW(Compress_Type, Uppercase_Compress_Type, Type) \
134/** 137/**
135 * @brief Create a new #Eina_Value containing the passed parameter 138 @brief Create a new #Eina_Value containing the passed parameter
136 * @param c The value to use 139 @param c The value to use
137 * @return The #Eina_Value 140 @return The #Eina_Value
138 * @since 1.21 141 @since 1.21
139 */ 142 */ \
140static inline Eina_Value * 143static inline Eina_Value * \
141eina_value_uchar_new(unsigned char c) 144eina_value_##Compress_Type##_new(Type c) \
142{ 145{ \
143 Eina_Value *v; 146 Eina_Value *v; \
144 147 \
145 v = eina_value_new(EINA_VALUE_TYPE_UCHAR); 148 v = eina_value_new(EINA_VALUE_TYPE_##Uppercase_Compress_Type); \
146 if (v) eina_value_set(v, c); 149 if (v) eina_value_set(v, c); \
147 return v; 150 return v; \
148}
149
150/**
151 * @brief Create a new #Eina_Value containing the passed parameter
152 * @param s The value to use
153 * @return The #Eina_Value
154 * @since 1.21
155 */
156static inline Eina_Value *
157eina_value_ushort_new(unsigned short s)
158{
159 Eina_Value *v;
160
161 v = eina_value_new(EINA_VALUE_TYPE_USHORT);
162 if (v) eina_value_set(v, s);
163 return v;
164}
165
166/**
167 * @brief Create a new #Eina_Value containing the passed parameter
168 * @param i The value to use
169 * @return The #Eina_Value
170 * @since 1.21
171 */
172static inline Eina_Value *
173eina_value_uint_new(unsigned int i)
174{
175 Eina_Value *v;
176
177 v = eina_value_new(EINA_VALUE_TYPE_UINT);
178 if (v) eina_value_set(v, i);
179 return v;
180}
181
182/**
183 * @brief Create a new #Eina_Value containing the passed parameter
184 * @param l The value to use
185 * @return The #Eina_Value
186 * @since 1.21
187 */
188static inline Eina_Value *
189eina_value_ulong_new(unsigned long l)
190{
191 Eina_Value *v;
192
193 v = eina_value_new(EINA_VALUE_TYPE_ULONG);
194 if (v) eina_value_set(v, l);
195 return v;
196}
197
198/**
199 * @brief Create a new #Eina_Value containing the passed parameter
200 * @param i The value to use
201 * @return The #Eina_Value
202 * @since 1.21
203 */
204static inline Eina_Value *
205eina_value_uint64_new(uint64_t i)
206{
207 Eina_Value *v;
208
209 v = eina_value_new(EINA_VALUE_TYPE_UINT64);
210 if (v) eina_value_set(v, i);
211 return v;
212}
213
214/**
215 * @brief Create a new #Eina_Value containing the passed parameter
216 * @param c The value to use
217 * @return The #Eina_Value
218 * @since 1.21
219 */
220static inline Eina_Value *
221eina_value_char_new(char c)
222{
223 Eina_Value *v;
224
225 v = eina_value_new(EINA_VALUE_TYPE_CHAR);
226 if (v) eina_value_set(v, c);
227 return v;
228}
229
230/**
231 * @brief Create a new #Eina_Value containing the passed parameter
232 * @param s The value to use
233 * @return The #Eina_Value
234 * @since 1.21
235 */
236static inline Eina_Value *
237eina_value_short_new(short s)
238{
239 Eina_Value *v;
240
241 v = eina_value_new(EINA_VALUE_TYPE_SHORT);
242 if (v) eina_value_set(v, s);
243 return v;
244}
245
246/**
247 * @brief Create a new #Eina_Value containing the passed parameter
248 * @param i The value to use
249 * @return The #Eina_Value
250 * @since 1.21
251 */
252static inline Eina_Value *
253eina_value_int_new(int i)
254{
255 Eina_Value *v;
256
257 v = eina_value_new(EINA_VALUE_TYPE_INT);
258 if (v) eina_value_set(v, i);
259 return v;
260}
261
262/**
263 * @brief Create a new #Eina_Value containing the passed parameter
264 * @param l The value to use
265 * @return The #Eina_Value
266 * @since 1.21
267 */
268static inline Eina_Value *
269eina_value_long_new(long l)
270{
271 Eina_Value *v;
272
273 v = eina_value_new(EINA_VALUE_TYPE_LONG);
274 if (v) eina_value_set(v, l);
275 return v;
276}
277
278/**
279 * @brief Create a new #Eina_Value containing the passed parameter
280 * @param i The value to use
281 * @return The #Eina_Value
282 * @since 1.21
283 */
284static inline Eina_Value *
285eina_value_int64_new(int64_t i)
286{
287 Eina_Value *v;
288
289 v = eina_value_new(EINA_VALUE_TYPE_INT64);
290 if (v) eina_value_set(v, i);
291 return v;
292}
293
294/**
295 * @brief Create a new #Eina_Value containing the passed parameter
296 * @param f The value to use
297 * @return The #Eina_Value
298 * @since 1.21
299 */
300static inline Eina_Value *
301eina_value_float_new(float f)
302{
303 Eina_Value *v;
304
305 v = eina_value_new(EINA_VALUE_TYPE_FLOAT);
306 if (v) eina_value_set(v, f);
307 return v;
308}
309
310/**
311 * @brief Create a new #Eina_Value containing the passed parameter
312 * @param d The value to use
313 * @return The #Eina_Value
314 * @since 1.21
315 */
316static inline Eina_Value *
317eina_value_double_new(double d)
318{
319 Eina_Value *v;
320
321 v = eina_value_new(EINA_VALUE_TYPE_DOUBLE);
322 if (v) eina_value_set(v, d);
323 return v;
324}
325
326/**
327 * @brief Create a new #Eina_Value containing the passed parameter
328 * @param b The value to use
329 * @return The #Eina_Value
330 * @since 1.21
331 */
332static inline Eina_Value *
333eina_value_bool_new(Eina_Bool b)
334{
335 Eina_Value *v;
336
337 v = eina_value_new(EINA_VALUE_TYPE_BOOL);
338 if (v) eina_value_set(v, b);
339 return v;
340}
341
342/**
343 * @brief Create a new #Eina_Value containing the passed parameter
344 * @param str The value to use
345 * @return The #Eina_Value
346 * @since 1.21
347 */
348static inline Eina_Value *
349eina_value_string_new(const char *str)
350{
351 Eina_Value *v;
352
353 v = eina_value_new(EINA_VALUE_TYPE_STRING);
354 if (v) eina_value_set(v, str);
355 return v;
356}
357
358/**
359 * @brief Create a new #Eina_Value containing the passed parameter
360 * @param str The value to use
361 * @return The #Eina_Value
362 * @since 1.21
363 */
364static inline Eina_Value *
365eina_value_stringshare_new(const char *str)
366{
367 Eina_Value *v;
368
369 v = eina_value_new(EINA_VALUE_TYPE_STRINGSHARE);
370 if (v) eina_value_set(v, str);
371 return v;
372}
373
374/**
375 * @brief Create a new #Eina_Value containing the passed parameter
376 * @param t The value to use
377 * @return The #Eina_Value
378 * @since 1.21
379 */
380static inline Eina_Value *
381eina_value_time_new(time_t t)
382{
383 Eina_Value *v;
384
385 v = eina_value_new(EINA_VALUE_TYPE_TIMESTAMP);
386 if (v) eina_value_set(v, t);
387 return v;
388} 151}
389 152
390/** 153EINA_VALUE_NEW(uchar, UCHAR, unsigned char);
391 * @brief Create a new #Eina_Value containing the passed parameter 154EINA_VALUE_NEW(ushort, USHORT, unsigned short);
392 * @param err The error code 155EINA_VALUE_NEW(uint, UINT, unsigned int);
393 * @return The #Eina_Value 156EINA_VALUE_NEW(ulong, ULONG, unsigned long);
394 * @since 1.21 157EINA_VALUE_NEW(uint64, UINT64, uint64_t);
395 */ 158EINA_VALUE_NEW(char, CHAR, char);
396static inline Eina_Value * 159EINA_VALUE_NEW(short, SHORT, short);
397eina_value_error_new(Eina_Error err) 160EINA_VALUE_NEW(int, INT, int);
398{ 161EINA_VALUE_NEW(long, LONG, long);
399 Eina_Value *v; 162EINA_VALUE_NEW(int64, INT64, int64_t);
400 163EINA_VALUE_NEW(float, FLOAT, float);
401 v = eina_value_new(EINA_VALUE_TYPE_ERROR); 164EINA_VALUE_NEW(double, DOUBLE, double);
402 if (v) eina_value_set(v, err); 165EINA_VALUE_NEW(bool, BOOL, Eina_Bool);
403 return v; 166EINA_VALUE_NEW(string, STRING, const char *);
404} 167EINA_VALUE_NEW(stringshare, STRINGSHARE, const char *);
168EINA_VALUE_NEW(time, TIMESTAMP, time_t);
169EINA_VALUE_NEW(error, ERROR, Eina_Error);
405 170
406/// @brief For internal use only. 171/// @brief For internal use only.
407/// @hideinitializer 172/// @hideinitializer