/* * Copyright (c) 2013 Remko Tronçon * Licensed under the GNU General Public License. * See the COPYING file for more information. */ #include #include #include #include using namespace Swift; BodyConvertor::BodyConvertor() : GenericLuaElementConvertor("body") { } BodyConvertor::~BodyConvertor() { } boost::shared_ptr BodyConvertor::doConvertFromLua(lua_State* L) { boost::shared_ptr result = boost::make_shared(); if (boost::optional value = Lua::getStringField(L, -1, "text")) { result->setText(*value); } return result; } void BodyConvertor::doConvertToLua(lua_State* L, boost::shared_ptr payload) { lua_createtable(L, 0, 0); if (!payload->getText().empty()) { lua_pushstring(L, payload->getText().c_str()); lua_setfield(L, -2, "text"); } }