From bcabb130408b5d52bb73f8404d3b4805047d86ff Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 13 Jan 2009 10:07:58 +0000 Subject: Changes for new multilist type... to be removed again in a minute. --- server/src/luaformatmapper.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'server/src/luaformatmapper.cc') diff --git a/server/src/luaformatmapper.cc b/server/src/luaformatmapper.cc index 6c0115d..652a34d 100644 --- a/server/src/luaformatmapper.cc +++ b/server/src/luaformatmapper.cc @@ -31,20 +31,22 @@ #include "exception.h" #include "luaformatmapperutils.h" - +/* static std::string loadresultstring(Fields &fields) { std::string s; Fields::iterator v = fields.begin(); while(v != fields.end()) { - s += (*v).first + " = \"" + (*v).second + "\"\n"; + lua_pushstring(L, v->second); // Push the pointer to 'this' instance + lua_setglobal(L, v->first); // Assign it to a global lua var. + // s += (*v).first + " = \"" + (*v).second + "\"\n"; v++; } return s; } - +*/ LUAFormatMapper::LUAFormatMapper(Fields &fields) { L = luaL_newstate(); @@ -58,6 +60,13 @@ LUAFormatMapper::LUAFormatMapper(Fields &fields) setGlobal(L, "LUAFormatMapper", this); preload_formatutils(L); + Fields::iterator v = fields.begin(); + while(v != fields.end()) { + lua_pushstring(L, v->second.c_str()); // Push the pointer to 'this' instance + lua_setglobal(L, v->first.c_str()); // Assign it to a global lua var. + v++; + } + /* std::string preload = loadresultstring(fields); if(luaL_loadbuffer(L, preload.c_str(), preload.size(), "preload")) { @@ -70,7 +79,7 @@ LUAFormatMapper::LUAFormatMapper(Fields &fields) error(lua_tostring(L, lua_gettop(L))); return; } - + */ clean_top = lua_gettop(L); } -- cgit v1.2.3