本文整理汇总了Java中org.luaj.vm2.Varargs.optint方法的典型用法代码示例。如果您正苦于以下问题:Java Varargs.optint方法的具体用法?Java Varargs.optint怎么用?Java Varargs.optint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.luaj.vm2.Varargs
的用法示例。
在下文中一共展示了Varargs.optint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
int a = 1;
LuaThread t = args.isthread(a) ? args.checkthread(a++) : globals.running;
LuaValue func = args.optfunction(a++, null);
String str = args.optjstring(a++, "");
int count = args.optint(a++, 0);
boolean call = false, line = false, rtrn = false;
for (int i = 0; i < str.length(); i++)
switch (str.charAt(i)) {
case 'c':
call = true;
break;
case 'l':
line = true;
break;
case 'r':
rtrn = true;
break;
}
t.hookfunc = func;
t.hookcall = call;
t.hookline = line;
t.hookcount = count;
t.hookrtrn = rtrn;
return NONE;
}
示例2: startAnimationImages
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
/**
* 开始帧动画
*
* @param view
* @param varargs 时间是秒而不是毫秒
* @return
*/
@Deprecated
public LuaValue startAnimationImages(U view, Varargs varargs) {//TODO 支持UDImageView和UDBitmap
final LuaTable imagesTable = varargs.opttable(2, null);
final double duration = varargs.optdouble(3, 1f);
boolean repeat = false;
if (varargs.isnumber(4)) {
repeat = varargs.optint(4, -1) > 0;
} else {
repeat = varargs.optboolean(4, false);
}
if (imagesTable != null && imagesTable.length() > 0) {
final String[] images = new String[imagesTable.length()];
int i = 0;
for (LuaValue key : imagesTable.keys()) {
images[i++] = imagesTable.get(key).optjstring(null);
}
return view.startAnimationImages(images, (int) duration * 1000, repeat);
}
return view;
}
示例3: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
int a=1;
LuaThread t = args.isthread(a)? args.checkthread(a++): globals.running;
LuaValue func = args.optfunction(a++, null);
String str = args.optjstring(a++,"");
int count = args.optint(a++,0);
boolean call=false,line=false,rtrn=false;
for ( int i=0; i<str.length(); i++ )
switch ( str.charAt(i) ) {
case 'c': call=true; break;
case 'l': line=true; break;
case 'r': rtrn=true; break;
}
LuaThread.State s = t.state;
s.hookfunc = func;
s.hookcall = call;
s.hookline = line;
s.hookcount = count;
s.hookrtrn = rtrn;
return NONE;
}
示例4: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
@Override
public Varargs invoke(Varargs args) {
int x = args.checkint(1);
int y = args.checkint(2);
int z = args.checkint(3);
Block block = (Block) args.checkuserdata(4, Block.class);
int meta = args.optint(5, 0);
world.setBlock(block, x, y, z, meta);
return NIL;
}
示例5: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
LuaString src = args.checkstring( 1 );
final int srclen = src.length();
LuaString p = args.checkstring( 2 );
LuaValue repl = args.arg( 3 );
int max_s = args.optint( 4, srclen + 1 );
final boolean anchor = p.length() > 0 && p.charAt( 0 ) == '^';
Buffer lbuf = new Buffer( srclen );
MatchState ms = new MatchState( args, src, p );
int soffset = 0;
int n = 0;
while ( n < max_s ) {
ms.reset();
int res = ms.match( soffset, anchor ? 1 : 0 );
if ( res != -1 ) {
n++;
ms.add_value( lbuf, soffset, res, repl );
}
if ( res != -1 && res > soffset )
soffset = res;
else if ( soffset < srclen )
lbuf.append( (byte) src.luaByte( soffset++ ) );
else
break;
if ( anchor )
break;
}
lbuf.append( src.substring( soffset, srclen ) );
return varargsOf(lbuf.tostring(), valueOf(n));
}
示例6: getIntValues
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
/**
* get int value from Varargs
*
* @param varargs
* @param firstIndex 开始的位置
* @return
*/
public static int[] getIntValues(Varargs varargs, int firstIndex) {
int[] values = null;
if (varargs.narg() > (firstIndex - 1)) {
values = new int[varargs.narg() - (firstIndex - 1)];
for (int i = firstIndex; i <= varargs.narg(); i++) {
values[i - firstIndex] = varargs.optint(i, 0);
}
}
return values;
}
示例7: setCurrentItem
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public LuaValue setCurrentItem(U view, Varargs varargs) {
final int item = varargs.optint(2, -1);
return view.setCurrentItem(item);
}
示例8: setCurrentItem
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public LuaValue setCurrentItem(U view, Varargs varargs) {
final int currentItem = varargs.optint(2, -1);
return view.setCurrentItem(currentItem);
}
示例9: str_find_aux
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
/**
* This utility method implements both string.find and string.match.
*/
static Varargs str_find_aux( Varargs args, boolean find ) {
LuaString s = args.checkstring( 1 );
LuaString pat = args.checkstring( 2 );
int init = args.optint( 3, 1 );
if ( init > 0 ) {
init = Math.min( init - 1, s.length() );
} else if ( init < 0 ) {
init = Math.max( 0, s.length() + init );
}
boolean fastMatch = find && ( args.arg(4).toboolean() || pat.indexOfAny( SPECIALS ) == -1 );
if ( fastMatch ) {
int result = s.indexOf( pat, init );
if ( result != -1 ) {
return varargsOf( valueOf(result+1), valueOf(result+pat.length()) );
}
} else {
MatchState ms = new MatchState( args, s, pat );
boolean anchor = false;
int poff = 0;
if ( pat.luaByte( 0 ) == '^' ) {
anchor = true;
poff = 1;
}
int soff = init;
do {
int res;
ms.reset();
if ( ( res = ms.match( soff, poff ) ) != -1 ) {
if ( find ) {
return varargsOf( valueOf(soff+1), valueOf(res), ms.push_captures( false, soff, res ));
} else {
return ms.push_captures( true, soff, res );
}
}
} while ( soff++ < s.length() && !anchor );
}
return NIL;
}
示例10: setLines
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public LuaValue setLines(U view, Varargs varargs) {
final int lines = varargs.optint(2, -1);
return view.setLines(lines);
}
示例11: setMaxLines
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public LuaValue setMaxLines(U view, Varargs varargs) {
final int lines = varargs.optint(2, -1);
return view.setMaxLines(lines);
}
示例12: setMinLines
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public LuaValue setMinLines(U view, Varargs varargs) {
final int lines = varargs.optint(2, -1);
return view.setMinLines(lines);
}
示例13: setRetryTimes
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public LuaValue setRetryTimes(U http, Varargs varargs) {
final int retryTimes = varargs.optint(2, UDHttp.DEFAULT_RETRY_TIMES);
return http.setRetryTimes(retryTimes);
}
示例14: gsub
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
/**
* string.gsub (s, pattern, repl [, n])
* Returns a copy of s in which all (or the first n, if given) occurrences of the
* pattern have been replaced by a replacement string specified by repl, which
* may be a string, a table, or a function. gsub also returns, as its second value,
* the total number of matches that occurred.
*
* If repl is a string, then its value is used for replacement.
* The character % works as an escape character: any sequence in repl of the form %n,
* with n between 1 and 9, stands for the value of the n-th captured substring (see below).
* The sequence %0 stands for the whole match. The sequence %% stands for a single %.
*
* If repl is a table, then the table is queried for every match, using the first capture
* as the key; if the pattern specifies no captures, then the whole match is used as the key.
*
* If repl is a function, then this function is called every time a match occurs,
* with all captured substrings passed as arguments, in order; if the pattern specifies
* no captures, then the whole match is passed as a sole argument.
*
* If the value returned by the table query or by the function call is a string or a number,
* then it is used as the replacement string; otherwise, if it is false or nil,
* then there is no replacement (that is, the original match is kept in the string).
*
* Here are some examples:
* x = string.gsub("hello world", "(%w+)", "%1 %1")
* --> x="hello hello world world"
*
* x = string.gsub("hello world", "%w+", "%0 %0", 1)
* --> x="hello hello world"
*
* x = string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1")
* --> x="world hello Lua from"
*
* x = string.gsub("home = $HOME, user = $USER", "%$(%w+)", os.getenv)
* --> x="home = /home/roberto, user = roberto"
*
* x = string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s)
* return loadstring(s)()
* end)
* --> x="4+5 = 9"
*
* local t = {name="lua", version="5.1"}
* x = string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
* --> x="lua-5.1.tar.gz"
*/
static Varargs gsub(Varargs args) {
LuaString src = args.checkstring(1);
final int srclen = src.length();
LuaString p = args.checkstring(2);
LuaValue repl = args.arg(3);
int max_s = args.optint(4, srclen + 1);
final boolean anchor = p.length() > 0 && p.charAt(0) == '^';
Buffer lbuf = new Buffer(srclen);
MatchState ms = new MatchState(args, src, p);
int soffset = 0;
int n = 0;
while (n < max_s) {
ms.reset();
int res = ms.match(soffset, anchor ? 1 : 0);
if (res != -1) {
n++;
ms.add_value(lbuf, soffset, res, repl);
}
if (res != -1 && res > soffset)
soffset = res;
else if (soffset < srclen)
lbuf.append((byte) src.luaByte(soffset++));
else
break;
if (anchor)
break;
}
lbuf.append(src.substring(soffset, srclen));
return varargsOf(lbuf.tostring(), valueOf(n));
}
示例15: pageScroll
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
/**
* scroll one page
*
* @param view
* @param varargs
* @return
*/
@Deprecated
public LuaValue pageScroll(U view, Varargs varargs) {
final int direction = varargs.optint(2, 0);
return view.pageScroll(direction);
}