本文整理汇总了Java中org.luaj.vm2.Varargs.isstring方法的典型用法代码示例。如果您正苦于以下问题:Java Varargs.isstring方法的具体用法?Java Varargs.isstring怎么用?Java Varargs.isstring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.luaj.vm2.Varargs
的用法示例。
在下文中一共展示了Varargs.isstring方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
LuaString name = args.checkstring(1);
InputStream is = null;
// get package path
LuaValue path = package_.get(_PATH);
if (!path.isstring())
return valueOf("package.path is not a string");
// get the searchpath function.
Varargs v = package_.get(_SEARCHPATH).invoke(varargsOf(name, path));
// Did we get a result?
if (!v.isstring(1))
return v.arg(2).tostring();
LuaString filename = v.arg1().strvalue();
// Try to load the file.
v = globals.loadfile(filename.tojstring());
if (v.arg1().isfunction())
return LuaValue.varargsOf(v.arg1(), filename);
// report error
return varargsOf(NIL, valueOf("'" + filename + "': " + v.arg(2).tojstring()));
}
示例2: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
LuaString name = args.checkstring(1);
InputStream is = null;
// get package path
LuaValue path = package_.get(_PATH);
if ( ! path.isstring() )
return valueOf("package.path is not a string");
// get the searchpath function.
Varargs v = package_.get(_SEARCHPATH).invoke(varargsOf(name, path));
// Did we get a result?
if (!v.isstring(1))
return v.arg(2).tostring();
LuaString filename = v.arg1().strvalue();
// Try to load the file.
v = globals.loadfile(filename.tojstring());
if ( v.arg1().isfunction() )
return LuaValue.varargsOf(v.arg1(), filename);
// report error
return varargsOf(NIL, valueOf("'"+filename+"': "+v.arg(2).tojstring()));
}
示例3: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
args.argcheck(args.isstring(1) || args.isnil(1), 1, "filename must be string or nil");
String filename = args.isstring(1) ? args.tojstring(1) : null;
Varargs v = filename == null ?
loadStream(globals.STDIN, "=stdin", "bt", globals) :
loadFile(args.checkjstring(1), "bt", globals);
return v.isnil(1) ? error(v.tojstring(2)) : v.arg1().invoke();
}
示例4: setImage
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public LuaValue setImage(U view, Varargs varargs) {
if (varargs.isstring(2)) {
final String url = varargs.optjstring(2, null);
final LuaFunction callback = varargs.optfunction(3, null);
return view.setImageUrl(url, callback);
} else if (varargs.arg(2) instanceof UDData) {//data
final UDData data = (UDData) varargs.arg(2);
return view.setImageBytes(data != null ? data.bytes() : null);
} else if (varargs.arg(2) instanceof UDBitmap){//bitmap
final UDBitmap bitmap = (UDBitmap) varargs.arg(2);
return view.setImageBitmap(bitmap);
}
return view;
}
示例5: call
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public LuaValue call( LuaValue arg ) {
LuaString name = arg.checkstring();
LuaValue loaded = package_.get(_LOADED);
LuaValue result = loaded.get(name);
if ( result.toboolean() ) {
if ( result == _SENTINEL )
error("loop or previous error loading module '"+name+"'");
return result;
}
/* else must load it; iterate over available loaders */
LuaTable tbl = package_.get(_SEARCHERS).checktable();
StringBuffer sb = new StringBuffer();
Varargs loader = null;
for ( int i=1; true; i++ ) {
LuaValue searcher = tbl.get(i);
if ( searcher.isnil() ) {
error( "module '"+name+"' not found: "+name+sb );
}
/* call loader with module name as argument */
loader = searcher.invoke(name);
if ( loader.isfunction(1) )
break;
if ( loader.isstring(1) )
sb.append( loader.tojstring(1) );
}
// load the module using the loader
loaded.set(name, _SENTINEL);
result = loader.arg1().call(name, loader.arg(2));
if ( ! result.isnil() )
loaded.set( name, result );
else if ( (result = loaded.get(name)) == _SENTINEL )
loaded.set( name, result = LuaValue.TRUE );
return result;
}
示例6: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
args.argcheck(args.isstring(1) || args.isnil(1), 1, "filename must be string or nil");
String filename = args.isstring(1) ? args.tojstring(1) : null;
Varargs v = filename == null ? loadStream(globals.STDIN, "=stdin", "bt", globals) :
loadFile(args.checkjstring(1), "bt", globals);
return v.isnil(1) ? error(v.tojstring(2)) : v.arg1().invoke();
}
示例7: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
@Override
public Varargs invoke(Varargs arguments) {
BlocksItems.load();
if (arguments.isstring(1)) {
LuaUserdata u = blocksItems.blockUserdata.get(arguments.checkjstring(1));
return u != null ? u : NIL;
} else {
return BlocksItems.blockTable;
}
}
示例8: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
args.argcheck(args.isstring(1) || args.isnil(1), 1, "filename must be string or nil");
String filename = args.isstring(1)? args.tojstring(1): null;
Varargs v = filename == null?
loadStream( globals.STDIN, "=stdin", "bt", globals ):
loadFile( args.checkjstring(1), "bt", globals );
return v.isnil(1)? error(v.tojstring(2)): v.arg1().invoke();
}
示例9: invoke
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
@Override
public Varargs invoke(Varargs args) {
BlocksItems.load();
if (args.isstring(1)) {
LuaUserdata u = BlocksItems.blockUserdata.get(args.checkjstring(1));
return u != null ? u : NIL;
} else {
return BlocksItems.blockTable;
}
}
示例10: call
import org.luaj.vm2.Varargs; //导入方法依赖的package包/类
public LuaValue call(LuaValue arg) {
LuaString name = arg.checkstring();
LuaValue loaded = package_.get(_LOADED);
LuaValue result = loaded.get(name);
if (result.toboolean()) {
if (result == _SENTINEL)
error("loop or previous error loading module '" + name + "'");
return result;
}/* else if (globals != null && (result = globals.lazyLoad(name.checkjstring())) != null){//TODO add by song, 如果是加载自定义的内容则使用globals加载
loaded.set(name, _SENTINEL);
return result;
}*/
/* else must load it; iterate over available loaders */
LuaTable tbl = package_.get(_SEARCHERS).checktable();
StringBuffer sb = new StringBuffer();
Varargs loader = null;
for (int i = 1; true; i++) {
LuaValue searcher = tbl.get(i);
if (searcher.isnil()) {
error("module '" + name + "' not found: " + name + sb);
}
/* call loader with module name as argument */
loader = searcher.invoke(name);
if (loader.isfunction(1))
break;
if (loader.isstring(1))
sb.append(loader.tojstring(1));
}
// load the module using the loader
loaded.set(name, _SENTINEL);
try {
result = loader.arg1().call(name, loader.arg(2));
if (!result.isnil())
loaded.set(name, result);
else if ((result = loaded.get(name)) == _SENTINEL)
loaded.set(name, result = LuaValue.TRUE);
return result;
} catch (Exception e){
LogUtil.e("[PackageLib]", name, "load failed!", e);
return NIL;
}
}