org.luaj.vm2.LuaValue Java Examples
The following examples show how to use
org.luaj.vm2.LuaValue.
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 Project: VideoOS-Android-SDK Author: VideoOS File: LVLoginPlugin.java License: GNU General Public License v3.0 | 6 votes |
@Override public Varargs invoke(Varargs args) { final int fixIndex = VenvyLVLibBinder.fixIndex(args); if (args.narg() > fixIndex) { if (mPlatform != null && mPlatform.getPlatformLoginInterface() != null) { Integer value = LuaUtil.getInt(args, fixIndex + 1); String currentUrl = LuaUtil.getString(args, fixIndex + 2); String ssid = LuaUtil.getString(args, fixIndex + 3); IPlatformLoginInterface.ScreenChangedInfo screenChanged = new IPlatformLoginInterface.ScreenChangedInfo(); screenChanged.url = currentUrl; screenChanged.ssid = ssid; screenChanged.screenType = value != null ? value : 1; mPlatform.getPlatformLoginInterface().screenChanged(screenChanged); } } return LuaValue.NIL; }
Example #2
Source Project: luaj Author: luaj File: LuajavaLib.java License: MIT License | 6 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); LuaValue func = lobj.get(name); if ( func.isnil() ) return null; boolean isvarargs = ((method.getModifiers() & METHOD_MODIFIERS_VARARGS) != 0); int n = args!=null? args.length: 0; LuaValue[] v; if ( isvarargs ) { Object o = args[--n]; int m = Array.getLength( o ); v = new LuaValue[n+m]; for ( int i=0; i<n; i++ ) v[i] = CoerceJavaToLua.coerce(args[i]); for ( int i=0; i<m; i++ ) v[i+n] = CoerceJavaToLua.coerce(Array.get(o,i)); } else { v = new LuaValue[n]; for ( int i=0; i<n; i++ ) v[i] = CoerceJavaToLua.coerce(args[i]); } LuaValue result = func.invoke(v).arg1(); return CoerceLuaToJava.coerce(result, method.getReturnType()); }
Example #3
Source Project: VideoOS-Android-SDK Author: VideoOS File: LuaUtil.java License: GNU General Public License v3.0 | 5 votes |
public static Varargs invokeFunction(LuaValue target, LuaValue arg1, LuaValue arg2) { try { return (target != null && target.isfunction()) ? target.invoke(arg1, arg2) : LuaValue.NIL; } catch (Exception e) { return LuaValue.NIL; } }
Example #4
Source Project: VideoOS-Android-SDK Author: VideoOS File: TimerMethodMapper.java License: GNU General Public License v3.0 | 5 votes |
/** * 启动延时 * * @param udTimer * @param varargs * @return */ @LuaViewApi(since = VmVersion.V_500) public LuaValue delay(U udTimer, Varargs varargs) { if (varargs.narg() > 1) { return setDelay(udTimer, varargs); } else { return getDelay(udTimer, varargs); } }
Example #5
Source Project: luaj Author: luaj File: DebugLib.java License: MIT License | 5 votes |
public Varargs invoke(Varargs args) { int a=1; LuaThread thread = args.isthread(a)? args.checkthread(a++): globals.running; int level = args.checkint(a++); int local = args.checkint(a++); LuaValue value = args.arg(a++); CallFrame f = callstack(thread).getCallFrame(level); return f != null? f.setLocal(local, value): NONE; }
Example #6
Source Project: luaj Author: luaj File: BaseLib.java License: MIT License | 5 votes |
public Varargs loadStream(InputStream is, String chunkname, String mode, LuaValue env) { try { if ( is == null ) return varargsOf(NIL, valueOf("not found: "+chunkname)); return globals.load(is, chunkname, mode, env); } catch (Exception e) { return varargsOf(NIL, valueOf(e.getMessage())); } }
Example #7
Source Project: HtmlNative Author: hsllany File: CoerceLuaToJava.java License: Apache License 2.0 | 5 votes |
public int score(LuaValue value) { switch ( value.type() ) { case LuaValue.TTABLE: return value.length()==0? 0: componentCoercion.score( value.get(1) ); case LuaValue.TUSERDATA: return inheritanceLevels( componentType, value.touserdata().getClass().getComponentType() ); case LuaValue.TNIL: return SCORE_NULL_VALUE; default: return SCORE_UNCOERCIBLE; } }
Example #8
Source Project: VideoOS-Android-SDK Author: VideoOS File: VenvyMqttMapper.java License: GNU General Public License v3.0 | 5 votes |
public LuaValue mqttCallback(U target, Varargs varargs) { final LuaFunction callback = varargs.optfunction(2, null); if (callback != null && callback.isfunction()) { return target.setMqttCallback(callback); } return LuaValue.NIL; }
Example #9
Source Project: XPrivacyLua Author: M66B File: IoLib.java License: GNU General Public License v3.0 | 5 votes |
public static LuaValue freadnumber(File f) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); freadchars(f," \t\r\n",null); freadchars(f,"-+",baos); //freadchars(f,"0",baos); //freadchars(f,"xX",baos); freadchars(f,"0123456789",baos); freadchars(f,".",baos); freadchars(f,"0123456789",baos); //freadchars(f,"eEfFgG",baos); // freadchars(f,"+-",baos); //freadchars(f,"0123456789",baos); String s = baos.toString(); return s.length()>0? valueOf( Double.parseDouble(s) ): NIL; }
Example #10
Source Project: VideoOS-Android-SDK Author: VideoOS File: LVReportPlugin.java License: GNU General Public License v3.0 | 5 votes |
@Override public Varargs invoke(Varargs args) { int fixIndex = VenvyLVLibBinder.fixIndex(args); if (args.narg() > fixIndex) { LuaValue messageValue = args.arg(fixIndex + 1);//key String message = VenvyLVLibBinder.luaValueToString(messageValue); if (TextUtils.isEmpty(message)) { return LuaValue.NIL; } int level = LuaUtil.getInt(args, fixIndex + 2) == null ? 0 : LuaUtil.getInt(args, fixIndex + 2); boolean needReport = LuaUtil.getBoolean(args, fixIndex + 3) == null ? true : false; switch (level) { case 0: VenvyLog.i(message); if (true) { Report.report(Report.ReportLevel.i, TAG, message); } break; case 1: VenvyLog.i(message); if (needReport) { Report.report(Report.ReportLevel.w, TAG, message); } break; default: VenvyLog.i(message); if (true) { Report.report(Report.ReportLevel.i, TAG, message); } break; } } return LuaValue.NIL; }
Example #11
Source Project: VideoOS-Android-SDK Author: VideoOS File: VenvyKeyboardMapper.java License: GNU General Public License v3.0 | 5 votes |
public LuaValue keyboardCallback(U target, Varargs varargs) { final LuaFunction callback = varargs.optfunction(2, null); if (callback != null && callback.isfunction()) { return target.setKeyboardCallback(callback); } return LuaValue.NIL; }
Example #12
Source Project: Cubes Author: ictrobot File: ReadOnlyLuaTable.java License: MIT License | 5 votes |
public ReadOnlyLuaTable(LuaValue table) { presize(table.length(), 0); for (Varargs n = table.next(LuaValue.NIL); !n.arg1().isnil(); n = table .next(n.arg1())) { LuaValue key = n.arg1(); LuaValue value = n.arg(2); super.rawset(key, value.istable() ? new ReadOnlyLuaTable(value) : value); } }
Example #13
Source Project: luaj Author: luaj File: BaseLib.java License: MIT License | 5 votes |
/** * Load from a named file, returning the chunk or nil,error of can't load * @param env * @param mode * @return Varargs containing chunk, or NIL,error-text on error */ public Varargs loadFile(String filename, String mode, LuaValue env) { InputStream is = globals.finder.findResource(filename); if ( is == null ) return varargsOf(NIL, valueOf("cannot open "+filename+": No such file or directory")); try { return loadStream(is, "@"+filename, mode, env); } finally { try { is.close(); } catch ( Exception e ) { e.printStackTrace(); } } }
Example #14
Source Project: VideoOS-Android-SDK Author: VideoOS File: UDBaseListOrRecyclerView.java License: GNU General Public License v3.0 | 5 votes |
/** * 调用 Callback 方法 * * @param cell * @param position * @return */ public LuaValue onCellClicked(LuaValue cell, int position) { int section = getSectionByPosition(position); int row = getRowInSectionByPosition(position); LuaValue cellData = getCell(getId(position, section, row)); if (cellData != null) { LuaValue callback = cellData.get("Callback"); if (callback.isfunction()) { return LuaUtil.callFunction(callback, cell, LuaUtil.toLuaInt(section), LuaUtil.toLuaInt(row)); } else if (callback.istable()) { return LuaUtil.callFunction(LuaUtil.getFunction(callback, "Click", "click"), cell, LuaUtil.toLuaInt(section), LuaUtil.toLuaInt(row)); } } return NIL; }
Example #15
Source Project: VideoOS-Android-SDK Author: VideoOS File: UIHorizontalScrollViewMethodMapper.java License: GNU General Public License v3.0 | 5 votes |
/** * 滚动一段距离 * * @param view * @param varargs * @return */ @Deprecated public LuaValue scrollBy(U view, Varargs varargs) { final int dx = DimenUtil.dpiToPx(varargs.arg(2)); ; final int dy = DimenUtil.dpiToPx(varargs.arg(3)); final boolean smooth = varargs.optboolean(4, false); if (smooth) { return view.smoothScrollBy(dx, dy); } else { return view.scrollBy(dx, dy); } }
Example #16
Source Project: VideoOS-Android-SDK Author: VideoOS File: VenvyNotificationMapper.java License: GNU General Public License v3.0 | 5 votes |
public LuaValue registerNotification(U target, Varargs args) { if (args.narg() > 0) { final String tag = LuaUtil.getString(args, 2); final LuaFunction callback = args.optfunction(3, null); if (TextUtils.isEmpty(tag)) { return LuaValue.NIL; } if (callback != null && callback.isfunction()) { return target.registerNotification(callback, tag); } } return LuaValue.NIL; }
Example #17
Source Project: VideoOS-Android-SDK Author: VideoOS File: LVDevicePlugin.java License: GNU General Public License v3.0 | 5 votes |
@Override public Varargs invoke(Varargs args) { if (mPlatform != null && mPlatform.getPlatformInfo() != null) { if (mPlatform.getPlatformInfo().getCustomerPackageName() != null) { return LuaValue.valueOf(mPlatform.getPlatformInfo().getCustomerPackageName()); } } return LuaValue.valueOf(VenvyDeviceUtil.getPackageName(App.getContext())); }
Example #18
Source Project: VideoOS-Android-SDK Author: VideoOS File: Bit32Lib.java License: GNU General Public License v3.0 | 5 votes |
static LuaValue lrotate(int x, int disp) { if (disp < 0) { return rrotate(x, -disp); } else { disp = disp & 31; return bitsToValue((x << disp) | (x >>> (32 - disp))); } }
Example #19
Source Project: VideoOS-Android-SDK Author: VideoOS File: TimerMethodMapper.java License: GNU General Public License v3.0 | 5 votes |
/** * 取消定时器 * * @param udTimer * @param varargs * @return */ public LuaValue callback(U udTimer, Varargs varargs) { if (varargs.narg() > 1) { return setCallback(udTimer, varargs); } else { return getCallback(udTimer, varargs); } }
Example #20
Source Project: luaj Author: luaj File: BaseLib.java License: MIT License | 5 votes |
public Varargs invoke(Varargs args) { LuaValue ld = args.arg1(); if (!ld.isstring() && !ld.isfunction()) { throw new LuaError("bad argument #1 to 'load' (string or function expected, got " + ld.typename() + ")"); } String source = args.optjstring(2, ld.isstring()? ld.tojstring(): "=(load)"); String mode = args.optjstring(3, "bt"); LuaValue env = args.optvalue(4, globals); return loadStream(ld.isstring()? ld.strvalue().toInputStream(): new StringInputStream(ld.checkfunction()), source, mode, env); }
Example #21
Source Project: VideoOS-Android-SDK Author: VideoOS File: JsonUtil.java License: GNU General Public License v3.0 | 5 votes |
/** * 将JSONObject转成LuaTable * * @param jsonString * @return */ public static LuaValue toLuaTable(String jsonString) { LuaValue luaTable = LuaValue.NIL; try { luaTable = toLuaTable(new JSONObject(jsonString)); } catch (Exception e) { try { luaTable = toLuaTable(new JSONArray(jsonString)); } catch (Exception ex1) { VenvyLog.e(JsonUtil.class.getName(), ex1); } } return luaTable; }
Example #22
Source Project: VideoOS-Android-SDK Author: VideoOS File: LVTextView.java License: GNU General Public License v3.0 | 5 votes |
public LVTextView(Globals globals, LuaValue metaTable, Varargs varargs) { super(globals.getContext()); this.mLuaUserdata = new UDTextView(this, globals, metaTable, varargs); this.setIncludeFontPadding(false);//设置默认TextView不包含字体的padding,否则adjustSize的时候拿到的高度有问题 this.setGravity(Gravity.CENTER_VERTICAL);//默认竖直居中 this.setLines(1);//默认一行 this.setTextSize(UDFontSize.FONTSIZE_SMALL); // this.setEllipsize(TextUtils.TruncateAt.END);//默认在最后有3个点 }
Example #23
Source Project: VideoOS-Android-SDK Author: VideoOS File: LVUrlPlugin.java License: GNU General Public License v3.0 | 5 votes |
@Override public LuaValue invoke(Varargs args) { int fixIndex = VenvyLVLibBinder.fixIndex(args); LuaValue target = args.arg(fixIndex + 1); //key String result = luaValueToString(target); return LuaValue.valueOf(VenvyBase64.encode(result.getBytes())); }
Example #24
Source Project: Cubes Author: ictrobot File: LuaConversion.java License: MIT License | 5 votes |
public static Object convertToJava(Class<?> c, LuaValue o) { if (o == null || o.isnil()) return null; LuaConverter luaConverter = converter(c); if (luaConverter == null) { if (o instanceof LuaObject) { luaConverter = map.get(Object.class); } else { throw new ConversionError("Cannot convert Lua to Java: " + c.getName()); } } return luaConverter.toJava(o, c); }
Example #25
Source Project: XPrivacyLua Author: M66B File: XLua.java License: GNU General Public License v3.0 | 5 votes |
LuaLocals(Globals globals) { this.presize(globals.length(), 0); Varargs entry = globals.next(LuaValue.NIL); while (!entry.arg1().isnil()) { LuaValue key = entry.arg1(); LuaValue value = entry.arg(2); super.rawset(key, value); entry = globals.next(entry.arg1()); } }
Example #26
Source Project: VideoOS-Android-SDK Author: VideoOS File: VenvyNotificationMapper.java License: GNU General Public License v3.0 | 5 votes |
public LuaValue postNotification(U target, Varargs args) { if (args.narg() > 0) { String tag = LuaUtil.getString(args, 2); if (TextUtils.isEmpty(tag)) { return LuaValue.NIL; } LuaTable table = LuaUtil.getTable(args, 3); Map<String, String> messageMap = LuaUtil.toMap(table); NotificationInfo info = new NotificationInfo(); info.messageInfo = messageMap; target.postNotification(tag, info); } return LuaValue.NIL; }
Example #27
Source Project: VideoOS-Android-SDK Author: VideoOS File: LVLoginPlugin.java License: GNU General Public License v3.0 | 5 votes |
@Override public Varargs invoke(Varargs args) { if (mPlatform != null && mPlatform.getPlatformLoginInterface() != null) { PlatformUserInfo platformUserInfo = mPlatform.getPlatformLoginInterface().getLoginUser(); if (platformUserInfo != null) { return JsonUtil.toLuaTable(platformUserInfo.toString()); } } return LuaValue.NIL; }
Example #28
Source Project: VideoOS-Android-SDK Author: VideoOS File: LexState.java License: GNU General Public License v3.0 | 5 votes |
boolean str2d(String str, SemInfo seminfo) { if (str.indexOf('n') >= 0 || str.indexOf('N') >= 0) seminfo.r = LuaValue.ZERO; else if (str.indexOf('x') >= 0 || str.indexOf('X') >= 0) seminfo.r = strx2number(str, seminfo); else seminfo.r = LuaValue.valueOf(Double.parseDouble(str.trim())); return true; }
Example #29
Source Project: VideoOS-Android-SDK Author: VideoOS File: LVCopyPlugin.java License: GNU General Public License v3.0 | 5 votes |
@Override public LuaValue invoke(Varargs args) { int fixIndex = VenvyLVLibBinder.fixIndex(args); LuaValue target = args.arg(fixIndex + 1); String copyStringToPasteBoard = luaValueToString(target); if (!TextUtils.isEmpty(copyStringToPasteBoard)) { ClipboardManager systemService = (ClipboardManager) App.getContext().getSystemService(Context.CLIPBOARD_SERVICE); systemService.setPrimaryClip(ClipData.newPlainText("text", copyStringToPasteBoard)); return LuaValue.NIL; } else { return LuaValue.NIL; } }
Example #30
Source Project: VideoOS-Android-SDK Author: VideoOS File: UIViewMethodMapper.java License: GNU General Public License v3.0 | 4 votes |
public LuaValue setInitParams(U view, Varargs varargs) { final LuaValue initParams = varargs.optvalue(2, NIL); return view.setInitParams(initParams); }