diff options
Diffstat (limited to 'Sluift/sluift.cpp')
| -rw-r--r-- | Sluift/sluift.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Sluift/sluift.cpp b/Sluift/sluift.cpp index 3908631..a04ceeb 100644 --- a/Sluift/sluift.cpp +++ b/Sluift/sluift.cpp @@ -116,71 +116,71 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( while (!watchdog.getTimedOut()) { Swift::sleep(boost::numeric_cast<unsigned int>(std::min(100, timeout))); Sluift::globals.eventLoop.runOnce(); } return 0; } SLUIFT_LUA_FUNCTION_WITH_HELP( Sluift, new_uuid, "Generates a new UUID", "", "" ) { lua_pushstring(L, IDGenerator().generateID().c_str()); return 1; } SLUIFT_LUA_FUNCTION_WITH_HELP( Sluift, from_xml, "Convert a raw XML string into a structured representation.", "string the string to convert", "" ) { PayloadsParserTester parser; if (!parser.parse(Lua::checkString(L, 1))) { throw Lua::Exception("Error in XML"); } return Sluift::globals.elementConvertor.convertToLua(L, parser.getPayload()); } SLUIFT_LUA_FUNCTION_WITH_HELP( Sluift, to_xml, "Convert a structured element into XML.", "element the element to convert", "" ) { static FullPayloadSerializerCollection serializers; - boost::shared_ptr<Payload> payload = Sluift::globals.elementConvertor.convertFromLua(L, 1); + boost::shared_ptr<Payload> payload = boost::dynamic_pointer_cast<Payload>(Sluift::globals.elementConvertor.convertFromLua(L, 1)); if (!payload) { throw Lua::Exception("Unrecognized XML"); } PayloadSerializer* serializer = serializers.getPayloadSerializer(payload); if (!payload) { throw Lua::Exception("Unrecognized XML"); } lua_pushstring(L, serializer->serialize(payload).c_str()); return 1; } SLUIFT_LUA_FUNCTION_WITH_HELP( Sluift, hexify, "Convert binary data into hexadecimal format.", "data the data to convert", "" ) { if (!lua_isstring(L, 1)) { throw Lua::Exception("Expected string"); } size_t len; const char* data = lua_tolstring(L, 1, &len); lua_pushstring(L, Hexify::hexify(createByteArray(data, len)).c_str()); return 1; } SLUIFT_LUA_FUNCTION_WITH_HELP( Sluift, unhexify, "Convert hexadecimal data into binary data.", "data the data in hexadecimal format", "" ) { if (!lua_isstring(L, 1)) { throw Lua::Exception("Expected string"); } |
Swift