org.luaj.vm2.lib.LibFunction Java Examples

The following examples show how to use org.luaj.vm2.lib.LibFunction. 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: LuaViewManager.java    From VideoOS-Android-SDK with GNU General Public License v3.0 6 votes vote down vote up
/**
 * bind lua functions using opcode
 *
 * @param factory
 * @param methods
 * @return
 */
public static LuaTable bind(Class<? extends LibFunction> factory, List<String> methods) {
    LuaTable env = new LuaTable();
    try {
        if (methods != null) {
            for (int i = 0; i < methods.size(); i++) {
                LibFunction f = factory.newInstance();
                f.opcode = i;
                f.method = null;
                f.name = methods.get(i);
                env.set(f.name, f);
            }
        }
    } catch (Exception e) {
        throw new LuaError("[Bind Failed] " + e);
    } finally {
        return env;
    }
}
 
Example #2
Source File: LuaViewManager.java    From VideoOS-Android-SDK with GNU General Public License v3.0 6 votes vote down vote up
/**
 * create metatable for libs
 *
 * @return
 */
public static LuaTable createMetatable(Class<? extends LibFunction> libClass) {
    LuaTable result = AppCache.getCache(AppCache.CACHE_METATABLES).get(libClass);//get from cache

    if (result == null) {
        LuaTable libTable = null;
        if (LuaViewConfig.isUseNoReflection()) {
            List<String> methodNames = getMapperMethodNames(libClass);
            libTable = LuaViewManager.bind(libClass, methodNames);
        } else {
            List<Method> methods = getMapperMethods(libClass);
            libTable = LuaViewManager.bindMethods(libClass, methods);
        }
        result = LuaValue.tableOf(new LuaValue[]{LuaValue.INDEX, libTable, LuaValue.NEWINDEX, new NewIndexFunction(libTable)});

        //update cache
        AppCache.getCache(AppCache.CACHE_METATABLES).put(libClass, result);
    }
    return result;
}
 
Example #3
Source File: LuaViewManager.java    From VideoOS-Android-SDK with GNU General Public License v3.0 6 votes vote down vote up
/**
 * bind lua functions using method
 *
 * @param factory
 * @param methods
 * @return
 */
public static LuaTable bindMethods(Class<? extends LibFunction> factory, List<Method> methods) {
    LuaTable env = new LuaTable();
    try {
        if (methods != null) {
            for (int i = 0; i < methods.size(); i++) {
                LibFunction f = factory.newInstance();
                f.opcode = -1;
                f.method = methods.get(i);
                f.name = methods.get(i).getName();
                env.set(f.name, f);
            }
        }
    } catch (Exception e) {
        throw new LuaError("[Bind Failed] " + e);
    } finally {
        return env;
    }
}
 
Example #4
Source File: BaseFunctionBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
private LuaValue call(LuaValue env, Class<? extends LibFunction> libClass) {
     LuaTable metatable = (libClass == null || !LuaViewConfig.isLibsLazyLoad()) ? LuaViewManager.createMetatable(libClass) : null;//当不是lazyLoad或者lib为空(常量)的时候直接加载
    if (luaNames != null) {
        for (String name : luaNames) {
            env.set(name, createCreator(env, metatable));
        }
    }
    return metatable;
}
 
Example #5
Source File: AlignBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return null;
}
 
Example #6
Source File: UIListViewBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return UIListViewMethodMapper.class;
}
 
Example #7
Source File: ViewEffectBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return null;
}
 
Example #8
Source File: FontStyleBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return null;
}
 
Example #9
Source File: TouchEventBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return null;
}
 
Example #10
Source File: TextAlignBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return null;
}
 
Example #11
Source File: GravityBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return null;
}
 
Example #12
Source File: FontWeightBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return null;
}
 
Example #13
Source File: EllipsizeBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return null;
}
 
Example #14
Source File: InterpolatorBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return null;
}
 
Example #15
Source File: PinnedBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return null;
}
 
Example #16
Source File: ScaleTypeBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return null;
}
 
Example #17
Source File: VenvyMediaLifeCycleBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return VenvyMediaLifeCycleMapper.class;
}
 
Example #18
Source File: OrientationBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return null;
}
 
Example #19
Source File: VenvyNativeBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return VenvyNativeBinder.class;
}
 
Example #20
Source File: VenvyMediaViewBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return VenvyMediaPlayerMethodMapper.class;
}
 
Example #21
Source File: VenvyKeyboardBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return VenvyKeyboardMapper.class;
}
 
Example #22
Source File: VenvyHttpRequestBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return VenvyHttpRequestMapper.class;
}
 
Example #23
Source File: VenvyAppletBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return null;
}
 
Example #24
Source File: VenvyMqttBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return VenvyMqttMapper.class;
}
 
Example #25
Source File: VenvySvgaBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return VenvyUISvgaImageViewMapper.class;
}
 
Example #26
Source File: VenvyAcrCloudBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return VenvyAcrCloudMapper.class;
}
 
Example #27
Source File: UIGradientViewBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return UIGradientMethodMapper.class;
}
 
Example #28
Source File: VenvyWebViewBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return LVWebViewMethodMapper.class;
}
 
Example #29
Source File: VenvyNotificationBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return VenvyNotificationMapper.class;
}
 
Example #30
Source File: VenvyActivityLifeCycleBinder.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends LibFunction> getMapperClass() {
    return VenvyActivityLifeCycleMapper.class;
}