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

The following examples show how to use org.luaj.vm2.LuaValue#optuserdata() . 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: CoerceLuaToJava.java    From VideoOS-Android-SDK with GNU General Public License v3.0 6 votes vote down vote up
public Object coerce(LuaValue value) {
    switch (value.type()) {
        case LuaValue.TNUMBER:
            return value.isint() ? (Object) new Integer(value.toint()) : (Object) new Double(value.todouble());
        case LuaValue.TBOOLEAN:
            return value.toboolean() ? Boolean.TRUE : Boolean.FALSE;
        case LuaValue.TSTRING:
            return value.tojstring();
        case LuaValue.TUSERDATA:
            return value.optuserdata(targetType, null);
        case LuaValue.TNIL:
            return null;
        default:
            return value;
    }
}
 
Example 2
Source File: CoerceLuaToJava.java    From XPrivacyLua with GNU General Public License v3.0 6 votes vote down vote up
public Object coerce(LuaValue value) {
	switch ( value.type() ) {
	case LuaValue.TNUMBER:
		return value.isint()? (Object)new Integer(value.toint()): (Object)new Double(value.todouble());
	case LuaValue.TBOOLEAN:
		return value.toboolean()? Boolean.TRUE: Boolean.FALSE;
	case LuaValue.TSTRING:
		return value.tojstring();
	case LuaValue.TUSERDATA:
		return value.optuserdata(targetType, null);
	case LuaValue.TNIL:
		return null;
	default:
		return value;
	}
}
 
Example 3
Source File: CoerceLuaToJava.java    From HtmlNative with Apache License 2.0 6 votes vote down vote up
public Object coerce(LuaValue value) {
	switch ( value.type() ) {
	case LuaValue.TNUMBER:
		return value.isint()? (Object)new Integer(value.toint()): (Object)new Double(value.todouble());
	case LuaValue.TBOOLEAN:
		return value.toboolean()? Boolean.TRUE: Boolean.FALSE;
	case LuaValue.TSTRING:
		return value.tojstring();
	case LuaValue.TUSERDATA:
		return value.optuserdata(targetType, null);
	case LuaValue.TNIL:
		return null;
	default:
		return value;
	}
}
 
Example 4
Source File: CoerceLuaToJava.java    From luaj with MIT License 6 votes vote down vote up
public Object coerce(LuaValue value) {
	switch ( value.type() ) {
	case LuaValue.TNUMBER:
		return value.isint()? (Object)new Integer(value.toint()): (Object)new Double(value.todouble());
	case LuaValue.TBOOLEAN:
		return value.toboolean()? Boolean.TRUE: Boolean.FALSE;
	case LuaValue.TSTRING:
		return value.tojstring();
	case LuaValue.TUSERDATA:
		return value.optuserdata(targetType, null);
	case LuaValue.TNIL:
		return null;
	default:
		return value;
	}
}