本文整理汇总了C#中KopiLua.CharPtr.next方法的典型用法代码示例。如果您正苦于以下问题:C# CharPtr.next方法的具体用法?C# CharPtr.next怎么用?C# CharPtr.next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KopiLua.CharPtr
的用法示例。
在下文中一共展示了CharPtr.next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PushNextTemplate
private static CharPtr PushNextTemplate(LuaState L, CharPtr path)
{
CharPtr l;
while (path[0] == LUA_PATHSEP[0]) path = path.next(); /* skip separators */
if (path[0] == '\0') return null; /* no more templates */
l = strchr(path, LUA_PATHSEP[0]); /* find next separator */
if (l == null) l = path + strlen(path);
LuaPushLString(L, path, (uint)(l - path)); /* template */
return l;
}
示例2: LuaOChunkID
public static void LuaOChunkID(CharPtr out_, CharPtr source, uint bufflen)
{
//out_ = "";
if (source[0] == '=') {
strncpy(out_, source+1, (int)bufflen); /* remove first char */
out_[bufflen-1] = '\0'; /* ensures null termination */
}
else { /* out = "source", or "...source" */
if (source[0] == '@') {
uint l;
source = source.next(); /* skip the `@' */
bufflen -= (uint)(" '...' ".Length + 1);
l = (uint)strlen(source);
strcpy(out_, "");
if (l > bufflen) {
source += (l-bufflen); /* get last part of file name */
strcat(out_, "...");
}
strcat(out_, source);
}
else { /* out = [string "string"] */
uint len = strcspn(source, "\n\r"); /* stop at first newline */
bufflen -= (uint)(" [string \"...\"] ".Length + 1);
if (len > bufflen) len = bufflen;
strcpy(out_, "[string \"");
if (source[len] != '\0') { /* must truncate? */
strncat(out_, source, (int)len);
strcat(out_, "...");
}
else
strcat(out_, source);
strcat(out_, "\"]");
}
}
}
示例3: min_expand
private static CharPtr min_expand(MatchState ms, CharPtr s,
CharPtr p, CharPtr ep)
{
for (;;) {
CharPtr res = match(ms, s, ep+1);
if (res != null)
return res;
else if ( (s < ms.src_end) && (singlematch((byte)(s[0]), p, ep) != 0) )
s = s.next(); /* try with one more repetition */
else return null;
}
}
示例4: scanformat
private static CharPtr scanformat(lua_State L, CharPtr strfrmt, CharPtr form)
{
CharPtr p = strfrmt;
while (p[0] != '\0' && strchr(FLAGS, p[0]) != null) p = p.next(); /* skip flags */
if ((uint)(p - strfrmt) >= (FLAGS.Length+1))
luaL_error(L, "invalid format (repeated flags)");
if (isdigit((byte)(p[0]))) p = p.next(); /* skip width */
if (isdigit((byte)(p[0]))) p = p.next(); /* (2 digits at most) */
if (p[0] == '.') {
p = p.next();
if (isdigit((byte)(p[0]))) p = p.next(); /* skip precision */
if (isdigit((byte)(p[0]))) p = p.next(); /* (2 digits at most) */
}
if (isdigit((byte)(p[0])))
luaL_error(L, "invalid format (width or precision too long)");
form[0] = '%';
form = form.next();
strncpy(form, strfrmt, p - strfrmt + 1);
form += p - strfrmt + 1;
form[0] = '\0';
return p;
}
示例5: matchbalance
private static CharPtr matchbalance(MatchState ms, CharPtr s,
CharPtr p)
{
if ((p[0] == 0) || (p[1] == 0))
luaL_error(ms.L, "unbalanced pattern");
if (s[0] != p[0]) return null;
else {
int b = p[0];
int e = p[1];
int cont = 1;
while ((s=s.next()) < ms.src_end) {
if (s[0] == e) {
if (--cont == 0) return s+1;
}
else if (s[0] == b) cont++;
}
}
return null; /* string ends out of balance */
}
示例6: matchbracketclass
private static int matchbracketclass(int c, CharPtr p, CharPtr ec)
{
int sig = 1;
if (p[1] == '^') {
sig = 0;
p = p.next(); /* skip the `^' */
}
while ((p=p.next()) < ec) {
if (p == L_ESC) {
p = p.next();
if (match_class(c, (byte)(p[0])) != 0)
return sig;
}
else if ((p[1] == '-') && (p + 2 < ec)) {
p+=2;
if ((byte)((p[-2])) <= c && (c <= (byte)p[0]))
return sig;
}
else if ((byte)(p[0]) == c) return sig;
}
return (sig == 0) ? 1 : 0;
}
示例7: classend
private static CharPtr classend(MatchState ms, CharPtr p)
{
p = new CharPtr(p);
char c = p[0];
p = p.next();
switch (c) {
case L_ESC: {
if (p[0] == '\0')
luaL_error(ms.L, "malformed pattern (ends with " + LUA_QL("%%") + ")");
return p+1;
}
case '[': {
if (p[0] == '^') p = p.next();
do { /* look for a `]' */
if (p[0] == '\0')
luaL_error(ms.L, "malformed pattern (missing " + LUA_QL("]") + ")");
c = p[0];
p = p.next();
if (c == L_ESC && p[0] != '\0')
p = p.next(); /* skip escapes (e.g. `%]') */
} while (p[0] != ']');
return p+1;
}
default: {
return p;
}
}
}
示例8: match
private static CharPtr match(MatchState ms, CharPtr s, CharPtr p)
{
s = new CharPtr(s);
p = new CharPtr(p);
init: /* using goto's to optimize tail recursion */
switch (p[0]) {
case '(': { /* start capture */
if (p[1] == ')') /* position capture? */
return start_capture(ms, s, p+2, CAP_POSITION);
else
return start_capture(ms, s, p+1, CAP_UNFINISHED);
}
case ')': { /* end capture */
return end_capture(ms, s, p+1);
}
case L_ESC: {
switch (p[1]) {
case 'b': { /* balanced string? */
s = matchbalance(ms, s, p+2);
if (s == null) return null;
p+=4; goto init; /* else return match(ms, s, p+4); */
}
case 'f': { /* frontier? */
CharPtr ep; char previous;
p += 2;
if (p[0] != '[')
luaL_error(ms.L, "missing " + LUA_QL("[") + " after " +
LUA_QL("%%f") + " in pattern");
ep = classend(ms, p); /* points to what is next */
previous = (s == ms.src_init) ? '\0' : s[-1];
if ((matchbracketclass((byte)(previous), p, ep-1)!=0) ||
(matchbracketclass((byte)(s[0]), p, ep-1)==0)) return null;
p=ep; goto init; /* else return match(ms, s, ep); */
}
default: {
if (isdigit((byte)(p[1]))) { /* capture results (%0-%9)? */
s = match_capture(ms, s, (byte)(p[1]));
if (s == null) return null;
p+=2; goto init; /* else return match(ms, s, p+2) */
}
goto dflt; /* case default */
}
}
}
case '\0': { /* end of pattern */
return s; /* match succeeded */
}
case '$': {
if (p[1] == '\0') /* is the `$' the last char in pattern? */
return (s == ms.src_end) ? s : null; /* check end of string */
else goto dflt;
}
default: dflt: { /* it is a pattern item */
CharPtr ep = classend(ms, p); /* points to what is next */
int m = (s<ms.src_end) && (singlematch((byte)(s[0]), p, ep)!=0) ? 1 : 0;
switch (ep[0]) {
case '?': { /* optional */
CharPtr res;
if ((m!=0) && ((res=match(ms, s+1, ep+1)) != null))
return res;
p=ep+1; goto init; /* else return match(ms, s, ep+1); */
}
case '*': { /* 0 or more repetitions */
return max_expand(ms, s, p, ep);
}
case '+': { /* 1 or more repetitions */
return ((m!=0) ? max_expand(ms, s+1, p, ep) : null);
}
case '-': { /* 0 or more repetitions (minimum) */
return min_expand(ms, s, p, ep);
}
default: {
if (m==0) return null;
s = s.next(); p=ep; goto init; /* else return match(ms, s+1, ep); */
}
}
}
}
}
示例9: LuaGetInfo
public static int LuaGetInfo (LuaState L, CharPtr what, ref LuaDebug ar) {
int status;
Closure f = null;
CallInfo ci = null;
LuaLock(L);
if (what == '>') {
StkId func = L.top - 1;
luai_apicheck(L, TTIsFunction(func));
what = what.next(); /* skip the '>' */
f = CLValue(func);
StkId.Dec(ref L.top); /* pop function */
}
else if (ar.i_ci != 0) { /* no tail call? */
ci = L.base_ci[ar.i_ci];
LuaAssert(TTIsFunction(ci.func));
f = CLValue(ci.func);
}
status = AuxGetInfo(L, what, ar, f, ci);
if (strchr(what, 'f') != null) {
if (f == null) SetNilValue(L.top);
else SetCLValue(L, L.top, f);
IncrTop(L);
}
if (strchr(what, 'L') != null)
CollectValidLines(L, f);
LuaUnlock(L);
return status;
}
示例10: match
private static CharPtr match(MatchState ms, CharPtr s, CharPtr p)
{
s = new CharPtr(s);
p = new CharPtr(p);
bool runDflt = false;
bool runInit = true;
if (ms.matchdepth-- == 0)
LuaLError(ms.L, "pattern too complex");
//init:
while (runInit) { // Replaces "init:" in order to be compatible with Mono.
runInit = false; // No "goto init" until further notice.
if (p != '\0') { /* end of pattern? */
switch (p[0]) {
case '(': { /* start capture */
if (p[1] == ')') { /* position capture? */
s = start_capture(ms, s, p + 2, CAP_POSITION);
}
else {
s = start_capture(ms, s, p + 1, CAP_UNFINISHED);
}
break;
}
case ')': { /* end capture */
s = end_capture(ms, s, p + 1);
break;
}
case '$': {
if (p[1] != '\0') { /* is the `$' the last char in pattern? */
runDflt = true; //goto dflt; /* no; go to default */
}
s = (s == ms.src_end) ? s : null; /* check end of string */
break;
}
case L_ESC: { /* escaped sequences not in the format class[*+?-]? */
switch (p[1]) {
case 'b': { /* balanced string? */
s = matchbalance(ms, s, p + 2);
if (s != null) {
p += 4;
runInit = true; //goto init; /* return match(ms, s, p+4); */
}
/* else fail (s == NULL) */
break;
}
case 'f': { /* frontier? */
CharPtr ep; char previous;
p += 2;
if (p[0] != '[') {
LuaLError(ms.L, "missing " + LUA_QL("[") + " after " +
LUA_QL("%%f") + " in pattern");
}
ep = classend(ms, p); /* points to what is next */
previous = (s == ms.src_init) ? '\0' : s[-1];
if ((matchbracketclass((byte)(previous), p, ep - 1) == 0) ||
(matchbracketclass((byte)(s[0]), p, ep - 1) != 0)) {
p = ep;
runInit = true; //goto init; /* else return match(ms, s, ep); */
}
s = null; /* match failed */
break;
}
default: {
if (isdigit((byte)(p[1]))) { /* capture results (%0-%9)? */
s = match_capture(ms, s, (byte)(p[1]));
if (s != null) {
p += 2;
runInit = true; //goto init; /* else return match(ms, s, p+2) */
}
break;
}
runDflt = true; //goto dflt;
break;
}
}
break;
}
default: {
runDflt = true; // goto dflt
break;
}
}
}
//dflt:
if (runDflt) // Replaces "dflt:" in order to be compatible with Mono.
{ /* pattern class plus optional suffix */
runDflt = false; // no more "goto dflt" until further notice.
CharPtr ep = classend(ms, p); /* points to optional suffix */
/* does not match at least once? */
if ((s >= ms.src_end) || (singlematch((byte)(s[0]), p, ep) == 0)) {
if (ep == '*' || ep == '?' || ep == '-') { /* accept empty? */
p = ep + 1;
runInit = true; //goto init; /* return match(ms, s, ep + 1); */
}
else /* '+' or no suffix */
s = null; /* fail */
}
else { /* matched once */
switch (ep[0]) {
case '?': { /* optional */
//.........这里部分代码省略.........
示例11: AuxGetInfo
private static int AuxGetInfo (LuaState L, CharPtr what, LuaDebug ar,
Closure f, CallInfo ci) {
int status = 1;
if (f == null) {
InfoTailCall(ar);
return status;
}
for (; what[0] != 0; what = what.next()) {
switch (what[0]) {
case 'S': {
FuncInfo(ar, f);
break;
}
case 'l': {
ar.currentline = (ci != null) ? CurrentLine(L, ci) : -1;
break;
}
case 'u': {
ar.nups = f.c.nupvalues;
break;
}
case 'n': {
ar.namewhat = (ci!=null) ? GetFuncName(L, ci, ref ar.name) : null;
if (ar.namewhat == null) {
ar.namewhat = ""; /* not found */
ar.name = null;
}
break;
}
case 'L':
case 'f': /* handled by lua_getinfo */
break;
default: status = 0; break;/* invalid option */
}
}
return status;
}
示例12: StrFTimeAdd
private static CharPtr StrFTimeAdd(CharPtr str, CharPtr pt, CharPtr ptlim)
{
pt[0] = str[0];
str = str.next();
while (pt < ptlim && pt[0] != 0)
{
pt.inc();
pt[0] = str[0];
str = str.next();
}
return pt;
}
示例13: LuaLAddLString
public static void LuaLAddLString (LuaLBuffer B, CharPtr s, uint l) {
while (l-- != 0)
{
char c = s[0];
s = s.next();
LuaLAddChar(B, c);
}
}
示例14: lua_getinfo
public static int lua_getinfo(lua_State L, CharPtr what, lua_Debug ar)
{
int status;
Closure f = null;
CallInfo ci = null;
lua_lock(L);
if (what == '>') {
StkId func = L.top - 1;
luai_apicheck(L, ttisfunction(func));
what = what.next(); /* skip the '>' */
f = clvalue(func);
StkId.dec(ref L.top); /* pop function */
}
else if (ar.i_ci != 0) { /* no tail call? */
ci = L.base_ci[ar.i_ci];
lua_assert(ttisfunction(ci.func));
f = clvalue(ci.func);
}
status = auxgetinfo(L, what, ar, f, ci);
if (strchr(what, 'f') != null) {
if (f == null) setnilvalue(L.top);
else setclvalue(L, L.top, f);
incr_top(L);
}
if (strchr(what, 'L') != null)
collectvalidlines(L, f);
lua_unlock(L);
return status;
}
示例15: luaL_addlstring
public static void luaL_addlstring (luaL_Buffer B, CharPtr s, uint l) {
while (l-- != 0)
{
char c = s[0];
s = s.next();
luaL_addchar(B, c);
}
}