Rapptz / sol

A C++11 Lua wrapper
MIT License
208 stars 32 forks source link

to_lua/from_lua (with love) #64

Closed ThePhD closed 5 years ago

ThePhD commented 9 years ago

This pull requests vastly simplifies the "plug in" architecture by allowing a user to define three functions to hook into the existing lua system:

int to_lua( lua_State* L, T&& item ) SomeReturn from_lua( types<T>, lua_State* L, int index ) bool check_lua( types<T>, lua_State* L, int index )

It's mostly an experimental feature, and I do not like the interface for from_lua and check_lua, since we have to take an overload-resolving argument types<T> in order to properly SFINAE if such a function exists (and prevent ambiguous overloads if you want to write such a function for multiple types).

to_lua, however, is done quite nicely and works out pretty well (tests also pass for the branch).

ThePhD commented 9 years ago

EDIT: The text that used to be here was a dumb idea that I didn't fully think through. Being tired sucks.

Rapptz commented 9 years ago

This drops down to the stack level no?

ThePhD commented 9 years ago

This is used if and only if sol::stack doesn't already have a define and there is a viable to_lua/from_lua/check_lua implementation.