From 40bad69cd77f32730f6939553d7f9667338c646f Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 3 Nov 2008 15:22:10 +0000 Subject: Did a lot of work on format utils. --- server/src/luaformatmapper.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'server/src/luaformatmapper.cc') diff --git a/server/src/luaformatmapper.cc b/server/src/luaformatmapper.cc index b45c170..6c0115d 100644 --- a/server/src/luaformatmapper.cc +++ b/server/src/luaformatmapper.cc @@ -30,6 +30,8 @@ #include "exception.h" +#include "luaformatmapperutils.h" + static std::string loadresultstring(Fields &fields) { std::string s; @@ -53,6 +55,9 @@ LUAFormatMapper::LUAFormatMapper(Fields &fields) luaL_openlibs(L); + setGlobal(L, "LUAFormatMapper", this); + preload_formatutils(L); + std::string preload = loadresultstring(fields); if(luaL_loadbuffer(L, preload.c_str(), preload.size(), "preload")) { @@ -101,14 +106,14 @@ std::string LUAFormatMapper::map(const std::string &mapper) } // Check if app messed up the stack. - if(lua_gettop(L) != clean_top + 1) { + if(lua_gettop(L) != clean_top) { error("Wrong number of return values in " + mapper); lua_pop(L, lua_gettop(L) - clean_top); return output; } - output = lua_tostring(L, lua_gettop(L)); - lua_pop(L, 1); + // output = lua_tostring(L, lua_gettop(L)); + // lua_pop(L, 1); return output; } @@ -117,3 +122,8 @@ void LUAFormatMapper::error(std::string message) { throw Exception("ERROR in LUAFormatMapper: " + message); } + +void LUAFormatMapper::bufferoutput(std::string value) +{ + output += value; +} -- cgit v1.2.3