本文整理汇总了Java中org.luaj.vm2.Varargs.arg方法的典型用法代码示例。如果您正苦于以下问题:Java Varargs.arg方法的具体用法?Java Varargs.arg怎么用?Java Varargs.arg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.luaj.vm2.Varargs
的用法示例。
在下文中一共展示了Varargs.arg方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
StringBuffer sb = new StringBuffer();
for (int i = 1, n = args.narg(); i <= n; i++) {
if (i > 1) {
sb.append('\t');
}
if (args.arg(i) instanceof UDView) {//基础的View对象
} else if (args.arg(i) instanceof BaseUserdata) {//基础用户数据扩展
} else if (args.arg(i) instanceof BaseLuaTable) {//基础Table表的扩展
}
}
LogUtil.i(sb);
return NONE;
}
示例2: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
@Override
public LuaValue invoke(Varargs args) {
final LuaValue target = args.arg(2);
final LuaValue callback = LuaUtil.getFunction(args, 3);
if(callback != null){//通过callback来处理
new SimpleTask1<LuaValue>() {
@Override
protected LuaValue doInBackground(Object... params) {
return isValid(target);
}
@Override
protected void onPostExecute(LuaValue result) {
LuaUtil.callFunction(callback, result);
}
}.executeInPool();
return LuaValue.NIL;
} else {
return isValid(target);
}
}
示例3: getValue
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
/**
* get value of given type, from varargs in position [poslist]
*
* @param type
* @param varargs
* @param poslist
* @return
*/
private static Object getValue(final int type, final Varargs varargs, Object defaultValue, int... poslist) {
Object result = null;
if (varargs != null) {
if (poslist != null && poslist.length > 0) {
LuaValue value = null;
for (int i = 0; i < poslist.length; i++) {
if (varargs.narg() >= poslist[i]) {
value = varargs.arg(poslist[i]);
result = parseValue(type, value);
}
if (result != null) {
break;
}
}
}
}
return result != null ? result : defaultValue;
}
示例4: onCalled
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
@Override
public LuaValue onCalled(Varargs parameters) {
String eventClassName = parameters.arg(1).tojstring();
LuaValue function = parameters.arg(2);
try {
Class<?> theClass = Class.forName(eventClassName);
attachment.eventListeners.put(theClass, function);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return LuaValue.NIL;
}
示例5: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
LuaValue func = args.checkfunction(1);
int up = args.checkint(2);
LuaValue value = args.arg(3);
if (func instanceof LuaClosure) {
LuaClosure c = (LuaClosure) func;
LuaString name = findupvalue(c, up);
if (name != null) {
c.upValues[up - 1].setValue(value);
return name;
}
}
return NIL;
}
示例6: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
int a=1;
LuaThread thread = args.isthread(a)? args.checkthread(a++): globals.running;
int level = args.checkint(a++);
int local = args.checkint(a++);
LuaValue value = args.arg(a++);
CallFrame f = callstack(thread).getCallFrame(level);
return f != null? f.setLocal(local, value): NONE;
}
示例7: 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));
}
示例8: startAnimation
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
/**
* 开始动画
*
* @param view
* @param varargs
* @return
*/
@LuaViewApi(revisions = {"待废弃"})
public LuaValue startAnimation(U view, Varargs varargs) {
LuaValue[] animators = null;
if (varargs.narg() > 1) {
animators = new LuaValue[varargs.narg() - 1];
for (int i = 2; i <= varargs.narg(); i++) {
animators[i - 2] = varargs.arg(i);
}
}
return view.startAnimation(animators);
}
示例9: onCalled
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
@Override
public LuaValue onCalled(Varargs parameters) {
LuaPlugin luaPlugin = (LuaPlugin) parameters.arg(1);
EventAttachment attachment = new EventAttachment(luaPlugin);
ATTACHMENTS.add(attachment);
return attachment;
}
示例10: setFooter
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public LuaValue setFooter(U view, Varargs varargs) {
final LuaValue footer = varargs.arg(2);
return getUDBaseListView(varargs).setFooter(footer);
}
示例11: with
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public LuaValue with(U udAnimator, Varargs varargs) {
final UDView udView = (varargs.narg() > 1 && varargs.arg(2) instanceof UDView) ? (UDView) varargs.arg(2) : null;
return udAnimator.with(udView);
}
示例12: fromLua
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
/**
* Create hub from a lua script text
*/
public static Hub fromLua(String luaText) throws Exception {
// Obatain a lua globals for loading configs
final Globals globals = new Globals();
LoadState.install(globals);
LuaC.install(globals);
final Hub hub = new Hub();
globals.load(luaText).call();
Varargs pair;
LuaValue key = LuaValue.NIL;
LuaValue value;
String keyStr;
while (true) {
pair = globals.next(key);
if ((key = pair.arg1()).isnil())
break;
value = pair.arg(2);
keyStr = key.checkjstring();
switch (keyStr) {
case "ID":
hub.setId(value.checkjstring().toLowerCase());
break;
case "NAME":
hub.setName(value.checkjstring());
break;
case "TYPE":
final String type = value.checkjstring();
boolean isTypeSupported = false;
for (String supportedType : SUPPORTED_TYPES) {
if (supportedType.equalsIgnoreCase(type)) {
isTypeSupported = true;
break;
}
}
if (isTypeSupported) {
hub.setType(type);
} else {
throw new Exception("Not supported hub type.");
}
break;
case "VERSION":
hub.setVersion(value.checkjstring());
break;
case "ENTRY":
hub.setEntry(value.checkjstring());
break;
case "DEBUG":
hub.setDebug(value.checkboolean());
break;
default:
hub.userConfig.put(keyStr, value);
break;
}
}
hub.checkProperties();
return hub;
}
示例13: onCalled
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
@Override
public LuaValue onCalled(Varargs parameters) {
LuaAccessor accessor = (LuaAccessor) parameters.arg(1);
return new PlayerType(accessor);
}