本文整理汇总了C#中ILuaState.LoadBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.LoadBuffer方法的具体用法?C# ILuaState.LoadBuffer怎么用?C# ILuaState.LoadBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILuaState
的用法示例。
在下文中一共展示了ILuaState.LoadBuffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addreturn
/*
** Try to compile line on the stack as 'return <line>'; on return, stack
** has either compiled chunk or original line (if compilation failed).
*/
static LuaStatus addreturn(ILuaState L)
{
LuaStatus status;
int len; string line;
L.PushLiteral("return ");
L.PushValue(-2); /* duplicate line */
L.Concat(2); /* new line is "return ..." */
line = L.ToLString(-1, out len);
if ((status = L.LoadBuffer(line, len, "=stdin")) == LuaStatus.OK)
{
L.Remove(-3); /* remove original line */
//line += sizeof("return")/sizeof(char); /* remove 'return' for history */
line = line.Substring("return".Length);
if (!String.IsNullOrEmpty(line)) /* non empty? */
lua_saveline(L, line); /* keep history */
}
else
L.Pop(2); /* remove result from 'luaL_loadbuffer' and new line */
return status;
}
示例2: multiline
/*
** Read multiple lines until a complete Lua statement
*/
static LuaStatus multiline(ILuaState L)
{
for (; ; )
{ /* repeat until gets a complete statement */
int len;
String line = L.ToLString(1, out len); /* get what it has */
LuaStatus status = L.LoadBuffer(line, len, "=stdin"); /* try it */
if (0 == incomplete(L, status) || 0 == pushline(L, false))
{
lua_saveline(L, line); /* keep history */
return status; /* cannot or should not try to add continuation line */
}
L.PushLiteral("\n"); /* add newline... */
L.Insert(-2); /* ...between the two lines */
L.Concat(3); /* join them */
}
}
示例3: dostring
static LuaStatus dostring(ILuaState L, String s, String name)
{
return dochunk(L, L.LoadBuffer(s, name));
}