View difference between Paste ID: EGuVF4dE and V5cC7Q6W
SHOW: | | - or go back to the newest paste.
1
class LuaSlot {
2
public:
3-
	static inline sigc::slot<void> Wrap(lua_State *l) {
3+
	static inline sigc::slot<void> Wrap(lua_State *l, int idx) {
4
		idx = lua_absindex(l, idx);
5
		lua_getfield(l, LUA_REGISTRYINDEX, "PiUISlot");
6
		if (lua_isnil(l, -1)) {
7
			lua_pop(l, 1);
8
			lua_newtable(l);
9
			lua_pushvalue(l, -1);
10-
		lua_pushvalue(l, -2);
10+
11
		}
12
		lua_pushvalue(l, idx);
13
		int ref = luaL_ref(l, -2);
14
		lua_pop(l, 1);
15
		return sigc::bind(sigc::ptr_fun(&trampoline), l, ref);
16
	}
17
18
private:
19
	static inline void trampoline(lua_State *l, int ref) {
20
		lua_getfield(l, LUA_REGISTRYINDEX, "PiUISlot");
21-
		lua_remove(l, -2);
21+
22-
		lua_call(l, -1, 0);
22+
23
		lua_call(l, 0, 0);
24
		lua_pop(l, 1);
25
	}
26
};