#pragma once /* These are helper functions to fill up the Element.As table with types that are able to be casted */ #include #include #include namespace Rml { namespace Lua { // Helper function for the controls, so that the types don't have to define individual functions themselves // to fill the Elements.As table template int CastFromElementTo(lua_State* L) { Element* ele = LuaType::check(L, 1); RMLUI_CHECK_OBJ(ele); LuaType::push(L, (ToType*)ele, false); return 1; } // Adds to the Element.As table the name of the type, and the function to use to cast template void AddCastFunctionToElementAsTable(lua_State* L) { int top = lua_gettop(L); lua_getglobal(L, "Element"); lua_getfield(L, -1, "As"); if (!lua_isnoneornil(L, -1)) { lua_pushcfunction(L, CastFromElementTo); lua_setfield(L, -2, GetTClassName()); } lua_settop(L, top); // pop "As" and "Element" } } // namespace Lua } // namespace Rml