jeremyong / Selene

Simple C++11 friendly header-only bindings to Lua
zlib License
813 stars 117 forks source link

Return multiple values from C++ to Lua #149

Open shohnwal opened 8 years ago

shohnwal commented 8 years ago

While we all know it's possible that Lua functions can return multiple values to other Lua functions and Selene can return multiple values from Lua to C++ thanks to sel::Tie , is there any way with Selene to pass multiple values from C++ to Lua? The readme/manual doesn't say anything about that, it only mentions multi-value returns from Lua to C++. If that's not possible at the moment, could a feature be added that we can use sel::Tie not only to recieve multiple-value data from Lua, but to also send multiple values from C++ to Lua? For example: C++

sel::Tie<int,int,int> CoordinatePoint::getCoordinates() {
return sel::Tie(this->X, this->Y, this->Z);
}

and in Lua

a, b, c = cpp_getCoordinates()
-- calls previously registered returnCoordinates() C++ function
-- and sets a, b and c according to the sel::Tie returned from C++
satoren commented 8 years ago

std::tuple<int,int,int>