cLuaState is used for pushing splits in ManualBindings
This commit is contained in:
parent
2030bd47c8
commit
4034136922
@ -25,13 +25,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// fwd: LuaCommandBinder.cpp
|
|
||||||
// bool cLuaState::ReportErrors(lua_State* lua, int status);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/****************************
|
/****************************
|
||||||
* Better error reporting for Lua
|
* Better error reporting for Lua
|
||||||
**/
|
**/
|
||||||
@ -84,23 +77,14 @@ int lua_do_error(lua_State* L, const char * a_pFormat, ...)
|
|||||||
* Lua bound functions with special return types
|
* Lua bound functions with special return types
|
||||||
**/
|
**/
|
||||||
|
|
||||||
static int tolua_StringSplit(lua_State* tolua_S)
|
static int tolua_StringSplit(lua_State * tolua_S)
|
||||||
{
|
{
|
||||||
std::string str = ((std::string) tolua_tocppstring(tolua_S,1,0));
|
cLuaState LuaState(tolua_S);
|
||||||
std::string delim = ((std::string) tolua_tocppstring(tolua_S,2,0));
|
std::string str = (std::string)tolua_tocppstring(LuaState, 1, 0);
|
||||||
|
std::string delim = (std::string)tolua_tocppstring(LuaState, 2, 0);
|
||||||
|
|
||||||
AStringVector Split = StringSplit( str, delim );
|
AStringVector Split = StringSplit(str, delim);
|
||||||
|
LuaState.PushStringVector(Split);
|
||||||
lua_createtable(tolua_S, Split.size(), 0);
|
|
||||||
int newTable = lua_gettop(tolua_S);
|
|
||||||
int index = 1;
|
|
||||||
std::vector<std::string>::const_iterator iter = Split.begin();
|
|
||||||
while(iter != Split.end()) {
|
|
||||||
tolua_pushstring( tolua_S, (*iter).c_str() );
|
|
||||||
lua_rawseti(tolua_S, newTable, index);
|
|
||||||
++iter;
|
|
||||||
++index;
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +142,8 @@ cPlugin_NewLua * GetLuaPlugin(lua_State * L)
|
|||||||
lua_getglobal(L, LUA_PLUGIN_INSTANCE_VAR_NAME);
|
lua_getglobal(L, LUA_PLUGIN_INSTANCE_VAR_NAME);
|
||||||
if (!lua_islightuserdata(L, -1))
|
if (!lua_islightuserdata(L, -1))
|
||||||
{
|
{
|
||||||
LOGERROR("%s: cannot get plugin instance, what have you done to my Lua state?", __FUNCTION__);
|
LOGWARNING("%s: cannot get plugin instance, what have you done to my Lua state?", __FUNCTION__);
|
||||||
|
lua_pop(L);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cPlugin_NewLua * Plugin = (cPlugin_NewLua *)lua_topointer(L, -1);
|
cPlugin_NewLua * Plugin = (cPlugin_NewLua *)lua_topointer(L, -1);
|
||||||
|
Loading…
Reference in New Issue
Block a user