🛠 Prevent non-zero default initialization for result types

This commit is contained in:
Shepherd 2022-06-24 07:43:54 -04:00 committed by The Phantom Derpstorm
parent 0a801ee656
commit 323c3ca210
3 changed files with 9 additions and 5 deletions

View File

@ -39,7 +39,7 @@ namespace sol {
load_status err;
public:
load_result() noexcept = default;
load_result() noexcept : load_result(nullptr) {}
load_result(lua_State* Ls, int stackindex = -1, int retnum = 0, int popnum = 0, load_status lerr = load_status::ok) noexcept
: L(Ls), index(stackindex), returncount(retnum), popcount(popnum), err(lerr) {
}
@ -142,8 +142,10 @@ namespace sol {
};
~load_result() {
if (L != nullptr) {
stack::remove(L, index, popcount);
}
}
};
} // namespace sol

View File

@ -54,7 +54,7 @@ namespace sol {
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
protected_function_result() noexcept = default;
protected_function_result() noexcept : protected_function_result(nullptr) {}
protected_function_result(lua_State* Ls, int idx = -1, int retnum = 0, int popped = 0, call_status pferr = call_status::ok) noexcept
: L(Ls), index(idx), returncount(retnum), popcount(popped), err(pferr) {
}

View File

@ -50,7 +50,7 @@ namespace sol {
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
unsafe_function_result() noexcept = default;
unsafe_function_result() noexcept : unsafe_function_result(nullptr) {}
unsafe_function_result(lua_State* Ls, int idx = -1, int retnum = 0) noexcept : L(Ls), index(idx), returncount(retnum) {
}
@ -158,8 +158,10 @@ namespace sol {
returncount = 0;
}
~unsafe_function_result() {
if (L != nullptr) {
lua_pop(L, returncount);
}
}
};
namespace stack {