Missing upvalue in make_range

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Missing upvalue in make_range

James Lloyd
Hello list,

I've recently upgraded to 0.8 (I know that 0.9 is now available) and have found a bug in the implementation of make_range in iterator_policy.hpp, line 52.  The iterator::destroy function wants an upvalue that is never pushed:

template <class Iterator>
int make_range(lua_State* L, Iterator first, Iterator last)
{
    void* storage = lua_newuserdata(L, sizeof(iterator<Iterator>));
    lua_newtable(L);
    // should lua_pushvalue(L, -2);
    lua_pushcclosure(L, iterator<Iterator>::destroy, 0); // should be 1
    lua_setfield(L, -2, "__gc");
    lua_setmetatable(L, -2);
    lua_pushcclosure(L, iterator<Iterator>::next, 1);
    new (storage) iterator<Iterator>(first, last);
    return 1;
}

This is still in the 0.9 download.

Cheers,
James
--

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Missing upvalue in make_range

Daniel Wallin
James Lloyd wrote:
> Hello list,
>
> I've recently upgraded to 0.8 (I know that 0.9 is now available) and
> have found a bug in the implementation of make_range in
> iterator_policy.hpp, line 52.  The iterator::destroy function wants an
> upvalue that is never pushed:
>
[...]
>
> This is still in the 0.9 download.

This was fixed before the 0.9 release:

http://github.com/luabind/luabind/commit/17a85a7657d94b256748cef45911c227a2c20afe

The patch can probably be applied cleanly to 0.8.1 as well.

--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user