Java Code Examples for org.luaj.vm2.LuaValue#error()

The following examples show how to use org.luaj.vm2.LuaValue#error() . 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: JavaMethod.java    From VideoOS-Android-SDK with GNU General Public License v3.0 6 votes vote down vote up
private LuaValue invokeBestMethod(Object instance, Varargs args) {
    JavaMethod best = null;
    int score = CoerceLuaToJava.SCORE_UNCOERCIBLE;
    for (int i = 0; i < methods.length; i++) {
        int s = methods[i].score(args);
        if (s < score) {
            score = s;
            best = methods[i];
            if (score == 0)
                break;
        }
    }

    // any match?
    if (best == null)
        LuaValue.error("no coercible public method");

    // invoke it
    return best.invokeMethod(instance, args);
}
 
Example 2
Source File: JavaConstructor.java    From VideoOS-Android-SDK with GNU General Public License v3.0 6 votes vote down vote up
public Varargs invoke(Varargs args) {
    JavaConstructor best = null;
    int score = CoerceLuaToJava.SCORE_UNCOERCIBLE;
    for (int i = 0; i < constructors.length; i++) {
        int s = constructors[i].score(args);
        if (s < score) {
            score = s;
            best = constructors[i];
            if (score == 0)
                break;
        }
    }

    // any match?
    if (best == null)
        LuaValue.error("no coercible public method");

    // invoke it
    return best.invoke(args);
}
 
Example 3
Source File: JavaMethod.java    From XPrivacyLua with GNU General Public License v3.0 6 votes vote down vote up
private LuaValue invokeBestMethod(Object instance, Varargs args) {
	JavaMethod best = null;
	int score = CoerceLuaToJava.SCORE_UNCOERCIBLE;
	for ( int i=0; i<methods.length; i++ ) {
		int s = methods[i].score(args);
		if ( s < score ) {
			score = s;
			best = methods[i];
			if ( score == 0 )
				break;
		}
	}
	
	// any match? 
	if ( best == null )
		LuaValue.error("no coercible public method");
	
	// invoke it
	return best.invokeMethod(instance, args);
}
 
Example 4
Source File: JavaConstructor.java    From XPrivacyLua with GNU General Public License v3.0 6 votes vote down vote up
public Varargs invoke(Varargs args) {
	JavaConstructor best = null;
	int score = CoerceLuaToJava.SCORE_UNCOERCIBLE;
	for ( int i=0; i<constructors.length; i++ ) {
		int s = constructors[i].score(args);
		if ( s < score ) {
			score = s;
			best = constructors[i];
			if ( score == 0 )
				break;
		}
	}
	
	// any match? 
	if ( best == null )
		LuaValue.error("no coercible public method");
	
	// invoke it
	return best.invoke(args);
}
 
Example 5
Source File: JavaMethod.java    From HtmlNative with Apache License 2.0 6 votes vote down vote up
private LuaValue invokeBestMethod(Object instance, Varargs args) {
	JavaMethod best = null;
	int score = CoerceLuaToJava.SCORE_UNCOERCIBLE;
	for ( int i=0; i<methods.length; i++ ) {
		int s = methods[i].score(args);
		if ( s < score ) {
			score = s;
			best = methods[i];
			if ( score == 0 )
				break;
		}
	}
	
	// any match? 
	if ( best == null )
		LuaValue.error("no coercible public method");
	
	// invoke it
	return best.invokeMethod(instance, args);
}
 
Example 6
Source File: JavaConstructor.java    From HtmlNative with Apache License 2.0 6 votes vote down vote up
public Varargs invoke(Varargs args) {
	JavaConstructor best = null;
	int score = CoerceLuaToJava.SCORE_UNCOERCIBLE;
	for ( int i=0; i<constructors.length; i++ ) {
		int s = constructors[i].score(args);
		if ( s < score ) {
			score = s;
			best = constructors[i];
			if ( score == 0 )
				break;
		}
	}
	
	// any match? 
	if ( best == null )
		LuaValue.error("no coercible public method");
	
	// invoke it
	return best.invoke(args);
}
 
Example 7
Source File: JavaMethod.java    From luaj with MIT License 6 votes vote down vote up
private LuaValue invokeBestMethod(Object instance, Varargs args) {
	JavaMethod best = null;
	int score = CoerceLuaToJava.SCORE_UNCOERCIBLE;
	for ( int i=0; i<methods.length; i++ ) {
		int s = methods[i].score(args);
		if ( s < score ) {
			score = s;
			best = methods[i];
			if ( score == 0 )
				break;
		}
	}
	
	// any match? 
	if ( best == null )
		LuaValue.error("no coercible public method");
	
	// invoke it
	return best.invokeMethod(instance, args);
}
 
Example 8
Source File: JavaConstructor.java    From luaj with MIT License 6 votes vote down vote up
public Varargs invoke(Varargs args) {
	JavaConstructor best = null;
	int score = CoerceLuaToJava.SCORE_UNCOERCIBLE;
	for ( int i=0; i<constructors.length; i++ ) {
		int s = constructors[i].score(args);
		if ( s < score ) {
			score = s;
			best = constructors[i];
			if ( score == 0 )
				break;
		}
	}
	
	// any match? 
	if ( best == null )
		LuaValue.error("no coercible public method");
	
	// invoke it
	return best.invoke(args);
}