Java Code Examples for org.luaj.vm2.Varargs#optvalue()

The following examples show how to use org.luaj.vm2.Varargs#optvalue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UIViewGroupMethodMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 添加子类
 *
 * @param view
 * @param varargs
 * @return
 */
public LuaValue addView(U view, Varargs varargs) {
    final LuaValue luaValue = varargs.optvalue(2, null);
    if (luaValue instanceof UDView) {
        return view.addView((UDView) luaValue, varargs);
    }
    return view;
}
 
Example 2
Source File: BaseLib.java    From HtmlNative with Apache License 2.0 5 votes vote down vote up
public Varargs invoke(Varargs args) {
    LuaValue ld = args.arg1();
    args.argcheck(ld.isstring() || ld.isfunction(), 1, "ld must be string or function");
    String source = args.optjstring(2, ld.isstring() ? ld.tojstring() : "=(load)");
    String mode = args.optjstring(3, "bt");
    LuaValue env = args.optvalue(4, globals);
    return loadStream(ld.isstring() ? ld.strvalue().toInputStream() : new
            StringInputStream(ld.checkfunction()), source, mode, env);
}
 
Example 3
Source File: BaseLib.java    From luaj with MIT License 5 votes vote down vote up
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;
	String mode = args.optjstring(2, "bt");
	LuaValue env = args.optvalue(3, globals);
	return filename == null?
		loadStream( globals.STDIN, "=stdin", mode, env ):
		loadFile( filename, mode, env );
}
 
Example 4
Source File: BaseLib.java    From HtmlNative with Apache License 2.0 5 votes vote down vote up
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;
    String mode = args.optjstring(2, "bt");
    LuaValue env = args.optvalue(3, globals);
    return filename == null ? loadStream(globals.STDIN, "=stdin", mode, env) : loadFile
            (filename, mode, env);
}
 
Example 5
Source File: BaseLib.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
public Varargs invoke(Varargs args) {
    LuaValue ld = args.arg1();
    args.argcheck(ld.isstring() || ld.isfunction(), 1, "ld must be string or function");
    String source = args.optjstring(2, ld.isstring() ? ld.tojstring() : "=(load)");
    String mode = args.optjstring(3, "bt");
    LuaValue env = args.optvalue(4, globals);
    return loadStream(ld.isstring() ? ld.strvalue().toInputStream() :
            new StringInputStream(ld.checkfunction()), source, mode, env);
}
 
Example 6
Source File: BaseLib.java    From luaj with MIT License 5 votes vote down vote up
public Varargs invoke(Varargs args) {
	LuaValue ld = args.arg1();
	if (!ld.isstring() && !ld.isfunction()) {
		throw new LuaError("bad argument #1 to 'load' (string or function expected, got " + ld.typename() + ")");
	}
	String source = args.optjstring(2, ld.isstring()? ld.tojstring(): "=(load)");
	String mode = args.optjstring(3, "bt");
	LuaValue env = args.optvalue(4, globals);
	return loadStream(ld.isstring()? ld.strvalue().toInputStream():
		new StringInputStream(ld.checkfunction()), source, mode, env);
}
 
Example 7
Source File: BaseLib.java    From XPrivacyLua with GNU General Public License v3.0 5 votes vote down vote up
public Varargs invoke(Varargs args) {
	LuaValue ld = args.arg1();
	args.argcheck(ld.isstring() || ld.isfunction(), 1, "ld must be string or function");
	String source = args.optjstring(2, ld.isstring()? ld.tojstring(): "=(load)");
	String mode = args.optjstring(3, "bt");
	LuaValue env = args.optvalue(4, globals);
	return loadStream(ld.isstring()? ld.strvalue().toInputStream(): 
		new StringInputStream(ld.checkfunction()), source, mode, env);
}
 
Example 8
Source File: UIViewGroupMethodMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public LuaValue setOnShow(U view, Varargs varargs) {
    final LuaValue callbacks = varargs.optvalue(2, NIL);
    return view.setOnShowCallback(callbacks);
}
 
Example 9
Source File: UIViewGroupMethodMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public LuaValue setOnBack(U view, Varargs varargs) {
    final LuaValue callbacks = varargs.optvalue(2, NIL);
    return view.setOnBackCallback(callbacks);
}
 
Example 10
Source File: VenvyMediaLifeCycleMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public Varargs onMediaDefault(U target, Varargs varargs) {
    final LuaValue callback = varargs.optvalue(2, NIL);
    return target.setOnMediaDefault(callback);
}
 
Example 11
Source File: VenvyMediaLifeCycleMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public Varargs onMediaPlay(U target, Varargs varargs) {
    final LuaValue callback = varargs.optvalue(2, NIL);
    return target.setOnMediaPlay(callback);
}
 
Example 12
Source File: VenvyMediaLifeCycleMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public Varargs onMediaProgress(U target, Varargs varargs) {
    final LuaValue callback = varargs.optvalue(2, NIL);
    return target.setOnMediaProgress(callback);
}
 
Example 13
Source File: UIAnimatorMethodMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public LuaValue onStart(U udAnimator, Varargs varargs) {
    final LuaValue callback = varargs.optvalue(2, NIL);
    return udAnimator.setOnStartCallback(callback);
}
 
Example 14
Source File: VenvyMediaLifeCycleMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public Varargs onMediaPause(U target, Varargs varargs) {
    final LuaValue callback = varargs.optvalue(2, NIL);
    return target.setOnMediaPause(callback);
}
 
Example 15
Source File: VenvyMediaLifeCycleMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public Varargs onPlayerSize(U target, Varargs varargs) {
    final LuaValue callback = varargs.optvalue(2, NIL);
    return target.setOnPlayerSize(callback);
}
 
Example 16
Source File: UIAnimatorMethodMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public LuaValue onCancel(U udAnimator, Varargs varargs) {
    final LuaValue callback = varargs.optvalue(2, NIL);
    return udAnimator.setOnCancelCallback(callback);
}
 
Example 17
Source File: VenvyMediaLifeCycleMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public Varargs onMediaSeeking(U target, Varargs varargs) {
    final LuaValue callback = varargs.optvalue(2, NIL);
    return target.setOnMediaSeeking(callback);
}
 
Example 18
Source File: UIViewMethodMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public LuaValue setInitParams(U view, Varargs varargs) {
    final LuaValue initParams = varargs.optvalue(2, NIL);
    return view.setInitParams(initParams);
}
 
Example 19
Source File: VenvyActivityLifeCycleMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public Varargs onPagePause(U target, Varargs varargs) {
    final LuaValue callback = varargs.optvalue(2, NIL);
    return target.setOnActivityPause(callback);
}
 
Example 20
Source File: VenvyActivityLifeCycleMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public Varargs onPageDidAppear(U target, Varargs varargs) {
    final LuaValue callback = varargs.optvalue(2, NIL);
    return target.setOnActivityResume(callback);
}