本文整理汇总了C#中ILuaState.ToLString方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.ToLString方法的具体用法?C# ILuaState.ToLString怎么用?C# ILuaState.ToLString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILuaState
的用法示例。
在下文中一共展示了ILuaState.ToLString方法的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: incomplete
/*
** Check whether 'status' signals a syntax error and the error
** message at the top of the stack ends with the above mark for
** incomplete statements.
*/
static int incomplete(ILuaState L, LuaStatus status)
{
if (status == LuaStatus.ErrSyntax)
{
int lmsg;
String msg = L.ToLString(-1, out lmsg);
//if (lmsg >= marklen && String.Compare(msg + lmsg - marklen, EOFMARK) == 0)
if (lmsg >= marklen && msg.EndsWith(EOFMARK))
{
L.Pop(1);
return 1;
}
}
return 0; /* else... */
}