fix review comments
This commit is contained in:
parent
7daf9d0df4
commit
91a87084ff
@ -68,8 +68,8 @@ public:
|
|||||||
ASSERT(loader.valid());
|
ASSERT(loader.valid());
|
||||||
|
|
||||||
sol::function result = loader(function_);
|
sol::function result = loader(function_);
|
||||||
ASSERT(result.valid()) << "Unable to restore function!" << std::endl
|
ASSERT(result.valid()) << "Unable to restore function!\n"
|
||||||
<< "Content:" << std::endl << function_ << std::endl;
|
<< "Content:\n" << function_;
|
||||||
return sol::make_object(state, result);
|
return sol::make_object(state, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ std::unique_ptr<BaseHolder> fromSolObject(const SolObject& luaObject) {
|
|||||||
return std::make_unique<PrimitiveHolder<SharedTable*>>(sol::type::userdata, table);
|
return std::make_unique<PrimitiveHolder<SharedTable*>>(sol::type::userdata, table);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
ERROR << "Unable to store object of that type: " << (int)luaObject.get_type() << std::endl;
|
ERROR << "Unable to store object of that type: " << (int)luaObject.get_type() << "\n";
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@ void LuaThread::detach() noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LuaThread::work() noexcept {
|
void LuaThread::work() noexcept {
|
||||||
ASSERT(p_state_.get() && p_arguments_.get()) << "invalid thread Lua state" << std::endl;
|
ASSERT(p_state_.get() && p_arguments_.get()) << "invalid thread Lua state\n";
|
||||||
|
|
||||||
std::string func_owner = std::move(str_function_);
|
std::string func_owner = std::move(str_function_);
|
||||||
std::shared_ptr<sol::state> state_owner = p_state_;
|
std::shared_ptr<sol::state> state_owner = p_state_;
|
||||||
|
|||||||
28
src/utils.h
28
src/utils.h
@ -5,25 +5,31 @@
|
|||||||
|
|
||||||
#include <sol.hpp>
|
#include <sol.hpp>
|
||||||
|
|
||||||
|
namespace effil {
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
class ExceptionThrower
|
class Exception : public sol::error {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
void operator =(const std::ostream& os)
|
Exception() noexcept : sol::error("") {}
|
||||||
{
|
|
||||||
throw sol::error(static_cast<const std::stringstream&>(os).str());
|
template<typename T>
|
||||||
|
Exception& operator<<(const T& value) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << value;
|
||||||
|
message_ += ss.str();
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator bool()
|
virtual const char* what() const noexcept override {
|
||||||
{
|
return message_.c_str();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string message_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // utils
|
||||||
|
} // effil
|
||||||
|
|
||||||
#define ERROR if (auto thr = utils::ExceptionThrower()) thr = std::stringstream() << __FILE__ << ":" << __LINE__ << std::endl
|
#define ERROR throw effil::utils::Exception() << __FILE__ << ":" << __LINE__
|
||||||
#define ASSERT(cond) if (!(cond)) ERROR << "In condition '" << #cond << "': "
|
#define ASSERT(cond) if (!(cond)) ERROR << "In condition '" << #cond << "': "
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user