當前位置: 首頁>>代碼示例>>Java>>正文


Java LuaValue.isfunction方法代碼示例

本文整理匯總了Java中org.luaj.vm2.LuaValue.isfunction方法的典型用法代碼示例。如果您正苦於以下問題:Java LuaValue.isfunction方法的具體用法?Java LuaValue.isfunction怎麽用?Java LuaValue.isfunction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.luaj.vm2.LuaValue的用法示例。


在下文中一共展示了LuaValue.isfunction方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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);
	}
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:17,代碼來源:LuaGeneration.java

示例2: onCellClicked

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
 * 調用 Callback 方法
 *
 * @param cell
 * @param position
 * @return
 */
public LuaValue onCellClicked(LuaValue cell, int position) {
    final int section = getSectionByPosition(position);
    final int row = getRowInSectionByPosition(position);
    final String id = getId(position, section, row);
    final LuaValue cellData = getCell(id);
    if (cellData != null) {
        final LuaValue callback = cellData.get("Callback");
        if (callback.isfunction()) {
            return LuaUtil.callFunction(callback, cell, LuaUtil.toLuaInt(section), LuaUtil.toLuaInt(row));
        } else if (callback.istable()) {
            return LuaUtil.callFunction(LuaUtil.getFunction(callback, "Click", "click"), cell, LuaUtil.toLuaInt(section), LuaUtil.toLuaInt(row));
        }
    }
    return NIL;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:23,代碼來源:UDBaseListOrRecyclerView.java

示例3: callFunction

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public static Varargs callFunction(LuaValue target, Object... objs) {
    if (target != null && target.isfunction()) {
        LuaValue[] args = null;
        if (objs != null && objs.length > 0) {
            args = new LuaValue[objs.length];

            for (int i = 0; i < objs.length; i++) {
                args[i] = CoerceJavaToLua.coerce(objs[i]);
            }
        }
        if (args != null) {
            return target.invoke(LuaValue.varargsOf(args));
        } else {
            return target.call();
        }
    }
    return LuaValue.NIL;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:19,代碼來源:LuaUtil.java

示例4: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public final LuaValue call(LuaValue arg1, LuaValue arg2) {
    if (!arg1.isnumber() || !arg2.isfunction()) {
        return LuaValue.FALSE;
    }

    // Queue up action for later
    new Thread(() -> {
        ClientAPIUtils.sleep(arg1.toint());
        arg2.invoke();
    }).start();

    return LuaValue.TRUE;
}
 
開發者ID:ImpactDevelopment,項目名稱:ClientAPI,代碼行數:15,代碼來源:time.java

示例5: 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);
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:13,代碼來源:LuaGeneration.java

示例6: invokeFunction

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
 * call lua function ( return multiple values)
 *
 * @param target
 * @return
 */
public static Varargs invokeFunction(LuaValue target) {
    try {
        return (target != null && target.isfunction()) ? target.invoke() : LuaValue.NIL;
    } catch (Exception e) {
        e.printStackTrace();
        return LuaValue.NIL;
    }
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:15,代碼來源:LuaUtil.java

示例7: getOrCallFunction

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
 * 調用方法或者直接取數據
 *
 * @param target
 * @return
 */
public static LuaValue getOrCallFunction(LuaValue target) {
    try {
        return (target != null && target.isfunction()) ? target.call() : target;
    } catch (Exception e) {
        e.printStackTrace();
        return LuaValue.NIL;
    }
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:15,代碼來源:LuaUtil.java

示例8: 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);
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:9,代碼來源:LuaGeneration.java

示例9: invoke

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs invoke(Varargs args) {
    int a = 1;
    LuaThread thread = args.isthread(a) ? args.checkthread(a++) : globals.running;
    LuaValue func = args.arg(a++);
    String what = args.optjstring(a++, "flnStu");
    DebugLib.CallStack callstack = callstack(thread);

    // find the stack info
    DebugLib.CallFrame frame;
    if (func.isnumber()) {
        frame = callstack.getCallFrame(func.toint());
        if (frame == null)
            return NONE;
        func = frame.f;
    } else if (func.isfunction()) {
        frame = callstack.findCallFrame(func);
    } else {
        return argerror(a - 2, "function or level");
    }

    // start a table
    DebugInfo ar = callstack.auxgetinfo(what, (LuaFunction) func, frame);
    LuaTable info = new LuaTable();
    if (what.indexOf('S') >= 0) {
        info.set(WHAT, LUA);
        info.set(SOURCE, valueOf(ar.source));
        info.set(SHORT_SRC, valueOf(ar.short_src));
        info.set(LINEDEFINED, valueOf(ar.linedefined));
        info.set(LASTLINEDEFINED, valueOf(ar.lastlinedefined));
    }
    if (what.indexOf('l') >= 0) {
        info.set(CURRENTLINE, valueOf(ar.currentline));
    }
    if (what.indexOf('u') >= 0) {
        info.set(NUPS, valueOf(ar.nups));
        info.set(NPARAMS, valueOf(ar.nparams));
        info.set(ISVARARG, ar.isvararg ? ONE : ZERO);
    }
    if (what.indexOf('n') >= 0) {
        info.set(NAME, LuaValue.valueOf(ar.name != null ? ar.name : "?"));
        info.set(NAMEWHAT, LuaValue.valueOf(ar.namewhat));
    }
    if (what.indexOf('t') >= 0) {
        info.set(ISTAILCALL, ZERO);
    }
    if (what.indexOf('L') >= 0) {
        LuaTable lines = new LuaTable();
        info.set(ACTIVELINES, lines);
        DebugLib.CallFrame cf;
        for (int l = 1; (cf = callstack.getCallFrame(l)) != null; ++l)
            if (cf.f == func)
                lines.insert(-1, valueOf(cf.currentline()));
    }
    if (what.indexOf('f') >= 0) {
        if (func != null)
            info.set(FUNC, func);
    }
    return info;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:60,代碼來源:DebugLib.java

示例10: invoke

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs invoke(Varargs args) {
	int a=1;
	LuaThread thread = args.isthread(a)? args.checkthread(a++): globals.running; 
	LuaValue func = args.arg(a++);
	String what = args.optjstring(a++, "flnStu");
	DebugLib.CallStack callstack = callstack(thread);

	// find the stack info
	DebugLib.CallFrame frame;
	if ( func.isnumber() ) {
		frame = callstack.getCallFrame(func.toint());
		if (frame == null)
			return NONE;
		func = frame.f;
	} else if ( func.isfunction() ) {
		frame = callstack.findCallFrame(func);
	} else {
		return argerror(a-2, "function or level");
	}

	// start a table
	DebugInfo ar = callstack.auxgetinfo(what, (LuaFunction) func, frame);
	LuaTable info = new LuaTable();
	if (what.indexOf('S') >= 0) {
		info.set(WHAT, LUA);
		info.set(SOURCE, valueOf(ar.source));
		info.set(SHORT_SRC, valueOf(ar.short_src));
		info.set(LINEDEFINED, valueOf(ar.linedefined));
		info.set(LASTLINEDEFINED, valueOf(ar.lastlinedefined));
	}
	if (what.indexOf('l') >= 0) {
		info.set( CURRENTLINE, valueOf(ar.currentline) );
	}
	if (what.indexOf('u') >= 0) {
		info.set(NUPS, valueOf(ar.nups));
		info.set(NPARAMS, valueOf(ar.nparams));
		info.set(ISVARARG, ar.isvararg? ONE: ZERO);
	}
	if (what.indexOf('n') >= 0) {
		info.set(NAME, LuaValue.valueOf(ar.name!=null? ar.name: "?"));
		info.set(NAMEWHAT, LuaValue.valueOf(ar.namewhat));
	}
	if (what.indexOf('t') >= 0) {
		info.set(ISTAILCALL, ZERO);
	}
	if (what.indexOf('L') >= 0) {
		LuaTable lines = new LuaTable();
		info.set(ACTIVELINES, lines);
		DebugLib.CallFrame cf;
		for (int l = 1; (cf=callstack.getCallFrame(l)) != null; ++l)
			if (cf.f == func)
				lines.insert(-1, valueOf(cf.currentline()));
	}
	if (what.indexOf('f') >= 0) {
		if (func != null)
			info.set( FUNC, func );
	}
	return info;
}
 
開發者ID:nekocode,項目名稱:Hubs,代碼行數:60,代碼來源:DebugLib.java


注:本文中的org.luaj.vm2.LuaValue.isfunction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。