mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-20 17:58:20 +00:00
Revert "Build System Updated"
This commit is contained in:
@@ -5,79 +5,79 @@
|
||||
#ifndef LUABIND_SHARED_PTR_CONVERTER_090211_HPP
|
||||
# define LUABIND_SHARED_PTR_CONVERTER_090211_HPP
|
||||
|
||||
#include <luabind/detail/policy.hpp>
|
||||
#include <luabind/detail/conversion_policies/value_converter.hpp> // for default_converter, etc
|
||||
#include <luabind/get_main_thread.hpp> // for get_main_thread
|
||||
#include <luabind/handle.hpp> // for handle
|
||||
#include <luabind/detail/decorate_type.hpp> // for decorated_type
|
||||
#include <memory>
|
||||
# include <luabind/get_main_thread.hpp>
|
||||
# include <luabind/handle.hpp>
|
||||
# include <luabind/detail/policy.hpp>
|
||||
# include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace luabind {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct shared_ptr_deleter
|
||||
{
|
||||
shared_ptr_deleter(lua_State* L, int index)
|
||||
: life_support(get_main_thread(L), L, index)
|
||||
{}
|
||||
struct shared_ptr_deleter
|
||||
{
|
||||
shared_ptr_deleter(lua_State* L, int index)
|
||||
: life_support(get_main_thread(L), L, index)
|
||||
{}
|
||||
|
||||
void operator()(void const*)
|
||||
{
|
||||
handle().swap(life_support);
|
||||
}
|
||||
void operator()(void const*)
|
||||
{
|
||||
handle().swap(life_support);
|
||||
}
|
||||
|
||||
handle life_support;
|
||||
};
|
||||
handle life_support;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace detail
|
||||
|
||||
template <class T>
|
||||
struct default_converter<std::shared_ptr<T> >
|
||||
: default_converter<T*>
|
||||
{
|
||||
using is_native = std::false_type;
|
||||
template <class T>
|
||||
struct default_converter<boost::shared_ptr<T> >
|
||||
: default_converter<T*>
|
||||
{
|
||||
typedef boost::mpl::false_ is_native;
|
||||
|
||||
template <class U>
|
||||
int match(lua_State* L, U, int index)
|
||||
{
|
||||
return default_converter<T*>::match(L, decorate_type_t<T*>(), index);
|
||||
}
|
||||
template <class U>
|
||||
int match(lua_State* L, U, int index)
|
||||
{
|
||||
return default_converter<T*>::match(
|
||||
L, LUABIND_DECORATE_TYPE(T*), index);
|
||||
}
|
||||
|
||||
template <class U>
|
||||
std::shared_ptr<T> to_cpp(lua_State* L, U, int index)
|
||||
{
|
||||
T* raw_ptr = default_converter<T*>::to_cpp(L, decorate_type_t<T*>(), index);
|
||||
template <class U>
|
||||
boost::shared_ptr<T> apply(lua_State* L, U, int index)
|
||||
{
|
||||
T* raw_ptr = default_converter<T*>::apply(
|
||||
L, LUABIND_DECORATE_TYPE(T*), index);
|
||||
if (!raw_ptr)
|
||||
return boost::shared_ptr<T>();
|
||||
return boost::shared_ptr<T>(
|
||||
raw_ptr, detail::shared_ptr_deleter(L, index));
|
||||
}
|
||||
|
||||
if(!raw_ptr) {
|
||||
return std::shared_ptr<T>();
|
||||
} else {
|
||||
return std::shared_ptr<T>(raw_ptr, detail::shared_ptr_deleter(L, index));
|
||||
}
|
||||
}
|
||||
void apply(lua_State* L, boost::shared_ptr<T> const& p)
|
||||
{
|
||||
if (detail::shared_ptr_deleter* d =
|
||||
boost::get_deleter<detail::shared_ptr_deleter>(p))
|
||||
{
|
||||
d->life_support.push(L);
|
||||
}
|
||||
else
|
||||
{
|
||||
detail::value_converter().apply(L, p);
|
||||
}
|
||||
}
|
||||
|
||||
void to_lua(lua_State* L, std::shared_ptr<T> const& p)
|
||||
{
|
||||
if(detail::shared_ptr_deleter* d = std::get_deleter<detail::shared_ptr_deleter>(p))
|
||||
{
|
||||
d->life_support.push(L);
|
||||
} else {
|
||||
detail::value_converter().to_lua(L, p);
|
||||
}
|
||||
}
|
||||
template <class U>
|
||||
void converter_postcall(lua_State*, U const&, int)
|
||||
{}
|
||||
};
|
||||
|
||||
template <class U>
|
||||
void converter_postcall(lua_State*, U const&, int)
|
||||
{}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct default_converter<std::shared_ptr<T> const&>
|
||||
: default_converter<std::shared_ptr<T> >
|
||||
{};
|
||||
template <class T>
|
||||
struct default_converter<boost::shared_ptr<T> const&>
|
||||
: default_converter<boost::shared_ptr<T> >
|
||||
{};
|
||||
|
||||
} // namespace luabind
|
||||
|
||||
#endif // LUABIND_SHARED_PTR_CONVERTER_090211_HPP
|
||||
|
||||
|
||||
Reference in New Issue
Block a user