Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing unit test: "out_value" vs. "pure_out_value" #30

Open
Bertram25 opened this issue Aug 27, 2015 · 4 comments
Open

Failing unit test: "out_value" vs. "pure_out_value" #30

Bertram25 opened this issue Aug 27, 2015 · 4 comments

Comments

@Bertram25
Copy link

As reported here: #29 (comment)

@fhoefling
there is at least one failing test concerning "out_value" vs. "pure_out_value", see commit
a1199b5

@Oberon00
Copy link
Owner

[OT: I was baffled at first because your link to the commit (automatically created by github) points to https://github.com/Oberon00/luabind/commit/a1199b51bc1b6af5cf7e6a5cfba021c4cacb1a78 and I thought "Where is this commit gone?" but it seems that git locates the commits by ID for any fork, no matter which fork you use in the URL, e.g. try https://github.com/luabind/luabind/commit/4274bb6f347d23f3bc8f2dee106b0d01f97.... ]

@Oberon00
Copy link
Owner

Seems complicated to fix as some converters are stateful and rely on e.g. match being called before apply (see for example https://github.com/Oberon00/luabind/blob/master/luabind/detail/policy.hpp#L217). However, to instantiate the appropriate converter, the out value converter would need to know which ‒ but it learns that only once match is called at runtime! Honestly, I think this design is broken. But a workaround to fix this withouth greater modifications, would be to introduce a type erased wrapper for the converter (exchanging the Ts per void*) and instantiating that in match.

@mrgreywater
Copy link

see rpavlik@42b8219

Honestly, I would love to see your two forks merged, Isn't it kindof counter productive to manually cherry pick commits from each others fork?

@Oberon00
Copy link
Owner

Have you read my above comment about stateful converters? The current test is insufficient to catch this error. Try using a class-type as out-value parameter and I bet you get an access violation.

And regarding mine and @rpavlik's fork being merged: I think neither of us is against that idea, but it would be a lot of work and at least I do not want to spend too much time on luabind anymore.

Oberon00 added a commit that referenced this issue Feb 29, 2016
Leads to a compiler error with g++:

In file included from luabind/test/test_out_value.cpp:4:0:
luabind/luabind/out_value_policy.hpp: In instantiation of ‘static int luabind::detail::out_value_converter<Size, Policies>::match(lua_State*, luabind::detail::by_reference<T>, int) [with T = float; int Size = 4; Policies = luabind::detail::null_type; lua_State = lua_State]’:
luabind/luabind/detail/call.hpp:262:9:   required from ‘int luabind::detail::invoke_normal(lua_State*, const luabind::detail::function_object&, luabind::detail::invoke_context&, const F&, Signature, const Policies&, mpl_::long_<1l>, mpl_::true_) [with F = void (*)(float&); Signature = boost::function_types::components<void (*)(float&), boost::add_reference<mpl_::arg<-1> > >; Policies = luabind::detail::policy_cons<luabind::detail::out_value_policy<1, luabind::detail::null_type>, luabind::detail::null_type>; lua_State = lua_State; mpl_::true_ = mpl_::bool_<true>]’
luabind/luabind/detail/call.hpp:94:5:   required from ‘int luabind::detail::invoke0(lua_State*, const luabind::detail::function_object&, luabind::detail::invoke_context&, const F&, Signature, const Policies&, IsVoid, mpl_::false_) [with F = void (*)(float&); Signature = boost::function_types::components<void (*)(float&), boost::add_reference<mpl_::arg<-1> > >; Policies = luabind::detail::policy_cons<luabind::detail::out_value_policy<1, luabind::detail::null_type>, luabind::detail::null_type>; IsVoid = boost::is_void<void>; lua_State = lua_State; mpl_::false_ = mpl_::bool_<false>]’
luabind/luabind/detail/call.hpp:106:4:   required from ‘int luabind::detail::invoke(lua_State*, const luabind::detail::function_object&, luabind::detail::invoke_context&, const F&, Signature, const Policies&) [with F = void (*)(float&); Signature = boost::function_types::components<void (*)(float&), boost::add_reference<mpl_::arg<-1> > >; Policies = luabind::detail::policy_cons<luabind::detail::out_value_policy<1, luabind::detail::null_type>, luabind::detail::null_type>; lua_State = lua_State]’
luabind/luabind/make_function.hpp:63:70:   required from ‘static int luabind::detail::function_object_impl<F, Signature, Policies>::entry_point(lua_State*) [with F = void (*)(float&); Signature = boost::function_types::components<void (*)(float&), boost::add_reference<mpl_::arg<-1> > >; Policies = luabind::detail::policy_cons<luabind::detail::out_value_policy<1, luabind::detail::null_type>, luabind::detail::null_type>; lua_State = lua_State]’
luabind/luabind/make_function.hpp:32:27:   required from ‘luabind::detail::function_object_impl<F, Signature, Policies>::function_object_impl(F, const Policies&) [with F = void (*)(float&); Signature = boost::function_types::components<void (*)(float&), boost::add_reference<mpl_::arg<-1> > >; Policies = luabind::detail::policy_cons<luabind::detail::out_value_policy<1, luabind::detail::null_type>, luabind::detail::null_type>]’
luabind/luabind/make_function.hpp:107:5:   required from ‘luabind::adl::object luabind::make_function(lua_State*, F, Signature, Policies) [with F = void (*)(float&); Signature = boost::function_types::components<void (*)(float&), boost::add_reference<mpl_::arg<-1> > >; Policies = luabind::detail::policy_cons<luabind::detail::out_value_policy<1, luabind::detail::null_type>, luabind::detail::null_type>; lua_State = lua_State]’
luabind/luabind/function.hpp:28:72:   required from ‘void luabind::detail::function_registration<F, Policies>::register_(lua_State*) const [with F = void (*)(float&); Policies = luabind::detail::policy_cons<luabind::detail::out_value_policy<1, luabind::detail::null_type>, luabind::detail::null_type>; lua_State = lua_State]’
luabind/test/test_out_value.cpp:22:1:   required from here
luabind/luabind/out_value_policy.hpp:126:71: error: cannot call member function ‘int luabind::native_converter_base<T, Derived>::match(lua_State*, luabind::detail::by_value<T>, int) [with T = float; Derived = luabind::default_converter<float, void>; lua_State = lua_State]’ without object
             return converter::match(L, LUABIND_DECORATE_TYPE(T), index);
                                                                       ^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants