summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-08-23 18:08:14 -0300
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-08-23 18:32:13 -0300
commitf4b02d87d6601eaa524dd23f84313bc3069fc594 (patch)
tree66786141db54fef0ecb7537275033f5e03a6422c
parentc158d5c17a93ba75013b340dd092441631c785e6 (diff)
eina_value_util: init helpers (stack/return).
These helpers are similar to eina_value_X_new(), however do not allocate the Eina_Value, rather return it. These are useful when the value struct storage was already there but needs to be initialized in a single line, like as stack variables or when returning a value.
-rw-r--r--src/lib/eina/eina_inline_value_util.x272
1 files changed, 272 insertions, 0 deletions
diff --git a/src/lib/eina/eina_inline_value_util.x b/src/lib/eina/eina_inline_value_util.x
index f863fd56cc..8a09f4cdea 100644
--- a/src/lib/eina/eina_inline_value_util.x
+++ b/src/lib/eina/eina_inline_value_util.x
@@ -400,6 +400,278 @@ eina_value_error_new(Eina_Error err)
400} 400}
401 401
402/** 402/**
403 * @brief Initialize #Eina_Value containing the passed parameter
404 * @param c The value to use
405 * @return The #Eina_Value
406 * @since 1.21
407 */
408static inline Eina_Value
409eina_value_uchar_init(unsigned char c)
410{
411 Eina_Value v = EINA_VALUE_EMPTY;
412
413 if (eina_value_setup(&v, EINA_VALUE_TYPE_UCHAR))
414 eina_value_set(&v, c);
415 return v;
416}
417
418/**
419 * @brief Initialize #Eina_Value containing the passed parameter
420 * @param s The value to use
421 * @return The #Eina_Value
422 * @since 1.21
423 */
424static inline Eina_Value
425eina_value_ushort_init(unsigned short s)
426{
427 Eina_Value v = EINA_VALUE_EMPTY;
428
429 if (eina_value_setup(&v, EINA_VALUE_TYPE_USHORT))
430 eina_value_set(&v, s);
431 return v;
432}
433
434/**
435 * @brief Initialize #Eina_Value containing the passed parameter
436 * @param i The value to use
437 * @return The #Eina_Value
438 * @since 1.21
439 */
440static inline Eina_Value
441eina_value_uint_init(unsigned int i)
442{
443 Eina_Value v = EINA_VALUE_EMPTY;
444
445 if (eina_value_setup(&v, EINA_VALUE_TYPE_UINT))
446 eina_value_set(&v, i);
447 return v;
448}
449
450/**
451 * @brief Create a new #EinaInitializeining the passed parameter
452 * @param l The value to use
453 * @return The #Eina_Value
454 * @since 1.21
455 */
456static inline Eina_Value
457eina_value_ulong_init(unsigned long l)
458{
459 Eina_Value v = EINA_VALUE_EMPTY;
460
461 if (eina_value_setup(&v, EINA_VALUE_TYPE_ULONG))
462 eina_value_set(&v, l);
463 return v;
464}
465
466/**
467 * @brief Initialize #Eina_Value containing the passed parameter
468 * @param i The value to use
469 * @return The #Eina_Value
470 * @since 1.21
471 */
472static inline Eina_Value
473eina_value_uint64_init(uint64_t i)
474{
475 Eina_Value v = EINA_VALUE_EMPTY;
476
477 if (eina_value_setup(&v, EINA_VALUE_TYPE_UINT64))
478 eina_value_set(&v, i);
479 return v;
480}
481
482/**
483 * @brief Create a new #EinaInitializeining the passed parameter
484 * @param c The value to use
485 * @return The #Eina_Value
486 * @since 1.21
487 */
488static inline Eina_Value
489eina_value_char_init(char c)
490{
491 Eina_Value v = EINA_VALUE_EMPTY;
492
493 if (eina_value_setup(&v, EINA_VALUE_TYPE_CHAR))
494 eina_value_set(&v, c);
495 return v;
496}
497
498/**
499 * @brief Initialize #Eina_Value containing the passed parameter
500 * @param s The value to use
501 * @return The #Eina_Value
502 * @since 1.21
503 */
504static inline Eina_Value
505eina_value_short_init(short s)
506{
507 Eina_Value v = EINA_VALUE_EMPTY;
508
509 if (eina_value_setup(&v, EINA_VALUE_TYPE_SHORT))
510 eina_value_set(&v, s);
511 return v;
512}
513
514/**
515 * @brief Create a new #EinaInitializeining the passed parameter
516 * @param i The value to use
517 * @return The #Eina_Value
518 * @since 1.21
519 */
520static inline Eina_Value
521eina_value_int_init(int i)
522{
523 Eina_Value v = EINA_VALUE_EMPTY;
524
525 if (eina_value_setup(&v, EINA_VALUE_TYPE_INT))
526 eina_value_set(&v, i);
527 return v;
528}
529
530/**
531 * @brief Initialize #Eina_Value containing the passed parameter
532 * @param l The value to use
533 * @return The #Eina_Value
534 * @since 1.21
535 */
536static inline Eina_Value
537eina_value_long_init(long l)
538{
539 Eina_Value v = EINA_VALUE_EMPTY;
540
541 if (eina_value_setup(&v, EINA_VALUE_TYPE_LONG))
542 eina_value_set(&v, l);
543 return v;
544}
545
546/**
547 * @brief Create a new #EinaInitializeining the passed parameter
548 * @param i The value to use
549 * @return The #Eina_Value
550 * @since 1.21
551 */
552static inline Eina_Value
553eina_value_int64_init(int64_t i)
554{
555 Eina_Value v = EINA_VALUE_EMPTY;
556
557 if (eina_value_setup(&v, EINA_VALUE_TYPE_INT64))
558 eina_value_set(&v, i);
559 return v;
560}
561
562/**
563 * @brief Initialize #Eina_Value containing the passed parameter
564 * @param f The value to use
565 * @return The #Eina_Value
566 * @since 1.21
567 */
568static inline Eina_Value
569eina_value_float_init(float f)
570{
571 Eina_Value v = EINA_VALUE_EMPTY;
572
573 if (eina_value_setup(&v, EINA_VALUE_TYPE_FLOAT))
574 eina_value_set(&v, f);
575 return v;
576}
577
578/**
579 * @brief Create a new #EinaInitializeining the passed parameter
580 * @param d The value to use
581 * @return The #Eina_Value
582 * @since 1.21
583 */
584static inline Eina_Value
585eina_value_double_init(double d)
586{
587 Eina_Value v = EINA_VALUE_EMPTY;
588
589 if (eina_value_setup(&v, EINA_VALUE_TYPE_DOUBLE))
590 eina_value_set(&v, d);
591 return v;
592}
593
594/**
595 * @brief Initialize #Eina_Value containing the passed parameter
596 * @param b The value to use
597 * @return The #Eina_Value
598 * @since 1.21
599 */
600static inline Eina_Value
601eina_value_bool_init(Eina_Bool b)
602{
603 Eina_Value v = EINA_VALUE_EMPTY;
604
605 if (eina_value_setup(&v, EINA_VALUE_TYPE_UCHAR))
606 eina_value_set(&v, b);
607 return v;
608}
609
610/**
611 * @brief Create a new #EinaInitializeining the passed parameter
612 * @param str The value to use
613 * @return The #Eina_Value
614 * @since 1.21
615 */
616static inline Eina_Value
617eina_value_string_init(const char *str)
618{
619 Eina_Value v = EINA_VALUE_EMPTY;
620
621 if (eina_value_setup(&v, EINA_VALUE_TYPE_STRING))
622 eina_value_set(&v, str);
623 return v;
624}
625
626/**
627 * @brief Initialize #Eina_Value containing the passed parameter
628 * @param str The value to use
629 * @return The #Eina_Value
630 * @since 1.21
631 */
632static inline Eina_Value
633eina_value_stringshare_init(const char *str)
634{
635 Eina_Value v = EINA_VALUE_EMPTY;
636
637 if (eina_value_setup(&v, EINA_VALUE_TYPE_STRINGSHARE))
638 eina_value_set(&v, str);
639 return v;
640}
641
642/**
643 * @brief Create a new #EinaInitializeining the passed parameter
644 * @param t The value to use
645 * @return The #Eina_Value
646 * @since 1.21
647 */
648static inline Eina_Value
649eina_value_time_init(time_t t)
650{
651 Eina_Value v = EINA_VALUE_EMPTY;
652
653 if (eina_value_setup(&v, EINA_VALUE_TYPE_TIMESTAMP))
654 eina_value_set(&v, t);
655 return v;
656}
657
658/**
659 * @brief Initialize #Eina_Value containing the passed parameter
660 * @param err The error code
661 * @return The #Eina_Value
662 * @since 1.21
663 */
664static inline Eina_Value
665eina_value_error_init(Eina_Error err)
666{
667 Eina_Value v = EINA_VALUE_EMPTY;
668
669 if (eina_value_setup(&v, EINA_VALUE_TYPE_ERROR))
670 eina_value_set(&v, err);
671 return v;
672}
673
674/**
403 * @brief Create a new #Eina_Value containing the passed parameter 675 * @brief Create a new #Eina_Value containing the passed parameter
404 * @param val The value to use 676 * @param val The value to use
405 * @return The #Eina_Value 677 * @return The #Eina_Value