eo: add an helper to get an object from an Eina_Value.
authorCedric Bail <cedric@osg.samsung.com>
Thu, 7 Dec 2017 05:58:30 +0000 (21:58 -0800)
committerWonki Kim <wonki_.kim@samsung.com>
Tue, 10 Apr 2018 11:10:54 +0000 (20:10 +0900)
src/lib/eo/Eo.h

index 7c20daa..f511562 100644 (file)
@@ -2058,6 +2058,7 @@ EOAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_OBJECT;
  * @brief Create a new #Eina_Value containing the passed parameter.
  * @param obj The object to use
  * @return The #Eina_Value
+ * @see eina_value_object_get(), eina_value_object_init()
  * @since 1.21
  */
 static inline Eina_Value *
@@ -2074,6 +2075,7 @@ eina_value_object_new(Eo *obj)
  * @brief Create a new #Eina_Value initialized with the passed parameter
  * @param obj The object to use
  * @return The #Eina_Value
+ * @see eina_value_object_new(), eina_value_object_get()
  * @since 1.21
  */
 static inline Eina_Value
@@ -2087,6 +2089,26 @@ eina_value_object_init(Eo *obj)
 }
 
 /**
+ * @brief Get the object contained in an #Eina_Value
+ * @param v The #Eina_Value to extract the object from
+ * @return The object.
+ * @see eina_value_object_new(), eina_value_object_init()
+ * @since 1.21
+ */
+static inline Eo *
+eina_value_object_get(Eina_Value *v)
+{
+   Eo *r = NULL;
+
+   if (!v) return NULL;
+   if (eina_value_type_get(v) != EINA_VALUE_TYPE_OBJECT)
+     return NULL;
+
+   eina_value_pget(v, &r);
+   return r;
+}
+
+/**
  * @}
  */