Ensure proper semantics for default error handler

This commit is contained in:
ThePhD 2015-11-02 08:10:29 -05:00
parent 3e17b24065
commit a69c599f99
2 changed files with 14 additions and 4 deletions

1
.gitignore vendored
View File

@ -39,3 +39,4 @@ lua-5.1.5/
luajit-2.0.4/ luajit-2.0.4/
*.creator.user.* *.creator.user.*
lua-5.3.1/ lua-5.3.1/
main2.cpp

View File

@ -107,10 +107,19 @@ public:
}; };
class function : public reference { class function : public reference {
private:
static reference& handler_storage() {
static sol::reference h;
return h;
}
public: public:
static reference& default_handler() { static const reference& get_default_handler () {
static sol::reference h; return handler_storage();
return h; }
static void set_default_handler( reference& ref ) {
handler_storage() = ref;
} }
private: private:
@ -199,7 +208,7 @@ public:
sol::reference error_handler; sol::reference error_handler;
function() = default; function() = default;
function(lua_State* L, int index = -1): reference(L, index), error_handler(default_handler()) { function(lua_State* L, int index = -1): reference(L, index), error_handler(get_default_handler()) {
type_assert(L, index, type::function); type_assert(L, index, type::function);
} }
function(const function&) = default; function(const function&) = default;