aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/eina/eina_inline_value_util.x
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 /src/lib/eina/eina_inline_value_util.x
parenteina_value_util: add missing eina_value_*_new() for basic types. (diff)
downloadefl-f4b02d87d6601eaa524dd23f84313bc3069fc594.tar.gz
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.
Diffstat (limited to '')
-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)
}
/**
+ * @brief Initialize #Eina_Value containing the passed parameter
+ * @param c The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_uchar_init(unsigned char c)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_UCHAR))
+ eina_value_set(&v, c);
+ return v;
+}
+
+/**
+ * @brief Initialize #Eina_Value containing the passed parameter
+ * @param s The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_ushort_init(unsigned short s)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_USHORT))
+ eina_value_set(&v, s);
+ return v;
+}
+
+/**
+ * @brief Initialize #Eina_Value containing the passed parameter
+ * @param i The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_uint_init(unsigned int i)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_UINT))
+ eina_value_set(&v, i);
+ return v;
+}
+
+/**
+ * @brief Create a new #EinaInitializeining the passed parameter
+ * @param l The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_ulong_init(unsigned long l)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_ULONG))
+ eina_value_set(&v, l);
+ return v;
+}
+
+/**
+ * @brief Initialize #Eina_Value containing the passed parameter
+ * @param i The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_uint64_init(uint64_t i)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_UINT64))
+ eina_value_set(&v, i);
+ return v;
+}
+
+/**
+ * @brief Create a new #EinaInitializeining the passed parameter
+ * @param c The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_char_init(char c)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_CHAR))
+ eina_value_set(&v, c);
+ return v;
+}
+
+/**
+ * @brief Initialize #Eina_Value containing the passed parameter
+ * @param s The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_short_init(short s)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_SHORT))
+ eina_value_set(&v, s);
+ return v;
+}
+
+/**
+ * @brief Create a new #EinaInitializeining the passed parameter
+ * @param i The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_int_init(int i)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_INT))
+ eina_value_set(&v, i);
+ return v;
+}
+
+/**
+ * @brief Initialize #Eina_Value containing the passed parameter
+ * @param l The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_long_init(long l)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_LONG))
+ eina_value_set(&v, l);
+ return v;
+}
+
+/**
+ * @brief Create a new #EinaInitializeining the passed parameter
+ * @param i The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_int64_init(int64_t i)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_INT64))
+ eina_value_set(&v, i);
+ return v;
+}
+
+/**
+ * @brief Initialize #Eina_Value containing the passed parameter
+ * @param f The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_float_init(float f)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_FLOAT))
+ eina_value_set(&v, f);
+ return v;
+}
+
+/**
+ * @brief Create a new #EinaInitializeining the passed parameter
+ * @param d The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_double_init(double d)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_DOUBLE))
+ eina_value_set(&v, d);
+ return v;
+}
+
+/**
+ * @brief Initialize #Eina_Value containing the passed parameter
+ * @param b The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_bool_init(Eina_Bool b)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_UCHAR))
+ eina_value_set(&v, b);
+ return v;
+}
+
+/**
+ * @brief Create a new #EinaInitializeining the passed parameter
+ * @param str The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_string_init(const char *str)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_STRING))
+ eina_value_set(&v, str);
+ return v;
+}
+
+/**
+ * @brief Initialize #Eina_Value containing the passed parameter
+ * @param str The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_stringshare_init(const char *str)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_STRINGSHARE))
+ eina_value_set(&v, str);
+ return v;
+}
+
+/**
+ * @brief Create a new #EinaInitializeining the passed parameter
+ * @param t The value to use
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_time_init(time_t t)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_TIMESTAMP))
+ eina_value_set(&v, t);
+ return v;
+}
+
+/**
+ * @brief Initialize #Eina_Value containing the passed parameter
+ * @param err The error code
+ * @return The #Eina_Value
+ * @since 1.21
+ */
+static inline Eina_Value
+eina_value_error_init(Eina_Error err)
+{
+ Eina_Value v = EINA_VALUE_EMPTY;
+
+ if (eina_value_setup(&v, EINA_VALUE_TYPE_ERROR))
+ eina_value_set(&v, err);
+ return v;
+}
+
+/**
* @brief Create a new #Eina_Value containing the passed parameter
* @param val The value to use
* @return The #Eina_Value