diff options
author | deva <deva> | 2008-11-03 15:22:10 +0000 |
---|---|---|
committer | deva <deva> | 2008-11-03 15:22:10 +0000 |
commit | 40bad69cd77f32730f6939553d7f9667338c646f (patch) | |
tree | 7a5b83aac4aef71a718f9aaa806feaedf8d25a4b /server/src/luaformatmapper.cc | |
parent | 5968c3af2c26abe61cf98bf45f672835ef4b51ba (diff) |
Did a lot of work on format utils.
Diffstat (limited to 'server/src/luaformatmapper.cc')
-rw-r--r-- | server/src/luaformatmapper.cc | 16 |
1 files changed, 13 insertions, 3 deletions
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; +} |