mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Fix up protected function returns and fix/use the horrible size
extension point derp. Fixes #973
This commit is contained in:
parent
465b472b2c
commit
e09d2ffef8
|
@ -101,7 +101,7 @@ namespace sol {
|
|||
using ValueType = typename UT::value_type;
|
||||
if constexpr (std::is_same_v<ValueType, error>) {
|
||||
if (valid()) {
|
||||
return UT(nullopt);
|
||||
return UT();
|
||||
}
|
||||
return UT(error(detail::direct_error, stack::get<std::string>(L, target)));
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ namespace sol {
|
|||
if (!valid()) {
|
||||
return UT();
|
||||
}
|
||||
return UT(stack::get<ValueType>(L, target));
|
||||
return stack::get<UT>(L, target);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// This file was generated with a script.
|
||||
// Generated 2020-05-22 13:37:42.297619 UTC
|
||||
// This header was generated with sol v3.2.0 (revision d9c034d)
|
||||
// Generated 2020-05-27 00:07:01.142852 UTC
|
||||
// This header was generated with sol v3.2.0 (revision 465b472)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// This file was generated with a script.
|
||||
// Generated 2020-05-22 13:37:38.805887 UTC
|
||||
// This header was generated with sol v3.2.0 (revision d9c034d)
|
||||
// Generated 2020-05-27 00:07:00.664617 UTC
|
||||
// This header was generated with sol v3.2.0 (revision 465b472)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||
|
@ -15197,7 +15197,7 @@ namespace sol {
|
|||
using ValueType = typename UT::value_type;
|
||||
if constexpr (std::is_same_v<ValueType, error>) {
|
||||
if (valid()) {
|
||||
return UT(nullopt);
|
||||
return UT();
|
||||
}
|
||||
return UT(error(detail::direct_error, stack::get<std::string>(L, target)));
|
||||
}
|
||||
|
@ -15205,7 +15205,7 @@ namespace sol {
|
|||
if (!valid()) {
|
||||
return UT();
|
||||
}
|
||||
return UT(stack::get<ValueType>(L, target));
|
||||
return stack::get<UT>(L, target);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -143,6 +143,13 @@ namespace sol {
|
|||
|
||||
template <>
|
||||
struct usertype_container<my_vec> {
|
||||
// Hooks Lua's syntax for #c
|
||||
static int size(lua_State* L) {
|
||||
my_vec& v = sol::stack::get<my_vec&>(L, 1);
|
||||
return stack::push(L, v.size());
|
||||
}
|
||||
|
||||
// Used by default implementation
|
||||
static auto begin(lua_State*, my_vec& self) {
|
||||
return self.begin();
|
||||
}
|
||||
|
@ -150,11 +157,6 @@ namespace sol {
|
|||
return self.end();
|
||||
}
|
||||
|
||||
static std::size_t size(lua_State* L) {
|
||||
my_vec& v = sol::stack::get<my_vec&>(L, 1);
|
||||
return v.size();
|
||||
}
|
||||
|
||||
static std::ptrdiff_t index_adjustment(lua_State*, my_vec&) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -216,6 +218,8 @@ TEST_CASE("containers/custom indexing", "allow containers to set a custom indexi
|
|||
REQUIRE(result2.valid());
|
||||
auto result3 = lua.safe_script("assert(c[-1] == nil)", sol::script_pass_on_error);
|
||||
REQUIRE(result3.valid());
|
||||
auto result4 = lua.safe_script("assert(#c == 10)", sol::script_pass_on_error);
|
||||
REQUIRE(result4.valid());
|
||||
}
|
||||
|
||||
TEST_CASE("containers/containers of pointers", "containers of pointers shouldn't have their value_type's overly stripped") {
|
||||
|
|
Loading…
Reference in New Issue
Block a user