Commit 712b6589 authored by charlenni's avatar charlenni
Browse files

Added DoString for binary chunks as byte[].


Signed-off-by: default avatarcharlenni <web@weltz-online.de>
parent 0d13cd45
...@@ -402,6 +402,29 @@ end ...@@ -402,6 +402,29 @@ end
return result; return result;
} }
/// <summary>
///
/// </summary>
/// <param name = "chunk"></param>
/// <param name = "name"></param>
/// <returns></returns>
public LuaFunction LoadString (byte[] chunk, string name)
{
int oldTop = LuaLib.lua_gettop (luaState);
executing = true;
try {
if (LuaLib.luaL_loadbuffer (luaState, chunk, name) != 0)
ThrowExceptionFromError (oldTop);
} finally {
executing = false;
}
var result = translator.getFunction (luaState, -1);
translator.popValues (luaState, oldTop);
return result;
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
......
...@@ -83,6 +83,11 @@ namespace NLua ...@@ -83,6 +83,11 @@ namespace NLua
return LuaCore.luaL_loadstring (luaState, chunk); return LuaCore.luaL_loadstring (luaState, chunk);
} }
public static int luaL_loadstring (LuaCore.lua_State luaState, byte[] chunk)
{
return LuaCore.luaL_loadstring (luaState, chunk);
}
public static int luaL_dostring (LuaCore.lua_State luaState, string chunk) public static int luaL_dostring (LuaCore.lua_State luaState, string chunk)
{ {
int result = luaL_loadstring (luaState, chunk); int result = luaL_loadstring (luaState, chunk);
...@@ -92,6 +97,15 @@ namespace NLua ...@@ -92,6 +97,15 @@ namespace NLua
return lua_pcall (luaState, 0, -1, 0); return lua_pcall (luaState, 0, -1, 0);
} }
public static int luaL_dostring (LuaCore.lua_State luaState, byte[] chunk)
{
int result = luaL_loadstring (luaState, chunk);
if (result != 0)
return result;
return lua_pcall (luaState, 0, -1, 0);
}
/// <summary>DEPRECATED - use luaL_dostring(LuaCore.lua_State luaState, string chunk) instead!</summary> /// <summary>DEPRECATED - use luaL_dostring(LuaCore.lua_State luaState, string chunk) instead!</summary>
public static int lua_dostring (LuaCore.lua_State luaState, string chunk) public static int lua_dostring (LuaCore.lua_State luaState, string chunk)
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment