本文整理匯總了Java中org.luaj.vm2.LuaValue.isnil方法的典型用法代碼示例。如果您正苦於以下問題:Java LuaValue.isnil方法的具體用法?Java LuaValue.isnil怎麽用?Java LuaValue.isnil使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.luaj.vm2.LuaValue
的用法示例。
在下文中一共展示了LuaValue.isnil方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: invoke
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
String name = method.getName();
LuaValue func = lobj.get(name);
if ( func.isnil() )
return null;
boolean isvarargs = ((method.getModifiers() & METHOD_MODIFIERS_VARARGS) != 0);
int n = args!=null? args.length: 0;
LuaValue[] v;
if ( isvarargs ) {
Object o = args[--n];
int m = Array.getLength( o );
v = new LuaValue[n+m];
for ( int i=0; i<n; i++ )
v[i] = CoerceJavaToLua.coerce(args[i]);
for ( int i=0; i<m; i++ )
v[i+n] = CoerceJavaToLua.coerce(Array.get(o,i));
} else {
v = new LuaValue[n];
for ( int i=0; i<n; i++ )
v[i] = CoerceJavaToLua.coerce(args[i]);
}
LuaValue result = func.invoke(v).arg1();
return CoerceLuaToJava.coerce(result, method.getReturnType());
}
示例2: getGenericListFromTable
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
* Transforming a table of LUA values to a array list of generic data types.
* @param table The table.
* @param mapper The mapper.
* @param <T> The generic type.
* @return The mapped arraylist.
*/
private static <T> ArrayList<T> getGenericListFromTable(LuaValue table, LuaValueMapper<T> mapper) {
ArrayList<T> generics = new ArrayList<T>();
if (!table.isnil() && table.istable()) {
int i = 1;
while (true) {
LuaValue v = table.get(i);
if (v.isnil()) {
break;
}
generics.add(mapper.map(v));
i++;
}
}
return generics;
}
示例3: method
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@RuntimeType
public Object method(@Origin Method aMethod, @This Object o, @AllArguments Object[] objects) {
LuaValue value = delegations.get(aMethod.getName());
if (value.isnil())
return null;
if (value.isfunction()) {
LuaFunction function = value.checkfunction();
LuaValue[] parameters = convertParamsToLua(o, objects);
Varargs invoke = function.invoke(parameters);
if (aMethod.getReturnType() == Void.class || invoke.narg() == 0)
return null;
return LuaConversion.convertToJava(aMethod.getReturnType(), invoke.checkvalue(1));
} else {
return LuaConversion.convertToJava(aMethod.getReturnType(), value);
}
}
示例4: constructor
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public void constructor(@This Object o, @AllArguments Object[] objects) { // @Origin
// Constructor
// constructor,
LuaValue value = delegations.get("__new__");
if (value.isnil())
return;
if (!value.isfunction())
throw new DynamicDelegationError("__new__ for " + o.getClass().getName() + " is a " + value.typename());
LuaFunction function = value.checkfunction();
LuaValue[] parameters = convertParamsToLua(o, objects);
function.invoke(parameters);
}
示例5: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue e, LuaValue base) {
if (base.isnil())
return e.tonumber();
final int b = base.checkint();
if (b < 2 || b > 36)
argerror(2, "base out of range");
return e.checkstring().tonumber(b);
}
示例6: read
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public int read() throws IOException {
if (remaining <= 0) {
LuaValue s = func.call();
if (s.isnil())
return -1;
LuaString ls = s.strvalue();
bytes = ls.m_bytes;
offset = ls.m_offset;
remaining = ls.m_length;
if (remaining <= 0)
return -1;
}
--remaining;
return bytes[offset++];
}
示例7: invoke
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs invoke(Varargs args) {
LuaString name = args.checkstring(1);
LuaValue val = package_.get(_PRELOAD).get(name);
return val.isnil()?
valueOf("\n\tno field package.preload['"+name+"']"):
val;
}
示例8: setHeader
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
* 調用Header函數
*
* @return
*/
public UDView setHeader(LuaValue header) {
final T lv = getView();
if (lv instanceof ILVListView) {
if (header instanceof UDView) {
mHeader = header;
((ILVListView) lv).addHeader(((UDView) header).getView());
} else if (header == null || header.isnil()) {
mHeader = NIL;
((ILVListView) lv).removeHeader();
}
}
return this;
}
示例9: setFooter
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
* 調用Header函數
*
* @return
*/
public UDView setFooter(LuaValue footer) {
final T lv = getView();
if (lv instanceof ILVListView) {
if (footer instanceof UDView) {
mFooter = footer;
((ILVListView) lv).addFooter(((UDView) footer).getView());
} else if (footer == null || footer.isnil()) {
mFooter = NIL;
((ILVListView) lv).removeFooter();
}
}
return this;
}
示例10: read
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public int read() throws IOException {
if ( remaining <= 0 ) {
LuaValue s = func.call();
if ( s.isnil() )
return -1;
LuaString ls = s.strvalue();
bytes = ls.m_bytes;
offset = ls.m_offset;
remaining = ls.m_length;
if (remaining <= 0)
return -1;
}
--remaining;
return bytes[offset++];
}
示例11: call
import org.luaj.vm2.LuaValue; //導入方法依賴的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;
}
示例12: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue arg) {
LuaValue h = arg.metatag(TOSTRING);
if (!h.isnil()) {
return h.call(arg);
}
LuaValue v = arg.tostring();
if (!v.isnil()) {
return v;
}
return valueOf(arg.tojstring());
}
示例13: _io_output
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs _io_output(LuaValue filename) {
outfile = filename.isnil()? output():
filename.isstring()? ioopenfile(FTYPE_NAMED, filename.checkjstring(),"w"):
checkfile(filename);
return outfile;
}
示例14: call
import org.luaj.vm2.LuaValue; //導入方法依賴的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;
}
}
示例15: _io_close
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs _io_close(LuaValue file) throws IOException {
File f = file.isnil()? output(): checkfile(file);
checkopen(f);
return ioclose(f);
}