1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-20 19:57:12 +01:00

Implement move semantics on the Sqrat table wrapper.

This commit is contained in:
Sandu Liviu Catalin 2016-06-12 13:43:19 +03:00
parent 4eaf365bee
commit 3ca90d0698

View File

@ -66,6 +66,19 @@ public:
TableBase(const Object& obj) : Object(obj) {
}
#ifdef SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Construct the TableBase from an Object that already exists
///
/// \param obj An Object that should already represent a Squirrel table
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TableBase(Object&& obj) : Object(std::move(obj)) {
}
#endif // SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Construct the TableBase from a HSQOBJECT and HSQUIRRELVM that already exist
///
@ -76,6 +89,58 @@ public:
TableBase(HSQOBJECT o, HSQUIRRELVM v = DefaultVM::Get()) : Object(o, v) {
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Copy constructor
///
/// \param st TableBase to copy
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TableBase(const TableBase& st) : Object(st) {
}
#ifdef SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Move constructor
///
/// \param st TableBase to move
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TableBase(TableBase&& st) : Object(std::move(st)) {
}
#endif // SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Assignment operator
///
/// \param st TableBase to copy
///
/// \return The TableBase itself
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TableBase& operator=(const TableBase& st) {
Object::operator = (st);
return *this;
}
#ifdef SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Assignment operator
///
/// \param st TableBase to move
///
/// \return The TableBase itself
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TableBase& operator=(TableBase&& st) {
Object::operator = (std::move(st));
return *this;
}
#endif // SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Binds a Table or Class to the Table (can be used to facilitate namespaces)
///
@ -428,6 +493,19 @@ public:
Table(const Object& obj) : TableBase(obj) {
}
#ifdef SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Construct the Table from an Object that already exists
///
/// \param obj An Object that should already represent a Squirrel table
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Table(Object&& obj) : TableBase(std::move(obj)) {
}
#endif // SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Construct the Table from a HSQOBJECT and HSQUIRRELVM that already exist
///
@ -437,6 +515,59 @@ public:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Table(HSQOBJECT o, HSQUIRRELVM v = DefaultVM::Get()) : TableBase(o, v) {
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Copy constructor
///
/// \param st Table to copy
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Table(const Table& st) : TableBase(st) {
}
#ifdef SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Move constructor
///
/// \param st Table to move
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Table(Table&& st) : TableBase(std::move(st)) {
}
#endif // SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Assignment operator
///
/// \param st Table to copy
///
/// \return The Table itself
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Table& operator=(const Table& st) {
TableBase::operator = (st);
return *this;
}
#ifdef SCRAT_USE_CXX11_OPTIMIZATIONS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Assignment operator
///
/// \param st Table to move
///
/// \return The Table itself
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Table& operator=(Table&& st) {
TableBase::operator = (std::move(st));
return *this;
}
#endif // SCRAT_USE_CXX11_OPTIMIZATIONS
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////