summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2019-01-22 12:52:41 +0000
committerCedric BAIL <cedric.bail@free.fr>2019-01-23 10:54:11 -0800
commit06604d5d25b57a9b277f148267cb98b6ea00a295 (patch)
tree7f25a6ea99cd15d66510509d8271e73deb04854b /src/lib/eina
parentde608bb2031419c417581c7abf59aa2e2dec7164 (diff)
eina: refactor eina_value_*_init.
Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es> Differential Revision: https://phab.enlightenment.org/D7700
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_inline_value_util.x305
1 files changed, 35 insertions, 270 deletions
diff --git a/src/lib/eina/eina_inline_value_util.x b/src/lib/eina/eina_inline_value_util.x
index a523a661b6..6d8583da1c 100644
--- a/src/lib/eina/eina_inline_value_util.x
+++ b/src/lib/eina/eina_inline_value_util.x
@@ -403,277 +403,42 @@ eina_value_error_new(Eina_Error err)
403 return v; 403 return v;
404} 404}
405 405
406/// @brief For internal use only.
407/// @hideinitializer
408#define EINA_VALUE_INIT(Compress_Type, Uppercase_Compress_Type, Type) \
406/** 409/**
407 * @brief Initialize #Eina_Value containing the passed parameter 410 @brief Initialize #Eina_Value containing the passed parameter
408 * @param c The value to use 411 @param c The value to use
409 * @return The #Eina_Value 412 @return The #Eina_Value
410 * @since 1.21 413 @since 1.21
411 */ 414 */ \
412static inline Eina_Value 415static inline Eina_Value \
413eina_value_uchar_init(unsigned char c) 416eina_value_##Compress_Type##_init(Type c) \
414{ 417{ \
415 Eina_Value v = EINA_VALUE_EMPTY; 418 Eina_Value v = EINA_VALUE_EMPTY; \
416 419 \
417 if (eina_value_setup(&v, EINA_VALUE_TYPE_UCHAR)) 420 if (eina_value_setup(&v, EINA_VALUE_TYPE_##Uppercase_Compress_Type)) \
418 eina_value_set(&v, c); 421 eina_value_set(&v, c); \
419 return v; 422 return v; \
420} 423}
421 424
422/** 425EINA_VALUE_INIT(uchar, UCHAR, unsigned char);
423 * @brief Initialize #Eina_Value containing the passed parameter 426EINA_VALUE_INIT(ushort, USHORT, unsigned short);
424 * @param s The value to use 427EINA_VALUE_INIT(uint, UINT, unsigned int);
425 * @return The #Eina_Value 428EINA_VALUE_INIT(ulong, ULONG, unsigned long);
426 * @since 1.21 429EINA_VALUE_INIT(uint64, UINT64, uint64_t);
427 */ 430EINA_VALUE_INIT(char, CHAR, char);
428static inline Eina_Value 431EINA_VALUE_INIT(short, SHORT, short);
429eina_value_ushort_init(unsigned short s) 432EINA_VALUE_INIT(int, INT, int);
430{ 433EINA_VALUE_INIT(long, LONG, long);
431 Eina_Value v = EINA_VALUE_EMPTY; 434EINA_VALUE_INIT(int64, INT64, int64_t);
432 435EINA_VALUE_INIT(float, FLOAT, float);
433 if (eina_value_setup(&v, EINA_VALUE_TYPE_USHORT)) 436EINA_VALUE_INIT(double, DOUBLE, double);
434 eina_value_set(&v, s); 437EINA_VALUE_INIT(bool, BOOL, Eina_Bool);
435 return v; 438EINA_VALUE_INIT(string, STRING, const char *);
436} 439EINA_VALUE_INIT(stringshare, STRINGSHARE, const char *);
437 440EINA_VALUE_INIT(time, TIMESTAMP, time_t);
438/** 441EINA_VALUE_INIT(error, ERROR, Eina_Error);
439 * @brief Initialize #Eina_Value containing the passed parameter
440 * @param i The value to use
441 * @return The #Eina_Value
442 * @since 1.21
443 */
444static inline Eina_Value
445eina_value_uint_init(unsigned int i)
446{
447 Eina_Value v = EINA_VALUE_EMPTY;
448
449 if (eina_value_setup(&v, EINA_VALUE_TYPE_UINT))
450 eina_value_set(&v, i);
451 return v;
452}
453
454/**
455 * @brief Create a new #EinaInitializeining the passed parameter
456 * @param l The value to use
457 * @return The #Eina_Value
458 * @since 1.21
459 */
460static inline Eina_Value
461eina_value_ulong_init(unsigned long l)
462{
463 Eina_Value v = EINA_VALUE_EMPTY;
464
465 if (eina_value_setup(&v, EINA_VALUE_TYPE_ULONG))
466 eina_value_set(&v, l);
467 return v;
468}
469
470/**
471 * @brief Initialize #Eina_Value containing the passed parameter
472 * @param i The value to use
473 * @return The #Eina_Value
474 * @since 1.21
475 */
476static inline Eina_Value
477eina_value_uint64_init(uint64_t i)
478{
479 Eina_Value v = EINA_VALUE_EMPTY;
480
481 if (eina_value_setup(&v, EINA_VALUE_TYPE_UINT64))
482 eina_value_set(&v, i);
483 return v;
484}
485
486/**
487 * @brief Create a new #EinaInitializeining the passed parameter
488 * @param c The value to use
489 * @return The #Eina_Value
490 * @since 1.21
491 */
492static inline Eina_Value
493eina_value_char_init(char c)
494{
495 Eina_Value v = EINA_VALUE_EMPTY;
496
497 if (eina_value_setup(&v, EINA_VALUE_TYPE_CHAR))
498 eina_value_set(&v, c);
499 return v;
500}
501
502/**
503 * @brief Initialize #Eina_Value containing the passed parameter
504 * @param s The value to use
505 * @return The #Eina_Value
506 * @since 1.21
507 */
508static inline Eina_Value
509eina_value_short_init(short s)
510{
511 Eina_Value v = EINA_VALUE_EMPTY;
512
513 if (eina_value_setup(&v, EINA_VALUE_TYPE_SHORT))
514 eina_value_set(&v, s);
515 return v;
516}
517
518/**
519 * @brief Create a new #EinaInitializeining the passed parameter
520 * @param i The value to use
521 * @return The #Eina_Value
522 * @since 1.21
523 */
524static inline Eina_Value
525eina_value_int_init(int i)
526{
527 Eina_Value v = EINA_VALUE_EMPTY;
528
529 if (eina_value_setup(&v, EINA_VALUE_TYPE_INT))
530 eina_value_set(&v, i);
531 return v;
532}
533
534/**
535 * @brief Initialize #Eina_Value containing the passed parameter
536 * @param l The value to use
537 * @return The #Eina_Value
538 * @since 1.21
539 */
540static inline Eina_Value
541eina_value_long_init(long l)
542{
543 Eina_Value v = EINA_VALUE_EMPTY;
544
545 if (eina_value_setup(&v, EINA_VALUE_TYPE_LONG))
546 eina_value_set(&v, l);
547 return v;
548}
549
550/**
551 * @brief Create a new #EinaInitializeining the passed parameter
552 * @param i The value to use
553 * @return The #Eina_Value
554 * @since 1.21
555 */
556static inline Eina_Value
557eina_value_int64_init(int64_t i)
558{
559 Eina_Value v = EINA_VALUE_EMPTY;
560
561 if (eina_value_setup(&v, EINA_VALUE_TYPE_INT64))
562 eina_value_set(&v, i);
563 return v;
564}
565
566/**
567 * @brief Initialize #Eina_Value containing the passed parameter
568 * @param f The value to use
569 * @return The #Eina_Value
570 * @since 1.21
571 */
572static inline Eina_Value
573eina_value_float_init(float f)
574{
575 Eina_Value v = EINA_VALUE_EMPTY;
576
577 if (eina_value_setup(&v, EINA_VALUE_TYPE_FLOAT))
578 eina_value_set(&v, f);
579 return v;
580}
581
582/**
583 * @brief Create a new #EinaInitializeining the passed parameter
584 * @param d The value to use
585 * @return The #Eina_Value
586 * @since 1.21
587 */
588static inline Eina_Value
589eina_value_double_init(double d)
590{
591 Eina_Value v = EINA_VALUE_EMPTY;
592
593 if (eina_value_setup(&v, EINA_VALUE_TYPE_DOUBLE))
594 eina_value_set(&v, d);
595 return v;
596}
597
598/**
599 * @brief Initialize #Eina_Value containing the passed parameter
600 * @param b The value to use
601 * @return The #Eina_Value
602 * @since 1.21
603 */
604static inline Eina_Value
605eina_value_bool_init(Eina_Bool b)
606{
607 Eina_Value v = EINA_VALUE_EMPTY;
608
609 if (eina_value_setup(&v, EINA_VALUE_TYPE_BOOL))
610 eina_value_set(&v, b);
611 return v;
612}
613
614/**
615 * @brief Create a new #EinaInitializeining the passed parameter
616 * @param str The value to use
617 * @return The #Eina_Value
618 * @since 1.21
619 */
620static inline Eina_Value
621eina_value_string_init(const char *str)
622{
623 Eina_Value v = EINA_VALUE_EMPTY;
624
625 if (eina_value_setup(&v, EINA_VALUE_TYPE_STRING))
626 eina_value_set(&v, str);
627 return v;
628}
629
630/**
631 * @brief Initialize #Eina_Value containing the passed parameter
632 * @param str The value to use
633 * @return The #Eina_Value
634 * @since 1.21
635 */
636static inline Eina_Value
637eina_value_stringshare_init(const char *str)
638{
639 Eina_Value v = EINA_VALUE_EMPTY;
640
641 if (eina_value_setup(&v, EINA_VALUE_TYPE_STRINGSHARE))
642 eina_value_set(&v, str);
643 return v;
644}
645
646/**
647 * @brief Create a new #EinaInitializeining the passed parameter
648 * @param t The value to use
649 * @return The #Eina_Value
650 * @since 1.21
651 */
652static inline Eina_Value
653eina_value_time_init(time_t t)
654{
655 Eina_Value v = EINA_VALUE_EMPTY;
656
657 if (eina_value_setup(&v, EINA_VALUE_TYPE_TIMESTAMP))
658 eina_value_set(&v, t);
659 return v;
660}
661
662/**
663 * @brief Initialize #Eina_Value containing the passed parameter
664 * @param err The error code
665 * @return The #Eina_Value
666 * @since 1.21
667 */
668static inline Eina_Value
669eina_value_error_init(Eina_Error err)
670{
671 Eina_Value v = EINA_VALUE_EMPTY;
672
673 if (eina_value_setup(&v, EINA_VALUE_TYPE_ERROR))
674 eina_value_set(&v, err);
675 return v;
676}
677 442
678/// @brief For internal use only. 443/// @brief For internal use only.
679/// @hideinitializer 444/// @hideinitializer