diff --git a/src/bindings/eo_cxx/eo_base.hh b/src/bindings/eo_cxx/eo_base.hh
index 3953fb9a58..a99d614926 100644
--- a/src/bindings/eo_cxx/eo_base.hh
+++ b/src/bindings/eo_cxx/eo_base.hh
@@ -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,10 +70,27 @@ 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;
+ }
+
/// @brief Return a pointer to the EO Object stored in this
/// instance.
///
@@ -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 EO Object stored in this
+ /// instance.
+ ///
+ /// @return A pointer to the opaque EO Object.
+ ///
+ 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 EO Object.
diff --git a/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh b/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh
index adc4e63a3d..259fead103 100644
--- a/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh
+++ b/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh
@@ -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;
}