Proper deprecation to alert users to API name changes.

This commit is contained in:
ThePhD 2014-09-19 11:08:44 -04:00
parent 746ef74a61
commit a217fa5c7a
4 changed files with 48 additions and 2 deletions

View File

@ -147,6 +147,26 @@ public:
return *this; return *this;
} }
template<typename T>
SOL_DEPRECATED table& set_userdata(usertype<T>& user) {
return set_usertype(user);
}
template<typename Key, typename T>
SOL_DEPRECATED table& set_userdata(Key&& key, usertype<T>& user) {
return set_usertype(std::forward<Key>(key), user);
}
template<typename Class, typename... CTor, typename... Args>
SOL_DEPRECATED state& new_userdata(const std::string& name, Args&&... args) {
return new_usertype<Class>(name, std::forward<Args>(args)...);
}
template<typename Class, typename... CArgs, typename... Args>
SOL_DEPRECATED state& new_userdata(const std::string& name, constructors<CArgs...> ctor, Args&&... args) {
return new_usertype(name, std::move(ctor), std::forward<Args>(args)...);
}
template<typename T> template<typename T>
state& set_usertype(usertype<T>& user) { state& set_usertype(usertype<T>& user) {
return set_usertype(usertype_traits<T>::name, user); return set_usertype(usertype_traits<T>::name, user);

View File

@ -83,9 +83,19 @@ public:
return *this; return *this;
} }
template<typename T>
SOL_DEPRECATED table& set_userdata(usertype<T>& user) {
return set_usertype(user);
}
template<typename Key, typename T>
SOL_DEPRECATED table& set_userdata(Key&& key, usertype<T>& user) {
return set_usertype(std::forward<Key>(key), user);
}
template<typename T> template<typename T>
table& set_usertype(usertype<T>& user) { table& set_usertype(usertype<T>& user) {
return set_userdata(usertype_traits<T>::name, user); return set_usertype(usertype_traits<T>::name, user);
} }
template<typename Key, typename T> template<typename Key, typename T>

View File

@ -90,7 +90,7 @@ inline std::string type_name(lua_State*L, type t) {
} }
template<typename T> template<typename T>
class userdata; class usertype;
class table; class table;
class function; class function;
class object; class object;

View File

@ -26,6 +26,7 @@
#include "function_types.hpp" #include "function_types.hpp"
#include "usertype_traits.hpp" #include "usertype_traits.hpp"
#include "default_construct.hpp" #include "default_construct.hpp"
#include "deprecate.hpp"
#include <vector> #include <vector>
#include <array> #include <array>
#include <algorithm> #include <algorithm>
@ -315,6 +316,18 @@ public:
template<typename... Args> template<typename... Args>
usertype(Args&&... args): usertype(default_constructor, std::forward<Args>(args)...) {} usertype(Args&&... args): usertype(default_constructor, std::forward<Args>(args)...) {}
template<typename... Args>
SOL_DEPRECATED usertype(std::string, Args&&... args): usertype(default_constructor, std::forward<Args>(args)...) {}
template<typename... Args>
SOL_DEPRECATED usertype(const char*, Args&&... args): usertype(default_constructor, std::forward<Args>(args)...) {}
template<typename... Args, typename... CArgs>
SOL_DEPRECATED usertype(std::string, constructors<CArgs...> c, Args&&... args) : usertype(std::move(c), std::forward<Args>(args)...) {}
template<typename... Args, typename... CArgs>
SOL_DEPRECATED usertype(const char*, constructors<CArgs...> c, Args&&... args) : usertype(std::move(c), std::forward<Args>(args)...) {}
template<typename... Args, typename... CArgs> template<typename... Args, typename... CArgs>
usertype(constructors<CArgs...>, Args&&... args) { usertype(constructors<CArgs...>, Args&&... args) {
functionnames.reserve(sizeof...(args) + 2); functionnames.reserve(sizeof...(args) + 2);
@ -392,6 +405,9 @@ private:
} }
}; };
template <typename T>
using userdata = typename detail::deprecate_type<usertype<T>>::type;
namespace stack { namespace stack {
template<typename T> template<typename T>
struct pusher<usertype<T>> { struct pusher<usertype<T>> {