MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / pushLuaValue

Method pushLuaValue

source/core/StarLua.cpp:1189–1220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1187}
1188
1189void LuaEngine::pushLuaValue(lua_State* state, LuaValue const& luaValue) {
1190 lua_checkstack(state, 1);
1191
1192 struct Pusher {
1193 LuaEngine* engine;
1194 lua_State* state;
1195
1196 void operator()(LuaNilType const&) {
1197 lua_pushnil(state);
1198 }
1199
1200 void operator()(LuaBoolean const& b) {
1201 lua_pushboolean(state, b);
1202 }
1203
1204 void operator()(LuaInt const& i) {
1205 lua_pushinteger(state, i);
1206 }
1207
1208 void operator()(LuaFloat const& f) {
1209 lua_pushnumber(state, f);
1210 }
1211
1212 void operator()(LuaReference const& ref) {
1213 if (&ref.engine() != engine)
1214 throw LuaException("lua reference values cannot be shared between engines");
1215 engine->pushHandle(state, ref.handleIndex());
1216 }
1217 };
1218
1219 luaValue.call(Pusher{this, state});
1220}
1221
1222LuaValue LuaEngine::popLuaValue(lua_State* state) {
1223 lua_checkstack(state, 1);

Callers 1

createWrappedFunctionMethod · 0.95

Calls 2

lua_checkstackFunction · 0.85
callMethod · 0.80

Tested by

no test coverage detected