summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2019-01-22 12:34:16 +0000
committerCedric BAIL <cedric.bail@free.fr>2019-01-23 10:54:09 -0800
commitde608bb2031419c417581c7abf59aa2e2dec7164 (patch)
tree00247fd1dbb567cc07680e5a18b10c7fc82ef054 /src/lib/eina
parente863a3d28a3bfcc227145a231c73355808e48bf7 (diff)
eina: refactor eina_value_*_get.
Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es> Differential Revision: https://phab.enlightenment.org/D7699
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_inline_value_util.x341
1 files changed, 37 insertions, 304 deletions
diff --git a/src/lib/eina/eina_inline_value_util.x b/src/lib/eina/eina_inline_value_util.x
index 5dc2a9b8df..a523a661b6 100644
--- a/src/lib/eina/eina_inline_value_util.x
+++ b/src/lib/eina/eina_inline_value_util.x
@@ -675,311 +675,44 @@ eina_value_error_init(Eina_Error err)
675 return v; 675 return v;
676} 676}
677 677
678/// @brief For internal use only.
679/// @hideinitializer
680#define EINA_VALUE_GET(Compress_Type, Uppercase_Compress_Type, Type) \
678/** 681/**
679 * @brief Check value type and get contents. 682 @brief Check value type and get contents.
680 * @param v The value to check type and get contents. 683 @param v The value to check type and get contents.
681 * @param c Where to store the value contents. 684 @param c Where to store the value contents.
682 * @return #EINA_TRUE if type matches and fetched contents, 685 @return #EINA_TRUE if type matches and fetched contents,
683 * #EINA_FALSE on different type or failures. 686 #EINA_FALSE on different type or failures.
684 * @since 1.21 687 @since 1.21
685 */ 688 */ \
686static inline Eina_Bool 689static inline Eina_Bool \
687eina_value_uchar_get(const Eina_Value *v, unsigned char *c) 690eina_value_##Compress_Type##_get(const Eina_Value *v, Type *c) \
688{ 691{ \
689 EINA_SAFETY_ON_NULL_RETURN_VAL(c, EINA_FALSE); 692 EINA_SAFETY_ON_NULL_RETURN_VAL(c, EINA_FALSE); \
690 *c = 0; 693 *c = 0; \
691 if (v && v->type == EINA_VALUE_TYPE_UCHAR) 694 if (v && v->type == EINA_VALUE_TYPE_##Uppercase_Compress_Type) \
692 return eina_value_get(v, c); 695 return eina_value_get(v, c); \
693 return EINA_FALSE; 696 return EINA_FALSE; \
694} 697}
695 698
696/** 699EINA_VALUE_GET(uchar, UCHAR, unsigned char);
697 * @brief Check value type and get contents. 700EINA_VALUE_GET(ushort, USHORT, unsigned short);
698 * @param v The value to check type and get contents. 701EINA_VALUE_GET(uint, UINT, unsigned int);
699 * @param s Where to store the value contents. 702EINA_VALUE_GET(ulong, ULONG, unsigned long);
700 * @return #EINA_TRUE if type matches and fetched contents, 703EINA_VALUE_GET(uint64, UINT64, uint64_t);
701 * #EINA_FALSE on different type or failures. 704EINA_VALUE_GET(char, CHAR, char);
702 * @since 1.21 705EINA_VALUE_GET(short, SHORT, short);
703 */ 706EINA_VALUE_GET(int, INT, int);
704static inline Eina_Bool 707EINA_VALUE_GET(long, LONG, long);
705eina_value_ushort_get(const Eina_Value *v, unsigned short *s) 708EINA_VALUE_GET(int64, INT64, int64_t);
706{ 709EINA_VALUE_GET(float, FLOAT, float);
707 EINA_SAFETY_ON_NULL_RETURN_VAL(s, EINA_FALSE); 710EINA_VALUE_GET(double, DOUBLE, double);
708 *s = 0; 711EINA_VALUE_GET(bool, BOOL, Eina_Bool);
709 if (v && v->type == EINA_VALUE_TYPE_USHORT) 712EINA_VALUE_GET(string, STRING, const char *);
710 return eina_value_get(v, s); 713EINA_VALUE_GET(stringshare, STRINGSHARE, const char *);
711 return EINA_FALSE; 714EINA_VALUE_GET(time, TIMESTAMP, time_t);
712} 715EINA_VALUE_GET(error, ERROR, Eina_Error);
713
714/**
715 * @brief Check value type and get contents.
716 * @param v The value to check type and get contents.
717 * @param i Where to store the value contents.
718 * @return #EINA_TRUE if type matches and fetched contents,
719 * #EINA_FALSE on different type or failures.
720 * @since 1.21
721 */
722static inline Eina_Bool
723eina_value_uint_get(const Eina_Value *v, unsigned int *i)
724{
725 EINA_SAFETY_ON_NULL_RETURN_VAL(i, EINA_FALSE);
726 *i = 0;
727 if (v && v->type == EINA_VALUE_TYPE_UINT)
728 return eina_value_get(v, i);
729 return EINA_FALSE;
730}
731
732/**
733 * @brief Check value type and get contents.
734 * @param v The value to check type and get contents.
735 * @param l Where to store the value contents.
736 * @return #EINA_TRUE if type matches and fetched contents,
737 * #EINA_FALSE on different type or failures.
738 * @since 1.21
739 */
740static inline Eina_Bool
741eina_value_ulong_get(const Eina_Value *v, unsigned long *l)
742{
743 EINA_SAFETY_ON_NULL_RETURN_VAL(l, EINA_FALSE);
744 *l = 0;
745 if (v && v->type == EINA_VALUE_TYPE_ULONG)
746 return eina_value_get(v, l);
747 return EINA_FALSE;
748}
749
750/**
751 * @brief Check value type and get contents.
752 * @param v The value to check type and get contents.
753 * @param i Where to store the value contents.
754 * @return #EINA_TRUE if type matches and fetched contents,
755 * #EINA_FALSE on different type or failures.
756 * @since 1.21
757 */
758static inline Eina_Bool
759eina_value_uint64_get(const Eina_Value *v, uint64_t *i)
760{
761 EINA_SAFETY_ON_NULL_RETURN_VAL(i, EINA_FALSE);
762 *i = 0;
763 if (v && v->type == EINA_VALUE_TYPE_UINT64)
764 return eina_value_get(v, i);
765 return EINA_FALSE;
766}
767
768/**
769 * @brief Check value type and get contents.
770 * @param v The value to check type and get contents.
771 * @param c Where to store the value contents.
772 * @return #EINA_TRUE if type matches and fetched contents,
773 * #EINA_FALSE on different type or failures.
774 * @since 1.21
775 */
776static inline Eina_Bool
777eina_value_char_get(const Eina_Value *v, char *c)
778{
779 EINA_SAFETY_ON_NULL_RETURN_VAL(c, EINA_FALSE);
780 *c = 0;
781 if (v && v->type == EINA_VALUE_TYPE_CHAR)
782 return eina_value_get(v, c);
783 return EINA_FALSE;
784}
785
786/**
787 * @brief Check value type and get contents.
788 * @param v The value to check type and get contents.
789 * @param s Where to store the value contents.
790 * @return #EINA_TRUE if type matches and fetched contents,
791 * #EINA_FALSE on different type or failures.
792 * @since 1.21
793 */
794static inline Eina_Bool
795eina_value_short_get(const Eina_Value *v, short *s)
796{
797 EINA_SAFETY_ON_NULL_RETURN_VAL(s, EINA_FALSE);
798 *s = 0;
799 if (v && v->type == EINA_VALUE_TYPE_SHORT)
800 return eina_value_get(v, s);
801 return EINA_FALSE;
802}
803
804/**
805 * @brief Check value type and get contents.
806 * @param v The value to check type and get contents.
807 * @param i Where to store the value contents.
808 * @return #EINA_TRUE if type matches and fetched contents,
809 * #EINA_FALSE on different type or failures.
810 * @since 1.21
811 */
812static inline Eina_Bool
813eina_value_int_get(const Eina_Value *v, int *i)
814{
815 EINA_SAFETY_ON_NULL_RETURN_VAL(i, EINA_FALSE);
816 *i = 0;
817 if (v && v->type == EINA_VALUE_TYPE_INT)
818 return eina_value_get(v, i);
819 return EINA_FALSE;
820}
821
822/**
823 * @brief Check value type and get contents.
824 * @param v The value to check type and get contents.
825 * @param l Where to store the value contents.
826 * @return #EINA_TRUE if type matches and fetched contents,
827 * #EINA_FALSE on different type or failures.
828 * @since 1.21
829 */
830static inline Eina_Bool
831eina_value_long_get(const Eina_Value *v, long *l)
832{
833 EINA_SAFETY_ON_NULL_RETURN_VAL(l, EINA_FALSE);
834 *l = 0;
835 if (v && v->type == EINA_VALUE_TYPE_LONG)
836 return eina_value_get(v, l);
837 return EINA_FALSE;
838}
839
840/**
841 * @brief Check value type and get contents.
842 * @param v The value to check type and get contents.
843 * @param i Where to store the value contents.
844 * @return #EINA_TRUE if type matches and fetched contents,
845 * #EINA_FALSE on different type or failures.
846 * @since 1.21
847 */
848static inline Eina_Bool
849eina_value_int64_get(const Eina_Value *v, int64_t *i)
850{
851 EINA_SAFETY_ON_NULL_RETURN_VAL(i, EINA_FALSE);
852 *i = 0;
853 if (v && v->type == EINA_VALUE_TYPE_INT64)
854 return eina_value_get(v, i);
855 return EINA_FALSE;
856}
857
858/**
859 * @brief Check value type and get contents.
860 * @param v The value to check type and get contents.
861 * @param f Where to store the value contents.
862 * @return #EINA_TRUE if type matches and fetched contents,
863 * #EINA_FALSE on different type or failures.
864 * @since 1.21
865 */
866static inline Eina_Bool
867eina_value_float_get(const Eina_Value *v, float *f)
868{
869 EINA_SAFETY_ON_NULL_RETURN_VAL(f, EINA_FALSE);
870 *f = 0.0f;
871 if (v && v->type == EINA_VALUE_TYPE_FLOAT)
872 return eina_value_get(v, f);
873 return EINA_FALSE;
874}
875
876/**
877 * @brief Check value type and get contents.
878 * @param v The value to check type and get contents.
879 * @param d Where to store the value contents.
880 * @return #EINA_TRUE if type matches and fetched contents,
881 * #EINA_FALSE on different type or failures.
882 * @since 1.21
883 */
884static inline Eina_Bool
885eina_value_double_get(const Eina_Value *v, double *d)
886{
887 EINA_SAFETY_ON_NULL_RETURN_VAL(d, EINA_FALSE);
888 *d = 0.0;
889 if (v && v->type == EINA_VALUE_TYPE_DOUBLE)
890 return eina_value_get(v, d);
891 return EINA_FALSE;
892}
893
894/**
895 * @brief Check value type and get contents.
896 * @param v The value to check type and get contents.
897 * @param b Where to store the value contents.
898 * @return #EINA_TRUE if type matches and fetched contents,
899 * #EINA_FALSE on different type or failures.
900 * @since 1.21
901 */
902static inline Eina_Bool
903eina_value_bool_get(const Eina_Value *v, Eina_Bool *b)
904{
905 EINA_SAFETY_ON_NULL_RETURN_VAL(b, EINA_FALSE);
906 *b = EINA_FALSE;
907 if (v && v->type == EINA_VALUE_TYPE_BOOL)
908 return eina_value_get(v, b);
909 return EINA_FALSE;
910}
911
912/**
913 * @brief Check value type and get contents.
914 * @param v The value to check type and get contents.
915 * @param str Where to store the value contents.
916 * @return #EINA_TRUE if type matches and fetched contents,
917 * #EINA_FALSE on different type or failures.
918 * @since 1.21
919 */
920static inline Eina_Bool
921eina_value_string_get(const Eina_Value *v, const char **str)
922{
923 EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
924 *str = NULL;
925 if (v && v->type == EINA_VALUE_TYPE_STRING)
926 return eina_value_get(v, str);
927 return EINA_FALSE;
928}
929
930/**
931 * @brief Check value type and get contents.
932 * @param v The value to check type and get contents.
933 * @param str Where to store the value contents.
934 * @return #EINA_TRUE if type matches and fetched contents,
935 * #EINA_FALSE on different type or failures.
936 * @since 1.21
937 */
938static inline Eina_Bool
939eina_value_stringshare_get(const Eina_Value *v, const char **str)
940{
941 EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
942 *str = NULL;
943 if (v && v->type == EINA_VALUE_TYPE_STRINGSHARE)
944 return eina_value_get(v, str);
945 return EINA_FALSE;
946}
947
948/**
949 * @brief Check value type and get contents.
950 * @param v The value to check type and get contents.
951 * @param t Where to store the value contents.
952 * @return #EINA_TRUE if type matches and fetched contents,
953 * #EINA_FALSE on different type or failures.
954 * @since 1.21
955 */
956static inline Eina_Bool
957eina_value_time_get(const Eina_Value *v, time_t *t)
958{
959 EINA_SAFETY_ON_NULL_RETURN_VAL(t, EINA_FALSE);
960 *t = 0;
961 if (v && v->type == EINA_VALUE_TYPE_TIMESTAMP)
962 return eina_value_get(v, t);
963 return EINA_FALSE;
964}
965
966/**
967 * @brief Check value type and get contents.
968 * @param v The value to check type and get contents.
969 * @param err Where to store the value contents.
970 * @return #EINA_TRUE if type matches and fetched contents,
971 * #EINA_FALSE on different type or failures.
972 * @since 1.21
973 */
974static inline Eina_Bool
975eina_value_error_get(const Eina_Value *v, Eina_Error *err)
976{
977 EINA_SAFETY_ON_NULL_RETURN_VAL(err, EINA_FALSE);
978 *err = 0;
979 if (v && v->type == EINA_VALUE_TYPE_ERROR)
980 return eina_value_get(v, err);
981 return EINA_FALSE;
982}
983 716
984/// @brief For internal use only. 717/// @brief For internal use only.
985/// @hideinitializer 718/// @hideinitializer