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
d3e5dc98
Commit
d3e5dc98
authored
May 16, 2013
by
Vinicius Jarina
Browse files
Merge pull request #3 from charlenni/master
Added DoString for binary chunks as byte[]
parents
4a084972
712b6589
Changes
2
Hide whitespace changes
Inline
Side-by-side
Core/NLua/Lua.cs
View file @
d3e5dc98
...
@@ -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 @
d3e5dc98
...
@@ -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