Refactor API's related to compiling and loading scripts and character encoding handling.

This commit is contained in:
James Roseborough
2013-09-18 05:32:30 +00:00
parent a552494b72
commit 2123d3f924
35 changed files with 489 additions and 293 deletions

View File

@@ -4,9 +4,7 @@ import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import org.luaj.vm2.*;
import org.luaj.vm2.lib.*;
import org.luaj.vm2.lib.jme.JmePlatform;
import org.luaj.vm2.compiler.LuaC;
public class SampleMIDlet extends MIDlet {
@@ -21,8 +19,8 @@ public class SampleMIDlet extends MIDlet {
script = DEFAULT_SCRIPT;
// create an environment to run in
LuaValue _G = JmePlatform.standardGlobals();
_G.get("require").call( LuaValue.valueOf(script) );
Globals globals = JmePlatform.standardGlobals();
globals.get("require").call( LuaValue.valueOf(script) );
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {

View File

@@ -13,7 +13,7 @@ public class SampleJseMain {
Globals globals = JsePlatform.standardGlobals();
// Use the convenience function on the globals to load a chunk.
LuaValue chunk = globals.loadFile(script);
LuaValue chunk = globals.loadfile(script);
// Use any of the "call()" or "invoke()" functions directly on the chunk.
chunk.call( LuaValue.valueOf(script) );

View File

@@ -26,8 +26,8 @@ public class SampleMultiThreaded {
// Once a Globals is created, it can and should be reused
// within the same thread.
g.loadFile(script1).call();
g.loadFile(script2).call();
g.loadfile(script1).call();
g.loadfile(script2).call();
} catch ( Exception e ) {
e.printStackTrace();