cxx: Give ref to returned objects
authorJean-Philippe Andre <jp.andre@samsung.com>
Tue, 28 Nov 2017 05:37:33 +0000 (14:37 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Tue, 5 Dec 2017 01:17:02 +0000 (10:17 +0900)
This should give a ref to obj in the following scenario:

  auto obj = other.function();

Where obj is an eo object.

src/bindings/cxx/eo_cxx/eo_cxx_interop.hh

index 9181c11..ffc486e 100644 (file)
@@ -646,13 +646,13 @@ T& convert_to_return(T* value, tag<T*, T&>)
 template <typename T>
 T convert_to_return(Eo* value, tag<Eo*, T>, typename std::enable_if< eo::is_eolian_object<T>::value>::type* = 0)
 {
-  T v{value};
+  T v{eo::detail::ref(value)};
   return v;
 }
 template <typename T>
 T convert_to_return(Eo const* value, tag<Eo const*, T>, typename std::enable_if<eo::is_eolian_object<T>::value>::type* = 0)
 {
-  return T{const_cast<Eo*>(value)};
+  return T{const_cast<Eo*>(eo::detail::ref(value))};
 }
 template <typename T>
 eina::list<T> convert_to_return(Eina_List* value, tag<Eina_List*, eina::list<T>>)