rendered paste body/* This class calls a LUA function. */class _luaFuncBinder : public CEGUI::SubscriberInterface<bool, const CEGUI::EventArgs &>{protected: // The Lua context for the function lua_State *Lua; // Function index in the Lua registry int Func; // EventArgs marshaller EventArgsMarshaller Marshaller;public: _luaFuncBinder (lua_State *iLua, int iFunc, EventArgsMarshaller iMarshaller) : Lua (iLua), Func (iFunc), Marshaller (iMarshaller) { } virtual ~_luaFuncBinder () { luaL_unref (Lua, LUA_REGISTRYINDEX, Func); } virtual bool operator() (const CEGUI::EventArgs &args) const { // Load the callback function to stack lua_rawgeti (Lua, LUA_REGISTRYINDEX, Func); return handle_call (args); } bool handle_call (const CEGUI::EventArgs &args) const { int nargs = Marshaller ? Marshaller (Lua, args) : 0; if (nargs < 0) return false; bool handled; // Call it if (lua_pcall (Lua, nargs, 1, 0)) { gLog->Out (LOG_IMPORTANT, "Lua error while calling event function:\n %s\n", lua_tostring (Lua, -1)); handled = false; } else handled = lua_toboolean (Lua, -1); // pop the return code from stack lua_pop (Lua, 1); return handled; }};...static int BindCEGUI_EventSet_SubscribeEvent (lua_State *tolua_S){ bool has4args = lua_gettop (tolua_S) > 3;#ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_isusertype (tolua_S, 1, "EventSet", 0, &tolua_err) || !tolua_isstring (tolua_S, 2, 0, &tolua_err) || !tolua_isfunction (tolua_S, 3, 0, &tolua_err) || (has4args && !tolua_istable (tolua_S, 4, 0, &tolua_err))) goto tolua_lerror; else#endif { EventSet *self = (EventSet *)tolua_tousertype (tolua_S, 1, 0);#ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SubscribeEvent'",NULL);#endif const char *name = ((const char *)tolua_tostring (tolua_S, 2, 0)); int table = LUA_REFNIL; if (has4args) table = luaL_ref (tolua_S, LUA_REGISTRYINDEX); int func = luaL_ref (tolua_S, LUA_REGISTRYINDEX); bool tolua_ret; if (has4args) tolua_ret = self->SubscribeEvent (name, tolua_S, func, table); else tolua_ret = self->SubscribeEvent (name, tolua_S, func); tolua_pushboolean (tolua_S,(bool)tolua_ret); } return 1;#ifndef TOLUA_RELEASEtolua_lerror: tolua_error(tolua_S,"#ferror in function 'SubscribeEvent'.",&tolua_err); return 0;#endif}