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/
|
luajit-2.0.4/
|
||||||
*.creator.user.*
|
*.creator.user.*
|
||||||
lua-5.3.1/
|
lua-5.3.1/
|
||||||
|
main2.cpp
|
||||||
|
|
|
@ -107,12 +107,21 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
class function : public reference {
|
class function : public reference {
|
||||||
public:
|
private:
|
||||||
static reference& default_handler() {
|
static reference& handler_storage() {
|
||||||
static sol::reference h;
|
static sol::reference h;
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
static const reference& get_default_handler () {
|
||||||
|
return handler_storage();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_default_handler( reference& ref ) {
|
||||||
|
handler_storage() = ref;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct handler {
|
struct handler {
|
||||||
const reference& target;
|
const reference& target;
|
||||||
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user