forked from enlightenment/efl
eolian-cxx: Added empty wrapper constructor
Added empty wrapper constructor to generation from std::nullptr_t and allowed efl::eo::base to be empty with proper copy-constructors and assignment operators.
This commit is contained in:
parent
c915df4f40
commit
377bb449ba
|
@ -38,14 +38,27 @@ struct base
|
|||
///
|
||||
explicit base(Eo* eo) : _eo_raw(eo)
|
||||
{
|
||||
assert(eo != 0);
|
||||
}
|
||||
|
||||
/// @brief Class destructor.
|
||||
///
|
||||
~base()
|
||||
{
|
||||
detail::unref(_eo_raw);
|
||||
if(_eo_raw)
|
||||
detail::unref(_eo_raw);
|
||||
}
|
||||
|
||||
base(base const& other)
|
||||
{
|
||||
if(other._eo_raw)
|
||||
_eo_raw = detail::ref(other._eo_raw);
|
||||
}
|
||||
|
||||
base(base&& other)
|
||||
{
|
||||
if(_eo_raw) detail::unref(_eo_raw);
|
||||
_eo_raw = other._eo_raw;
|
||||
other._eo_raw = nullptr;
|
||||
}
|
||||
|
||||
base(base const& other)
|
||||
|
@ -57,7 +70,24 @@ struct base
|
|||
///
|
||||
base& operator=(base const& other)
|
||||
{
|
||||
_eo_raw = detail::ref(other._eo_ptr());
|
||||
if(_eo_raw)
|
||||
{
|
||||
detail::unref(_eo_raw);
|
||||
_eo_raw = nullptr;
|
||||
}
|
||||
if(other._eo_raw)
|
||||
_eo_raw = detail::ref(other._eo_raw);
|
||||
return *this;
|
||||
}
|
||||
|
||||
base& operator=(base&& other)
|
||||
{
|
||||
if(_eo_raw)
|
||||
{
|
||||
detail::unref(_eo_raw);
|
||||
_eo_raw = nullptr;
|
||||
}
|
||||
std::swap(_eo_raw, other._eo_raw);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -68,6 +98,19 @@ struct base
|
|||
///
|
||||
Eo* _eo_ptr() const { return _eo_raw; }
|
||||
|
||||
/// @brief Releases the reference from this wrapper object and
|
||||
/// return the pointer to the <em>EO Object</em> stored in this
|
||||
/// instance.
|
||||
///
|
||||
/// @return A pointer to the opaque <em>EO Object</em>.
|
||||
///
|
||||
Eo* _release()
|
||||
{
|
||||
Eo* tmp = _eo_raw;
|
||||
_eo_raw = nullptr;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/// @brief Get the reference count of this object.
|
||||
///
|
||||
/// @return The referencer count of this object.
|
||||
|
@ -168,6 +211,10 @@ struct base
|
|||
return info;
|
||||
}
|
||||
|
||||
explicit operator bool() const
|
||||
{
|
||||
return _eo_raw;
|
||||
}
|
||||
protected:
|
||||
Eo* _eo_raw; ///< The opaque <em>EO Object</em>.
|
||||
|
||||
|
|
|
@ -94,6 +94,16 @@ operator<<(std::ostream& out, constructor_eo const& x)
|
|||
<< "explicit " << x._cls.name << "(Eo* eo)" << endl
|
||||
<< tab(2) << ": " << class_name(x._cls.parent) << "(eo)" << endl
|
||||
<< tab(1) << "{}" << endl << endl;
|
||||
|
||||
out << comment(
|
||||
"@brief nullptr_t Constructor.\n\n"
|
||||
"Constructs an empty (null) object.\n\n"
|
||||
, 1
|
||||
)
|
||||
<< tab(1)
|
||||
<< "explicit " << x._cls.name << "(std::nullptr_t)" << endl
|
||||
<< tab(2) << ": " << class_name(x._cls.parent) << "(nullptr)" << endl
|
||||
<< tab(1) << "{}" << endl << endl;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue