Fix build errors for j2me. #32
This commit is contained in:
@@ -49,7 +49,7 @@ import org.luaj.vm2.compiler.DumpState;
|
||||
* Globals globals = new Globals();
|
||||
* globals.load(new JseBaseLib());
|
||||
* globals.load(new PackageLib());
|
||||
* globals.load(new StringLib());
|
||||
* globals.load(new JseStringLib());
|
||||
* System.out.println( globals.get("string").get("upper").call( LuaValue.valueOf("abcde") ) );
|
||||
* } </pre>
|
||||
* <p>
|
||||
@@ -230,7 +230,7 @@ public class StringLib extends TwoArgFunction {
|
||||
* This function does not accept string values containing embedded zeros,
|
||||
* except as arguments to the q option.
|
||||
*/
|
||||
static final class format extends VarArgFunction {
|
||||
final class format extends VarArgFunction {
|
||||
public Varargs invoke(Varargs args) {
|
||||
LuaString fmt = args.checkstring( 1 );
|
||||
final int n = fmt.length();
|
||||
@@ -330,7 +330,7 @@ public class StringLib extends TwoArgFunction {
|
||||
|
||||
private static final String FLAGS = "-+ #0";
|
||||
|
||||
static class FormatDesc {
|
||||
class FormatDesc {
|
||||
|
||||
private boolean leftAdjust;
|
||||
private boolean zeroPad;
|
||||
@@ -470,13 +470,7 @@ public class StringLib extends TwoArgFunction {
|
||||
}
|
||||
|
||||
public void format(Buffer buf, double x) {
|
||||
String out;
|
||||
try {
|
||||
out = String.format(src, x);
|
||||
} catch (Throwable e) {
|
||||
out = String.valueOf( x );
|
||||
}
|
||||
buf.append( out );
|
||||
buf.append( StringLib.this.format(src, x) );
|
||||
}
|
||||
|
||||
public void format(Buffer buf, LuaString s) {
|
||||
@@ -486,13 +480,17 @@ public class StringLib extends TwoArgFunction {
|
||||
buf.append(s);
|
||||
}
|
||||
|
||||
public static final void pad(Buffer buf, char c, int n) {
|
||||
public final void pad(Buffer buf, char c, int n) {
|
||||
byte b = (byte)c;
|
||||
while ( n-- > 0 )
|
||||
buf.append(b);
|
||||
}
|
||||
}
|
||||
|
||||
protected String format(String src, double x) {
|
||||
return String.valueOf(x);
|
||||
}
|
||||
|
||||
/**
|
||||
* string.gmatch (s, pattern)
|
||||
*
|
||||
|
||||
@@ -23,7 +23,6 @@ package org.luaj.vm2.lib.jse;
|
||||
|
||||
import org.luaj.vm2.Globals;
|
||||
import org.luaj.vm2.LoadState;
|
||||
import org.luaj.vm2.LuaThread;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
import org.luaj.vm2.Varargs;
|
||||
import org.luaj.vm2.compiler.LuaC;
|
||||
@@ -35,10 +34,10 @@ import org.luaj.vm2.lib.ResourceFinder;
|
||||
import org.luaj.vm2.lib.StringLib;
|
||||
import org.luaj.vm2.lib.TableLib;
|
||||
|
||||
/** The {@link org.luaj.vm2.lib.jse.JsePlatform} class is a convenience class to standardize
|
||||
* how globals tables are initialized for the JSE platform.
|
||||
/** The {@link org.luaj.vm2.lib.jse.JsePlatform} class is a convenience class to standardize
|
||||
* how globals tables are initialized for the JSE platform.
|
||||
* <p>
|
||||
* It is used to allocate either a set of standard globals using
|
||||
* It is used to allocate either a set of standard globals using
|
||||
* {@link #standardGlobals()} or debug globals using {@link #debugGlobals()}
|
||||
* <p>
|
||||
* A simple example of initializing globals and using them from Java is:
|
||||
@@ -52,7 +51,7 @@ import org.luaj.vm2.lib.TableLib;
|
||||
* globals.load( new FileInputStream("main.lua"), "main.lua" ).call();
|
||||
* } </pre>
|
||||
* <p>
|
||||
* although {@code require} could also be used:
|
||||
* although {@code require} could also be used:
|
||||
* <pre> {@code
|
||||
* globals.get("require").call(LuaValue.valueOf("main"));
|
||||
* } </pre>
|
||||
@@ -73,8 +72,8 @@ import org.luaj.vm2.lib.TableLib;
|
||||
* <li>{@link org.luaj.vm2.lib.jse.JseOsLib}</li>
|
||||
* <li>{@link org.luaj.vm2.lib.jse.LuajavaLib}</li>
|
||||
* </ul>
|
||||
* In addition, the {@link LuaC} compiler is installed so lua files may be loaded in their source form.
|
||||
* <p>
|
||||
* In addition, the {@link LuaC} compiler is installed so lua files may be loaded in their source form.
|
||||
* <p>
|
||||
* The debug globals are simply the standard globals plus the {@code debug} library {@link DebugLib}.
|
||||
* <p>
|
||||
* The class ensures that initialization is done in the correct order.
|
||||
@@ -98,7 +97,7 @@ public class JsePlatform {
|
||||
globals.load(new PackageLib());
|
||||
globals.load(new Bit32Lib());
|
||||
globals.load(new TableLib());
|
||||
globals.load(new StringLib());
|
||||
globals.load(new JseStringLib());
|
||||
globals.load(new CoroutineLib());
|
||||
globals.load(new JseMathLib());
|
||||
globals.load(new JseIoLib());
|
||||
@@ -106,7 +105,7 @@ public class JsePlatform {
|
||||
globals.load(new LuajavaLib());
|
||||
LoadState.install(globals);
|
||||
LuaC.install(globals);
|
||||
return globals;
|
||||
return globals;
|
||||
}
|
||||
|
||||
/** Create standard globals including the {@link DebugLib} library.
|
||||
@@ -124,9 +123,9 @@ public class JsePlatform {
|
||||
}
|
||||
|
||||
|
||||
/** Simple wrapper for invoking a lua function with command line arguments.
|
||||
/** Simple wrapper for invoking a lua function with command line arguments.
|
||||
* The supplied function is first given a new Globals object as its environment
|
||||
* then the program is run with arguments.
|
||||
* then the program is run with arguments.
|
||||
* @return {@link Varargs} containing any values returned by mainChunk.
|
||||
*/
|
||||
public static Varargs luaMain(LuaValue mainChunk, String[] args) {
|
||||
|
||||
Reference in New Issue
Block a user