diff options
Diffstat (limited to 'server/src/luaformatmapper.cc')
-rw-r--r-- | server/src/luaformatmapper.cc | 17 |
1 files changed, 13 insertions, 4 deletions
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); } |