Search in sources :

Example 11 with LuaError

use of org.luaj.vm2.LuaError in project LuaViewSDK by alibaba.

the class JavaInstance method set.

public void set(LuaValue key, LuaValue value) {
    if (jclass == null)
        jclass = JavaClass.forClass(m_instance.getClass());
    Field f = jclass.getField(key);
    if (f != null)
        try {
            f.set(m_instance, CoerceLuaToJava.coerce(value, f.getType()));
            return;
        } catch (Exception e) {
            throw new LuaError(e);
        }
    super.set(key, value);
}
Also used : Field(java.lang.reflect.Field) LuaError(org.luaj.vm2.LuaError)

Example 12 with LuaError

use of org.luaj.vm2.LuaError in project LuaViewSDK by alibaba.

the class JavaInstance method get.

public LuaValue get(LuaValue key) {
    if (jclass == null)
        jclass = JavaClass.forClass(m_instance.getClass());
    Field f = jclass.getField(key);
    if (f != null)
        try {
            return CoerceJavaToLua.coerce(f.get(m_instance));
        } catch (Exception e) {
            throw new LuaError(e);
        }
    LuaValue m = jclass.getMethod(key);
    if (m != null)
        return m;
    return super.get(key);
}
Also used : Field(java.lang.reflect.Field) LuaError(org.luaj.vm2.LuaError) LuaValue(org.luaj.vm2.LuaValue)

Aggregations

LuaError (org.luaj.vm2.LuaError)11 LuaTable (org.luaj.vm2.LuaTable)5 LuaValue (org.luaj.vm2.LuaValue)4 LibFunction (org.luaj.vm2.lib.LibFunction)3 Field (java.lang.reflect.Field)2 Nullable (android.support.annotation.Nullable)1 MotionEvent (android.view.MotionEvent)1 LoveVM (net.schattenkind.androidLove.LoveVM)1 LuaString (org.luaj.vm2.LuaString)1 LuaThread (org.luaj.vm2.LuaThread)1