org.luaj.vm2.LuaDouble Java Examples
The following examples show how to use
org.luaj.vm2.LuaDouble.
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: FuncState.java From XPrivacyLua with GNU General Public License v3.0 | 5 votes |
int numberK(LuaValue r) { if ( r instanceof LuaDouble ) { double d = r.todouble(); int i = (int) d; if ( d == (double) i ) r = LuaInteger.valueOf(i); } return this.addk(r); }
Example #2
Source File: FuncState.java From luaj with MIT License | 5 votes |
int numberK(LuaValue r) { if ( r instanceof LuaDouble ) { double d = r.todouble(); int i = (int) d; if ( d == (double) i ) r = LuaInteger.valueOf(i); } return this.addk(r); }
Example #3
Source File: MathLib.java From luaj with MIT License | 5 votes |
/** compute power using installed math library, or default if there is no math library installed */ public static LuaValue dpow(double a, double b) { return LuaDouble.valueOf( MATHLIB!=null? MATHLIB.dpow_lib(a,b): dpow_default(a,b) ); }
Example #4
Source File: MathLib.java From luaj with MIT License | 5 votes |
/** Perform one-time initialization on the library by creating a table * containing the library functions, adding that table to the supplied environment, * adding the table to package.loaded, and returning table as the return value. * @param modname the module name supplied if this is loaded via 'require'. * @param env the environment to load into, typically a Globals instance. */ public LuaValue call(LuaValue modname, LuaValue env) { LuaTable math = new LuaTable(0,30); math.set("abs", new abs()); math.set("ceil", new ceil()); math.set("cos", new cos()); math.set("deg", new deg()); math.set("exp", new exp(this)); math.set("floor", new floor()); math.set("fmod", new fmod()); math.set("frexp", new frexp()); math.set("huge", LuaDouble.POSINF ); math.set("ldexp", new ldexp()); math.set("max", new max()); math.set("min", new min()); math.set("modf", new modf()); math.set("pi", Math.PI ); math.set("pow", new pow()); random r; math.set("random", r = new random()); math.set("randomseed", new randomseed(r)); math.set("rad", new rad()); math.set("sin", new sin()); math.set("sqrt", new sqrt()); math.set("tan", new tan()); env.set("math", math); if (!env.get("package").isnil()) env.get("package").get("loaded").set("math", math); return math; }
Example #5
Source File: FuncState.java From HtmlNative with Apache License 2.0 | 5 votes |
int numberK(LuaValue r) { if ( r instanceof LuaDouble ) { double d = r.todouble(); int i = (int) d; if ( d == (double) i ) r = LuaInteger.valueOf(i); } return this.addk(r); }
Example #6
Source File: MathLib.java From HtmlNative with Apache License 2.0 | 5 votes |
/** compute power using installed math library, or default if there is no math library installed */ public static LuaValue dpow(double a, double b) { return LuaDouble.valueOf( MATHLIB!=null? MATHLIB.dpow_lib(a,b): dpow_default(a,b) ); }
Example #7
Source File: MathLib.java From HtmlNative with Apache License 2.0 | 5 votes |
/** Perform one-time initialization on the library by creating a table * containing the library functions, adding that table to the supplied environment, * adding the table to package.loaded, and returning table as the return value. * @param modname the module name supplied if this is loaded via 'require'. * @param env the environment to load into, typically a Globals instance. */ public LuaValue call(LuaValue modname, LuaValue env) { LuaTable math = new LuaTable(0,30); math.set("abs", new abs()); math.set("ceil", new ceil()); math.set("cos", new cos()); math.set("deg", new deg()); math.set("exp", new exp(this)); math.set("floor", new floor()); math.set("fmod", new fmod()); math.set("frexp", new frexp()); math.set("huge", LuaDouble.POSINF ); math.set("ldexp", new ldexp()); math.set("max", new max()); math.set("min", new min()); math.set("modf", new modf()); math.set("pi", Math.PI ); math.set("pow", new pow()); random r; math.set("random", r = new random()); math.set("randomseed", new randomseed(r)); math.set("rad", new rad()); math.set("sin", new sin()); math.set("sqrt", new sqrt()); math.set("tan", new tan()); env.set("math", math); env.get("package").get("loaded").set("math", math); return math; }
Example #8
Source File: MathLib.java From XPrivacyLua with GNU General Public License v3.0 | 5 votes |
/** compute power using installed math library, or default if there is no math library installed */ public static LuaValue dpow(double a, double b) { return LuaDouble.valueOf( MATHLIB!=null? MATHLIB.dpow_lib(a,b): dpow_default(a,b) ); }
Example #9
Source File: MathLib.java From XPrivacyLua with GNU General Public License v3.0 | 5 votes |
/** Perform one-time initialization on the library by creating a table * containing the library functions, adding that table to the supplied environment, * adding the table to package.loaded, and returning table as the return value. * @param modname the module name supplied if this is loaded via 'require'. * @param env the environment to load into, typically a Globals instance. */ public LuaValue call(LuaValue modname, LuaValue env) { LuaTable math = new LuaTable(0,30); math.set("abs", new abs()); math.set("ceil", new ceil()); math.set("cos", new cos()); math.set("deg", new deg()); math.set("exp", new exp(this)); math.set("floor", new floor()); math.set("fmod", new fmod()); math.set("frexp", new frexp()); math.set("huge", LuaDouble.POSINF ); math.set("ldexp", new ldexp()); math.set("max", new max()); math.set("min", new min()); math.set("modf", new modf()); math.set("pi", Math.PI ); math.set("pow", new pow()); random r; math.set("random", r = new random()); math.set("randomseed", new randomseed(r)); math.set("rad", new rad()); math.set("sin", new sin()); math.set("sqrt", new sqrt()); math.set("tan", new tan()); env.set("math", math); env.get("package").get("loaded").set("math", math); return math; }
Example #10
Source File: LuaUtil.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 5 votes |
/** * convert a table to map * * @param table * @return */ public static HashMap<String, String> toMap(LuaTable table) { if (table != null) { final HashMap<String, String> result = new HashMap<String, String>(); final LuaValue[] keys = table.keys(); for (LuaValue key : keys) { LuaValue luaValue = table.get(key); String value = null; if (luaValue.istable()) { value = JsonUtil.toString(luaValue); } else { if (luaValue instanceof LuaBoolean) { value = String.valueOf(luaValue.optboolean(false)); } else if (luaValue instanceof LuaInteger) { value = String.valueOf(luaValue.optint(0)); } else if (luaValue instanceof LuaDouble) { value = String.valueOf(luaValue.optdouble(0)); } else if (luaValue instanceof LuaString) { value = String.valueOf(luaValue.optstring(null)); } else { value = String.valueOf(luaValue); } } if (value != null) { result.put(key.optjstring(null), value); } } return result; } return null; }
Example #11
Source File: FuncState.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 5 votes |
int numberK(LuaValue r) { if ( r instanceof LuaDouble ) { double d = r.todouble(); int i = (int) d; if ( d == (double) i ) r = LuaInteger.valueOf(i); } return this.addk(r); }
Example #12
Source File: MathLib.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 5 votes |
/** compute power using installed math library, or default if there is no math library installed */ public static LuaValue dpow(double a, double b) { return LuaDouble.valueOf( MATHLIB!=null? MATHLIB.dpow_lib(a,b): dpow_default(a,b) ); }
Example #13
Source File: MathLib.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 5 votes |
public LuaValue call(LuaValue modname, LuaValue env) { LuaTable math = new LuaTable(0,30); math.set("abs", new abs()); math.set("ceil", new ceil()); math.set("cos", new cos()); math.set("deg", new deg()); math.set("exp", new exp(this)); math.set("floor", new floor()); math.set("fmod", new fmod()); math.set("frexp", new frexp()); math.set("huge", LuaDouble.POSINF ); math.set("ldexp", new ldexp()); math.set("max", new max()); math.set("min", new min()); math.set("modf", new modf()); math.set("pi", Math.PI ); math.set("pow", new pow()); random r; math.set("random", r = new random()); math.set("randomseed", new randomseed(r)); math.set("rad", new rad()); math.set("sin", new sin()); math.set("sqrt", new sqrt()); math.set("tan", new tan()); env.set("math", math); env.get("package").get("loaded").set("math", math); return math; }
Example #14
Source File: CoerceJavaToLua.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 4 votes |
public LuaValue coerce(Object javaValue) { Number n = (Number) javaValue; return LuaDouble.valueOf(n.doubleValue()); }
Example #15
Source File: CoerceJavaToLua.java From HtmlNative with Apache License 2.0 | 4 votes |
public LuaValue coerce( Object javaValue ) { Number n = (Number) javaValue; return LuaDouble.valueOf( n.doubleValue() ); }
Example #16
Source File: CoerceJavaToLua.java From XPrivacyLua with GNU General Public License v3.0 | 4 votes |
public LuaValue coerce( Object javaValue ) { Number n = (Number) javaValue; return LuaDouble.valueOf( n.doubleValue() ); }
Example #17
Source File: CoerceJavaToLua.java From luaj with MIT License | 4 votes |
public LuaValue coerce( Object javaValue ) { Number n = (Number) javaValue; return LuaDouble.valueOf( n.doubleValue() ); }