/** Construct a {@link LuaTable} initialized with supplied array values. * @param varargs {@link Varargs} containing the values to use in initialization * @param firstarg the index of the first argument to use from the varargs, 1 being the first. * @return new {@link LuaTable} instance with sequential elements coming from the varargs. */ public static LuaTable tableOf(Varargs varargs, int firstarg) { return new LuaTable(varargs,firstarg); }
/** Construct a {@link LuaTable} initialized with supplied array values. * @param unnamedValues array of {@link LuaValue} containing the values to use in initialization * @return new {@link LuaTable} instance with sequential elements coming from the array. */ public static LuaTable listOf(LuaValue[] unnamedValues) { return new LuaTable(null,unnamedValues,null); }
/** Construct a {@link LuaTable} initialized with supplied named values and sequential elements. * The named values will be assigned first, and the sequential elements will be assigned later, * possibly overwriting named values at the same slot if there are conflicts. * @param namedValues array of {@link LuaValue} containing the keys and values to use in initialization * in order {@code {key-a, value-a, key-b, value-b, ...} } * @param unnamedValues array of {@link LuaValue} containing the sequenctial elements to use in initialization * in order {@code {value-1, value-2, ...} }, or null if there are none * @return new {@link LuaTable} instance with named and sequential values supplied. */ public static LuaTable tableOf(LuaValue[] namedValues, LuaValue[] unnamedValues) {return new LuaTable(namedValues,unnamedValues,null); }
/** Construct a {@link LuaTable} initialized with supplied array values. * @param unnamedValues array of {@link LuaValue} containing the first values to use in initialization * @param lastarg {@link Varargs} containing additional values to use in initialization * to be put after the last unnamedValues element * @return new {@link LuaTable} instance with sequential elements coming from the array and varargs. */ public static LuaTable listOf(LuaValue[] unnamedValues,Varargs lastarg) { return new LuaTable(null,unnamedValues,lastarg); }
/** Construct an empty {@link LuaTable} preallocated to hold array and hashed elements * @param narray Number of array elements to preallocate * @param nhash Number of hash elements to preallocate * @return new {@link LuaTable} instance with no values and no metatable, but preallocated for array and hashed elements. */ public static LuaTable tableOf(int narray, int nhash) { return new LuaTable(narray, nhash); }
/** Construct a {@link LuaTable} initialized with supplied array values. * @param unnamedValues array of {@link LuaValue} containing the first values to use in initialization * @param lastarg {@link Varargs} containing additional values to use in initialization * to be put after the last unnamedValues element * @return new {@link LuaTable} instance with sequential elements coming from the array and varargs. */ public static LuaTable listOf(LuaValue[] unnamedValues,Varargs lastarg) { return new LuaTable(null,unnamedValues,lastarg); }
/** Construct a {@link LuaTable} initialized with supplied named values and sequential elements in an array part and as varargs. * The named values will be assigned first, and the sequential elements will be assigned later, * possibly overwriting named values at the same slot if there are conflicts. * @param namedValues array of {@link LuaValue} containing the keys and values to use in initialization * in order {@code {key-a, value-a, key-b, value-b, ...} } * @param unnamedValues array of {@link LuaValue} containing the first sequenctial elements to use in initialization * in order {@code {value-1, value-2, ...} }, or null if there are none * @param lastarg {@link Varargs} containing additional values to use in the sequential part of the initialization, * to be put after the last unnamedValues element * @return new {@link LuaTable} instance with named and sequential values supplied. */ public static LuaTable tableOf(LuaValue[] namedValues, LuaValue[] unnamedValues, Varargs lastarg) {return new LuaTable(namedValues,unnamedValues,lastarg); }
/** Construct a {@link LuaTable} initialized with supplied named values. * @param namedValues array of {@link LuaValue} containing the keys and values to use in initialization * in order {@code {key-a, value-a, key-b, value-b, ...} } * @return new {@link LuaTable} instance with non-sequential keys coming from the supplied array. */ public static LuaTable tableOf(LuaValue[] namedValues) { return new LuaTable(namedValues,null,null); }
/** Construct a {@link LuaTable} initialized with supplied named values and sequential elements in an array part and as varargs. * The named values will be assigned first, and the sequential elements will be assigned later, * possibly overwriting named values at the same slot if there are conflicts. * @param namedValues array of {@link LuaValue} containing the keys and values to use in initialization * in order {@code {key-a, value-a, key-b, value-b, ...} } * @param unnamedValues array of {@link LuaValue} containing the first sequenctial elements to use in initialization * in order {@code {value-1, value-2, ...} }, or null if there are none * @param lastarg {@link Varargs} containing additional values to use in the sequential part of the initialization, * to be put after the last unnamedValues element * @return new {@link LuaTable} instance with named and sequential values supplied. */ public static LuaTable tableOf(LuaValue[] namedValues, LuaValue[] unnamedValues, Varargs lastarg) {return new LuaTable(namedValues,unnamedValues,lastarg); }
@Override public LuaValue getSetupOptions() { LuaTable options = new LuaTable(); return options; }
@Override public LuaValue getSetupOptions() { LuaTable options = new LuaTable(); options.set("lang", "en"); return options; }
@Override public LuaTable getEnv(){ LuaTable table = new LuaTable(); for( Map.Entry<String, String> entry : mMapEnvironment.entrySet() ){ table.set(LuaString.valueOf(entry.getKey()), LuaString.valueOf(entry.getValue())); } return table; }
@Override public LuaTable getEnv(){ LuaTable table = new LuaTable(); for( Map.Entry<String, String> entry : mMapEnvironment.entrySet() ){ table.set(LuaString.valueOf(entry.getKey()), LuaString.valueOf(entry.getValue())); } return table; }
@Override public LuaValue getSetupOptions() { LuaTable table = new LuaTable(); // https://www.mediawiki.org/wiki/Manual:$wgMaxArticleSize // stringLengthLimit = $wgMaxArticleSize * 1024; table.set("stringLengthLimit", 2048 * 1024); table.set("patternLengthLimit", 10000); return table; } }
private static LuaTable arrayToTable(Object[] arrayObj){ LuaTable table = new LuaTable(); for( int i = 0; i < arrayObj.length; i++ ){ table.set( LuaInteger.valueOf( i + 1), CoerceJavaToLua.coerce(arrayObj[i])); } return table; } }
public LuaValue call(LuaValue env) { LuaTable meta = new LuaTable(0,1); meta.set("__tostring", new tostring()); LuaTable table = new LuaTable(0,10); table.setmetatable(meta); table.set("read", new read()); table.set("readable", new readable()); table.set("writeable", new writeable()); table.set("write", new write()); instance.registerPackage("stream", table); return table; }
@Override public LuaValue call(LuaValue var1, LuaValue var2) { LuaTable functions = new LuaTable(); functions.set("getRapidView", new GetPhotonView()); functions.set("getJavaBridge", new GetJavaBridge()); functions.set("getEnvironment", new GetEnvironment()); var2.set("rapid", functions); var2.get("package").get("loaded").set("rapid", functions); return functions; }
@Override public LuaTable getInterface() { LuaTable table = new LuaTable(); table.set("getNsIndex", getNsIndex()); table.set("pagesInCategory", pagesInCategory()); table.set("pagesInNamespace", pagesInNamespace()); table.set("usersInGroup", usersInGroup()); table.set("interwikiMap", interwikiMap()); return table; }
@Override public LuaTable getInterface() { LuaTable table = new LuaTable(); table.set("unstrip", unstrip()); table.set("unstripNoWiki", unstripNoWiki()); table.set("killMarkers", killMarkers()); table.set("getEntityTable", getEntityTable()); table.set("jsonEncode", jsonEncode()); table.set("jsonDecode", jsonDecode()); return table; }