mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Ensure proper semantics for default error handler
This commit is contained in:
parent
3e17b24065
commit
a69c599f99
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -39,3 +39,4 @@ lua-5.1.5/
|
|||
luajit-2.0.4/
|
||||
*.creator.user.*
|
||||
lua-5.3.1/
|
||||
main2.cpp
|
||||
|
|
|
@ -107,10 +107,19 @@ public:
|
|||
};
|
||||
|
||||
class function : public reference {
|
||||
private:
|
||||
static reference& handler_storage() {
|
||||
static sol::reference h;
|
||||
return h;
|
||||
}
|
||||
|
||||
public:
|
||||
static reference& default_handler() {
|
||||
static sol::reference h;
|
||||
return h;
|
||||
static const reference& get_default_handler () {
|
||||
return handler_storage();
|
||||
}
|
||||
|
||||
static void set_default_handler( reference& ref ) {
|
||||
handler_storage() = ref;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -199,7 +208,7 @@ public:
|
|||
sol::reference error_handler;
|
||||
|
||||
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);
|
||||
}
|
||||
function(const function&) = default;
|
||||
|
|
Loading…
Reference in New Issue
Block a user