本文整理汇总了C#中luaL_Buffer类的典型用法代码示例。如果您正苦于以下问题:C# luaL_Buffer类的具体用法?C# luaL_Buffer怎么用?C# luaL_Buffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
luaL_Buffer类属于命名空间,在下文中一共展示了luaL_Buffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: addfield
private static void addfield(lua_State L, luaL_Buffer b, int i)
{
lua_rawgeti(L, 1, i);
if (lua_isstring(L, -1)==0)
luaL_error(L, "invalid value (%s) at index %d in table for " +
LUA_QL("concat"), luaL_typename(L, -1), i);
luaL_addvalue(b);
}
开发者ID:lenzener,项目名称:LuaInterface,代码行数:8,代码来源:ltablib.cs
示例2: str_reverse
private static int str_reverse (lua_State L) {
uint l;
luaL_Buffer b = new luaL_Buffer();
CharPtr s = luaL_checklstring(L, 1, out l);
luaL_buffinit(L, b);
while ((l--) != 0) luaL_addchar(b, s[l]);
luaL_pushresult(b);
return 1;
}
开发者ID:mlnlover11,项目名称:KopiLua-v5.1.5,代码行数:9,代码来源:lstrlib.cs
示例3: str_upper
private static int str_upper (lua_State L) {
uint l;
uint i;
luaL_Buffer b = new luaL_Buffer();
CharPtr s = luaL_checklstring(L, 1, out l);
luaL_buffinit(L, b);
for (i=0; i<l; i++)
luaL_addchar(b, toupper(s[i]));
luaL_pushresult(b);
return 1;
}
开发者ID:mlnlover11,项目名称:KopiLua-v5.1.5,代码行数:11,代码来源:lstrlib.cs
示例4: luaL_buffinit
public static extern void luaL_buffinit(lua_State L, ref luaL_Buffer B);
开发者ID:vhotur,项目名称:tao,代码行数:1,代码来源:Lua.cs
示例5: read_line
private static int read_line (lua_State L, Stream f) {
luaL_Buffer b = new luaL_Buffer();
luaL_buffinit(L, b);
for (;;) {
uint l;
CharPtr p = luaL_prepbuffer(b);
if (fgets(p, f) == null) { /* eof? */
luaL_pushresult(b); /* close buffer */
return (lua_objlen(L, -1) > 0) ? 1 : 0; /* check whether read something */
}
l = (uint)strlen(p);
if (l == 0 || p[l-1] != '\n')
luaL_addsize(b, (int)l);
else {
luaL_addsize(b, (int)(l - 1)); /* do not include `eol' */
luaL_pushresult(b); /* close buffer */
return 1; /* read at least an `eol' */
}
}
}
开发者ID:mlnlover11,项目名称:KopiLua-v5.1.5,代码行数:20,代码来源:liolib.cs
示例6: luaL_addvalue
public static void luaL_addvalue(luaL_Buffer B)
{
LuaState L = B.L;
uint vl;
CharPtr s = lua_tolstring(L, -1, out vl);
if (vl <= bufffree(B))
{ /* fit into buffer? */
CharPtr dst = new CharPtr(B.buffer.chars, B.buffer.index + B.p);
CharPtr src = new CharPtr(s.chars, s.index);
for (uint i = 0; i < vl; i++)
dst[i] = src[i];
B.p += (int)vl;
lua_pop(L, 1); /* remove from stack */
}
else
{
if (emptybuffer(B) != 0)
lua_insert(L, -2); /* put buffer before new value */
B.lvl++; /* add new value into B stack */
adjuststack(B);
}
}
开发者ID:chenzuo,项目名称:SharpLua,代码行数:22,代码来源:lauxlib.cs
示例7: luaL_addstring
public static void luaL_addstring(luaL_Buffer B, CharPtr s)
{
luaL_addlstring(B, s, (uint)strlen(s));
}
开发者ID:chenzuo,项目名称:SharpLua,代码行数:4,代码来源:lauxlib.cs
示例8: luaL_prepbuffer
public static CharPtr luaL_prepbuffer(luaL_Buffer B)
{
if (emptybuffer(B) != 0)
adjuststack(B);
return new CharPtr(B.buffer, B.p);
}
开发者ID:chenzuo,项目名称:SharpLua,代码行数:6,代码来源:lauxlib.cs
示例9: emptybuffer
private static int emptybuffer(luaL_Buffer B)
{
uint l = (uint)bufflen(B);
if (l == 0) return 0; /* put nothing on stack */
else
{
lua_pushlstring(B.L, B.buffer, l);
B.p = 0;
B.lvl++;
return 1;
}
}
开发者ID:chenzuo,项目名称:SharpLua,代码行数:12,代码来源:lauxlib.cs
示例10: bufflen
/*
** {======================================================
** Generic Buffer manipulation
** =======================================================
*/
private static int bufflen(luaL_Buffer B) { return B.p; }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:7,代码来源:lauxlib.cs
示例11: add_value
private static void add_value(MatchState ms, luaL_Buffer b, CharPtr s,
CharPtr e)
{
lua_State L = ms.L;
switch (lua_type(L, 3)) {
case LUA_TNUMBER:
case LUA_TSTRING: {
add_s(ms, b, s, e);
return;
}
case LUA_TUSERDATA:
case LUA_TFUNCTION: {
int n;
lua_pushvalue(L, 3);
n = push_captures(ms, s, e);
lua_call(L, n, 1);
break;
}
case LUA_TTABLE: {
push_onecapture(ms, 0, s, e);
lua_gettable(L, 3);
break;
}
}
if (lua_toboolean(L, -1)==0) { /* nil or false? */
lua_pop(L, 1);
lua_pushlstring(L, s, (uint)(e - s)); /* keep original text */
}
else if (lua_isstring(L, -1)==0)
luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1));
luaL_addvalue(b); /* add result to accumulator */
}
开发者ID:WondermSwift,项目名称:kopilua-1,代码行数:32,代码来源:lstrlib.cs
示例12: add_s
private static void add_s(MatchState ms, luaL_Buffer b, CharPtr s,
CharPtr e)
{
uint l, i;
CharPtr news = lua_tolstring(ms.L, 3, out l);
for (i = 0; i < l; i++) {
if (news[i] != L_ESC)
luaL_addchar(b, news[i]);
else {
i++; /* skip ESC */
if (!isdigit((byte)(news[i])))
luaL_addchar(b, news[i]);
else if (news[i] == '0')
luaL_addlstring(b, s, (uint)(e - s));
else {
push_onecapture(ms, news[i] - '1', s, e);
luaL_addvalue(b); /* add capture to accumulated result */
}
}
}
}
开发者ID:WondermSwift,项目名称:kopilua-1,代码行数:21,代码来源:lstrlib.cs
示例13: addquoted
private static void addquoted(lua_State L, luaL_Buffer b, int arg)
{
uint l;
CharPtr s = luaL_checklstring(L, arg, out l);
luaL_addchar(b, '"');
while ((l--) != 0) {
switch (s[0]) {
case '"': case '\\': case '\n': {
luaL_addchar(b, '\\');
luaL_addchar(b, s[0]);
break;
}
case '\r': {
luaL_addlstring(b, "\\r", 2);
break;
}
case '\0': {
luaL_addlstring(b, "\\000", 4);
break;
}
default: {
luaL_addchar(b, s[0]);
break;
}
}
s = s.next();
}
luaL_addchar(b, '"');
}
开发者ID:WondermSwift,项目名称:kopilua-1,代码行数:29,代码来源:lstrlib.cs
示例14: tconcat
private static int tconcat(LuaState L)
{
luaL_Buffer b = new luaL_Buffer();
uint lsep;
int i, last;
CharPtr sep = luaL_optlstring(L, 2, "", out lsep);
luaL_checktype(L, 1, LUA_TTABLE);
i = luaL_optint(L, 3, 1);
last = luaL_opt_integer(L, luaL_checkint, 4, luaL_getn(L, 1));
luaL_buffinit(L, b);
for (; i < last; i++)
{
addfield(L, b, i);
luaL_addlstring(b, sep, lsep);
}
if (i == last) /* add last value (if interval was not empty) */
addfield(L, b, i);
luaL_pushresult(b);
return 1;
}
开发者ID:chenzuo,项目名称:SharpLua,代码行数:20,代码来源:ltablib.cs
示例15: luaL_addsize
public static void luaL_addsize(luaL_Buffer B, int n) { B.p += n; }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:1,代码来源:lauxlib.cs
示例16: str_char
private static int str_char(lua_State L)
{
int n = lua_gettop(L); /* number of arguments */
int i;
luaL_Buffer b = new luaL_Buffer();
luaL_buffinit(L, b);
for (i=1; i<=n; i++) {
int c = luaL_checkint(L, i);
luaL_argcheck(L, (byte)(c) == c, i, "invalid value");
luaL_addchar(b, (char)(byte)c);
}
luaL_pushresult(b);
return 1;
}
开发者ID:WondermSwift,项目名称:kopilua-1,代码行数:14,代码来源:lstrlib.cs
示例17: luaL_gsub
/* }====================================================== */
public static CharPtr luaL_gsub(LuaState L, CharPtr s, CharPtr p,
CharPtr r)
{
CharPtr wild;
uint l = (uint)strlen(p);
luaL_Buffer b = new luaL_Buffer();
luaL_buffinit(L, b);
while ((wild = strstr(s, p)) != null)
{
luaL_addlstring(b, s, (uint)(wild - s)); /* push prefix */
luaL_addstring(b, r); /* push replacement in place of pattern */
s = wild + l; /* continue after `p' */
}
luaL_addstring(b, s); /* push last suffix */
luaL_pushresult(b);
return lua_tostring(L, -1);
}
开发者ID:chenzuo,项目名称:SharpLua,代码行数:19,代码来源:lauxlib.cs
示例18: str_dump
private static int str_dump(lua_State L)
{
luaL_Buffer b = new luaL_Buffer();
luaL_checktype(L, 1, LUA_TFUNCTION);
lua_settop(L, 1);
luaL_buffinit(L,b);
if (lua_dump(L, writer, b) != 0)
luaL_error(L, "unable to dump given function");
luaL_pushresult(b);
return 1;
}
开发者ID:WondermSwift,项目名称:kopilua-1,代码行数:11,代码来源:lstrlib.cs
示例19: bufffree
private static int bufffree(luaL_Buffer B) { return LUAL_BUFFERSIZE - bufflen(B); }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:1,代码来源:lauxlib.cs
示例20: str_format
private static int str_format(lua_State L)
{
int arg = 1;
uint sfl;
CharPtr strfrmt = luaL_checklstring(L, arg, out sfl);
CharPtr strfrmt_end = strfrmt+sfl;
luaL_Buffer b = new luaL_Buffer();
luaL_buffinit(L, b);
while (strfrmt < strfrmt_end) {
if (strfrmt[0] != L_ESC)
{
luaL_addchar(b, strfrmt[0]);
strfrmt = strfrmt.next();
}
else if (strfrmt[1] == L_ESC)
{
luaL_addchar(b, strfrmt[0]); /* %% */
strfrmt = strfrmt + 2;
}
else
{ /* format item */
strfrmt = strfrmt.next();
CharPtr form = new char[MAX_FORMAT]; /* to store the format (`%...') */
CharPtr buff = new char[MAX_ITEM]; /* to store the formatted item */
arg++;
strfrmt = scanformat(L, strfrmt, form);
char ch = strfrmt[0];
strfrmt = strfrmt.next();
switch (ch)
{
case 'c':
{
sprintf(buff, form, (int)luaL_checknumber(L, arg));
break;
}
case 'd':
case 'i':
{
addintlen(form);
sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
break;
}
case 'o':
case 'u':
case 'x':
case 'X':
{
addintlen(form);
sprintf(buff, form, (UNSIGNED_LUA_INTFRM_T)luaL_checknumber(L, arg));
break;
}
case 'e':
case 'E':
case 'f':
case 'g':
case 'G':
{
sprintf(buff, form, (double)luaL_checknumber(L, arg));
break;
}
case 'q':
{
addquoted(L, b, arg);
continue; /* skip the 'addsize' at the end */
}
case 's':
{
uint l;
CharPtr s = luaL_checklstring(L, arg, out l);
if ((strchr(form, '.') == null) && l >= 100)
{
/* no precision and string is too long to be formatted;
keep original string */
lua_pushvalue(L, arg);
luaL_addvalue(b);
continue; /* skip the `addsize' at the end */
}
else
{
sprintf(buff, form, s);
break;
}
}
default:
{ /* also treat cases `pnLlh' */
return luaL_error(L, "invalid option " + LUA_QL("%%%c") + " to " +
LUA_QL("format"), strfrmt[-1]);
}
}
luaL_addlstring(b, buff, (uint)strlen(buff));
}
}
luaL_pushresult(b);
return 1;
}
开发者ID:WondermSwift,项目名称:kopilua-1,代码行数:95,代码来源:lstrlib.cs
注:本文中的luaL_Buffer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论