assert(!type.empty());
if (parameter_is_out(parameter))
{
- type = { efl::eolian::type_to_native(type) };
+ if (type.front().native == "char *")
+ type = { efl::eolian::type_to_native(type) };
+ type.front().is_out = true;
type.front().native += "*";
}
if (parameter_is_const(parameter, func_type))
//// From C++ to C
-inline Eo*
-to_c(efl::eo::base const& x)
-{
- return x._eo_ptr();
-}
-
inline const char*
to_c(std::string const& x)
{
}
template <typename T>
-T to_c(T const& v, typename std::enable_if<!std::is_base_of<efl::eo::base, T>::value>::type* = 0)
+T to_c(T const& v, typename std::enable_if<!std::is_convertible<T*, efl::eo::base*>::value>::type* = 0)
{
return v;
}
+
+template <typename T>
+Eo* to_c(T const& v, typename std::enable_if<std::is_convertible<T*, efl::eo::base*>::value>::type* = 0)
+{
+ return v._eo_ptr();
+}
+
+template <typename T>
+Eo** to_c(T* v, typename std::enable_if<std::is_convertible<T*, efl::eo::base*>::value>::type* = 0)
+{
+ static_assert(sizeof(T) == sizeof(Eo*), "");
+ return static_cast<Eo**>(static_cast<void*>(v));
+}
+
+template <typename R, typename T>
+R to_native(T const& v)
+{
+ static_assert(sizeof(T) == sizeof(R), "");
+ return v.native_handle();
+}
+
+template <typename R, typename T>
+R to_native(T* v)
+{
+ static_assert(sizeof(T) == sizeof(typename std::remove_pointer<R>::type), "");
+ return static_cast<R>(static_cast<void*>(v));
+}
+
//// From C to C++
, category(unknown_)
, is_const(false)
, is_own(false)
+ , is_out(false)
, binding()
, includes()
{}
, category(category_)
, is_const(is_const_)
, is_own(is_own_)
+ , is_out(false)
, binding(binding_)
, includes(includes_)
{
category_type category;
bool is_const;
bool is_own;
+ bool is_out;
std::string binding;
includes_container_type includes;
};
return type_is_binding(type.front());
}
+inline bool
+type_is_out(eolian_type const& type)
+{
+ return type.is_out;
+}
+
+inline bool
+type_is_out(eolian_type_instance const& type)
+{
+ assert(!type.empty());
+ return type_is_out(type.front());
+}
+
inline eolian_type
type_to_native(eolian_type const& type)
{
return type.category == eolian_type::complex_;
}
+inline bool
+type_is_complex(eolian_type_instance const& type_ins)
+{
+ assert(!type_ins.empty());
+ return type_is_complex(type_ins.front());
+}
+
template <typename T>
inline bool
type_is_callback(T const&);
std::string res;
for (auto rit = x._list.rbegin(), last = x._list.rend(); rit != last; ++rit)
{
- if (type_is_complex(*rit))
- res = (*rit).binding + "< " + res + " >";
+ eolian_type const& t = *rit;
+ if (type_is_complex(t))
+ res = t.binding + "< " + res + " >" + (t.is_out ? "*" : "");
else
- res = type_is_binding(*rit) ? (*rit).binding : (*rit).native;
+ res = type_is_binding(t) ? t.binding + (t.is_out ? "*" : "")
+ : t.native;
}
assert(!res.empty());
return out << res;
if (type_is_callback(x._type))
out << "efl::eolian::get_callback<" << type_to_native_str(x._type)
<< ", " << parameter_no_ref_type(x._type, x._varname) << " >()";
+ else if (type_is_complex(x._type) && type_is_binding(x._type))
+ out << "efl::eolian::to_native<" << c_type(x._type) << ">(" << x._varname << ")";
else if (type_is_binding(x._type))
out << "efl::eolian::to_c(" << x._varname << ")";
else