Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
NLua
Commits
712b6589
Commit
712b6589
authored
May 16, 2013
by
charlenni
Browse files
Added DoString for binary chunks as byte[].
Signed-off-by:
charlenni
<
web@weltz-online.de
>
parent
0d13cd45
Changes
2
Hide whitespace changes
Inline
Side-by-side
Core/NLua/Lua.cs
View file @
712b6589
...
@@ -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>
...
...
Core/NLua/LuaLib/LuaLib.cs
View file @
712b6589
...
@@ -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
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment