mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
thread and state awareness in all sol lua types
This commit is contained in:
parent
01aeaf6492
commit
3baa99f941
@ -50,7 +50,10 @@ namespace sol {
|
||||
}
|
||||
|
||||
int push(lua_State* Ls) const noexcept {
|
||||
lua_pushvalue(Ls, index);
|
||||
lua_pushvalue(lua_state(), index);
|
||||
if (Ls != lua_state()) {
|
||||
lua_xmove(lua_state(), Ls, 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -192,11 +192,18 @@ namespace sol {
|
||||
const_reverse_iterator crend() const { return std::reverse_iterator<const_iterator>(cend()); }
|
||||
|
||||
int push() const {
|
||||
push(L);
|
||||
}
|
||||
|
||||
int push(lua_State* target) const {
|
||||
int pushcount = 0;
|
||||
for (int i = index; i <= stacktop; ++i) {
|
||||
lua_pushvalue(L, i);
|
||||
pushcount += 1;
|
||||
}
|
||||
if (target != L) {
|
||||
lua_xmove(L, target, pushcount);
|
||||
}
|
||||
return pushcount;
|
||||
}
|
||||
|
||||
@ -226,8 +233,8 @@ namespace sol {
|
||||
|
||||
template <>
|
||||
struct pusher<variadic_args> {
|
||||
static int push(lua_State*, const variadic_args& ref) {
|
||||
return ref.push();
|
||||
static int push(lua_State* L, const variadic_args& ref) {
|
||||
return ref.push(L);
|
||||
}
|
||||
};
|
||||
} // stack
|
||||
|
Loading…
x
Reference in New Issue
Block a user