Java Code Examples for org.luaj.vm2.LuaValue#TRUE

The following examples show how to use org.luaj.vm2.LuaValue#TRUE . 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: BaseLib.java    From VideoOS-Android-SDK with GNU General Public License v3.0 6 votes vote down vote up
public Varargs invoke(Varargs args) {
    String s = args.checkjstring(1);
    if ("collect".equals(s)) {
        System.gc();
        return ZERO;
    } else if ("count".equals(s)) {
        Runtime rt = Runtime.getRuntime();
        long used = rt.totalMemory() - rt.freeMemory();
        return varargsOf(valueOf(used / 1024.), valueOf(used % 1024));
    } else if ("step".equals(s)) {
        System.gc();
        return LuaValue.TRUE;
    } else {
        this.argerror("gc op");
    }
    return NIL;
}
 
Example 2
Source File: BaseLib.java    From HtmlNative with Apache License 2.0 6 votes vote down vote up
public Varargs invoke(Varargs args) {
    String s = args.optjstring(1, "collect");
    if ("collect".equals(s)) {
        System.gc();
        return ZERO;
    } else if ("count".equals(s)) {
        Runtime rt = Runtime.getRuntime();
        long used = rt.totalMemory() - rt.freeMemory();
        return varargsOf(valueOf(used / 1024.), valueOf(used % 1024));
    } else if ("step".equals(s)) {
        System.gc();
        return LuaValue.TRUE;
    } else {
        this.argerror("gc op");
    }
    return NIL;
}
 
Example 3
Source File: UIViewMethodMapper.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 cornerRadii(U view, Varargs varargs) {
    if (varargs.narg() > 1) {
        return setCornerRadii(view, varargs);
    } else {
        return LuaValue.TRUE;
    }
}
 
Example 4
Source File: LVVideoPlugin.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Varargs invoke(Varargs args) {
    final int fixIndex = VenvyLVLibBinder.fixIndex(args);
    Integer type = LuaUtil.getInt(args, fixIndex + 1);
    if (type != null) {
        DebugStatus.EnvironmentStatus status = DebugStatus.EnvironmentStatus.getStatusByIntType(type);
        DebugStatus.changeEnvironmentStatus(status);
    }
    return LuaValue.TRUE;
}
 
Example 5
Source File: IoLib.java    From luaj with MIT License 5 votes vote down vote up
public Varargs _file_setvbuf(LuaValue file, String mode, int size) {
	if ("no".equals(mode)) {
	} else if ("full".equals(mode)) {
	} else if ("line".equals(mode)) {
	} else {
		argerror(1, "invalid value: '" + mode + "'; must be one of 'no', 'full' or 'line'");
	}
	checkfile(file).setvbuf(mode,size);
	return LuaValue.TRUE;
}
 
Example 6
Source File: JsonStorage.java    From Lukkit with MIT License 5 votes vote down vote up
@Override
public LuaBoolean setDefaultValue(LuaString path, LuaValue value) throws StorageObjectException {
    if (object.has(path.checkjstring())) {
        setValue(path, value);
        return LuaValue.TRUE;
    }
    return LuaValue.FALSE;
}
 
Example 7
Source File: JsonStorage.java    From Lukkit with MIT License 5 votes vote down vote up
@Override
protected LuaBoolean clearVaule(LuaString path) throws StorageObjectException {
    if (object.has(path.checkjstring())) {
        object.remove(path.checkjstring());
        return LuaValue.TRUE;
    }
    return LuaValue.FALSE;
}
 
Example 8
Source File: YamlStorage.java    From Lukkit with MIT License 5 votes vote down vote up
@Override
public LuaBoolean setDefaultValue(LuaString path, LuaValue value) throws StorageObjectException {
    if (this.yamlConfiguration.get(path.checkjstring()) == null) {
        this.yamlConfiguration.set(path.checkjstring(), Utilities.getObjectFromLuavalue(value));
        return LuaValue.TRUE;
    }

    return LuaValue.FALSE;
}
 
Example 9
Source File: CoerceJavaToLua.java    From HtmlNative with Apache License 2.0 4 votes vote down vote up
public LuaValue coerce( Object javaValue ) {
	Boolean b = (Boolean) javaValue;
	return b.booleanValue()? LuaValue.TRUE: LuaValue.FALSE;
}
 
Example 10
Source File: CoerceJavaToLua.java    From luaj with MIT License 4 votes vote down vote up
public LuaValue coerce( Object javaValue ) {
	Boolean b = (Boolean) javaValue;
	return b.booleanValue()? LuaValue.TRUE: LuaValue.FALSE;
}
 
Example 11
Source File: IoLib.java    From HtmlNative with Apache License 2.0 4 votes vote down vote up
public Varargs _file_setvbuf(LuaValue file, String mode, int size) {
	checkfile(file).setvbuf(mode,size);
	return LuaValue.TRUE;
}
 
Example 12
Source File: IoLib.java    From HtmlNative with Apache License 2.0 4 votes vote down vote up
public Varargs _file_flush(LuaValue file) throws IOException {
	checkfile(file).flush();
	return LuaValue.TRUE;
}
 
Example 13
Source File: IoLib.java    From HtmlNative with Apache License 2.0 4 votes vote down vote up
public Varargs _io_flush() throws IOException {
	checkopen(output());
	outfile.flush();
	return LuaValue.TRUE;
}
 
Example 14
Source File: JsonStorage.java    From Lukkit with MIT License 4 votes vote down vote up
@Override
protected LuaBoolean exists(String path) {
    return object.has(path) ? LuaValue.TRUE : LuaValue.FALSE;
}
 
Example 15
Source File: IoLib.java    From XPrivacyLua with GNU General Public License v3.0 4 votes vote down vote up
public Varargs _file_flush(LuaValue file) throws IOException {
	checkfile(file).flush();
	return LuaValue.TRUE;
}
 
Example 16
Source File: IoLib.java    From XPrivacyLua with GNU General Public License v3.0 4 votes vote down vote up
public Varargs _io_flush() throws IOException {
	checkopen(output());
	outfile.flush();
	return LuaValue.TRUE;
}
 
Example 17
Source File: VenvyAcrCloudMapper.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public LuaValue acrEnable(U target, Varargs args) {
    return target.acrEnable() ? LuaValue.TRUE : LuaValue.FALSE;
}
 
Example 18
Source File: YamlStorage.java    From Lukkit with MIT License 4 votes vote down vote up
@Override
protected LuaBoolean exists(String path) {
    return yamlConfiguration.get(path) != null ? LuaValue.TRUE : LuaValue.FALSE;
}
 
Example 19
Source File: IoLib.java    From luaj with MIT License 4 votes vote down vote up
public Varargs _file_flush(LuaValue file) throws IOException {
	checkfile(file).flush();
	return LuaValue.TRUE;
}
 
Example 20
Source File: LVEventPlugin.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
        public Varargs invoke(Varargs args) {
            final int fixIndex = VenvyLVLibBinder.fixIndex(args);
            if (mPlatform == null || mPlatform.getContentViewGroup() == null) {
                return LuaValue.FALSE;
            }
            if (args.narg() > fixIndex) {
                final String urlString = LuaUtil.getString(args, fixIndex + 1);
                final LuaTable table = LuaUtil.getTable(args, fixIndex + 2);
                if (TextUtils.isEmpty(urlString)) {
                    return LuaValue.FALSE;
                }
                Uri uri = Uri.parse(new String(VenvyBase64.decode(urlString)));
                PostInfo info = VenvyRouterManager.getInstance().setUri(uri);
                Set<String> params = uri.getQueryParameterNames();
                HashMap<String, String> map = new HashMap<>();
                if (table != null) {
                    map.put("data", JsonUtil.toString(table));
                }
                if (params != null && params.size() > 0) {
                    for (String key : params) {
                        String value = uri.getQueryParameter(key);
                        if (!TextUtils.isEmpty(value)) {
                            map.put(key, value);
                        }
                    }
                }
                if(!map.keySet().contains("miniAppId")){
                    // 如果过来的uri中不带miniAppId,则需要尝试去table中找miniAppId put进 map里
                    try {
                        JSONObject jsonObject = new JSONObject(JsonUtil.toString(table));
                        JSONObject miniAppInfo = jsonObject.optJSONObject("miniAppInfo");
                        if(miniAppInfo != null){
                            String miniAppId = miniAppInfo.optString("miniAppId");
                            if(!TextUtils.isEmpty(miniAppId)){
                                map.put("miniAppId",miniAppId);
                            }
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }

                if (map.size() > 0) {
                    info.withSerializable("data", map);
                }
                String protocolHost = uri.getHost();
                if (protocolHost.equalsIgnoreCase("defaultLuaView")) {
                    // A类容器内部跳转
                    info.withTargetViewParent(mPlatform.getContentViewGroup()).withTargetPlatform("platform", mPlatform).navigation();

                } else if (protocolHost.equalsIgnoreCase("topLuaView")) {
                    // 标签小程序 - [top level]
//                    Bundle bundle = new Bundle();
//                    bundle.putString(VenvyObservableTarget.Constant.CONSTANT_LUA_NAME, info.getBundle().getString("template"));
//                    bundle.putString(VenvyObservableTarget.Constant.CONSTANT_ID, info.getBundle().getString("id"));
                    ObservableManager.getDefaultObserable().sendToTarget(VenvyObservableTarget.TAG_ADD_LUA_SCRIPT_TO_TOP_LEVEL, info.getBundle());

                } else if (protocolHost.equalsIgnoreCase("applets")) {
                    String type = info.getBundle().getString("type");
                    String appType = info.getBundle().getString("appType");
                    if (TextUtils.isEmpty(appType)) {
                        VenvyLog.d("appType is null");
                        // appType为空默认指定为lua
                        appType = String.valueOf(VenvyObservableTarget.Constant.CONSTANT_APP_TYPE_LUA);
                    }
                    VenvyLog.d("type is " + type + " , appType is " + appType);
                    if (TextUtils.isEmpty(type)) {
                        // B类小程序内部跳转
                        info.withTargetViewParent(mPlatform.getContentViewGroup()).withTargetPlatform("platform", mPlatform).navigation();
                        ObservableManager.getDefaultObserable().sendToTarget(VenvyObservableTarget.TAG_ADD_LUA_SCRIPT_TO_VISION_PROGRAM, null);

                    } else {
                        // 发起一个视联网小程序
                        Bundle bundle = new Bundle();
                        bundle.putString(VenvyObservableTarget.KEY_APPLETS_ID, info.getBundle().getString("appletId"));
                        bundle.putString(VenvyObservableTarget.KEY_ORIENTATION_TYPE, type);
                        bundle.putString(VenvyObservableTarget.Constant.CONSTANT_APP_TYPE, appType);
                        if (table != null) {
                            bundle.putString(VenvyObservableTarget.Constant.CONSTANT_DATA, JsonUtil.toString(table));
                        }
                        ObservableManager.getDefaultObserable().sendToTarget(VenvyObservableTarget.TAG_LAUNCH_VISION_PROGRAM, bundle);
                    }


                }
                return LuaValue.TRUE;
            }
            return LuaValue.FALSE;
        }