Change platform packages.

This commit is contained in:
James Roseborough
2010-07-30 18:09:31 +00:00
parent 6ca90b180a
commit 51e64c87cb
24 changed files with 50 additions and 36 deletions

View File

@@ -142,7 +142,7 @@ The following pattern is used within Java SE
<pre> <pre>
import org.luaj.vm2.*; import org.luaj.vm2.*;
import org.luaj.vm2.lib.*; import org.luaj.vm2.lib.jse.*;
String script = "examples/lua/hello.lua"; String script = "examples/lua/hello.lua";
LuaValue _G = JsePlatform.standardGlobals(); LuaValue _G = JsePlatform.standardGlobals();
@@ -165,7 +165,7 @@ The for MIDlets the <em>JmePlatform</em> is used instead:
<pre> <pre>
import org.luaj.vm2.*; import org.luaj.vm2.*;
import org.luaj.vm2.lib.*; import org.luaj.vm2.lib.jme.*;
String script = "examples/lua/hello.lua"; String script = "examples/lua/hello.lua";
LuaValue _G = JmePlatform.standardGlobals(); LuaValue _G = JmePlatform.standardGlobals();

View File

@@ -5,6 +5,7 @@ import javax.microedition.midlet.MIDletStateChangeException;
import org.luaj.vm2.*; import org.luaj.vm2.*;
import org.luaj.vm2.lib.*; import org.luaj.vm2.lib.*;
import org.luaj.vm2.lib.jme.JmePlatform;
import org.luaj.vm2.compiler.LuaC; import org.luaj.vm2.compiler.LuaC;

View File

@@ -1,7 +1,7 @@
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
import org.luaj.vm2.lib.JsePlatform; import org.luaj.vm2.lib.jse.JsePlatform;
public class SampleJseMain { public class SampleJseMain {

View File

@@ -312,8 +312,11 @@ public class DebugLib extends VarArgFunction {
ds.nextInfo().setargs( args, stack ); ds.nextInfo().setargs( args, stack );
} }
/** Called by Closures and recursing java functions on entry /** Called by Closures and recursing java functions on entry
* @param calls */ * @param thread the thread for the call
* @param calls the number of calls in the call stack
* @param func the function called
*/
public static void debugOnCall(LuaThread thread, int calls, LuaFunction func) { public static void debugOnCall(LuaThread thread, int calls, LuaFunction func) {
DebugState ds = getDebugState(); DebugState ds = getDebugState();
if ( ds.inhook ) if ( ds.inhook )
@@ -326,8 +329,9 @@ public class DebugLib extends VarArgFunction {
} }
/** Called by Closures and recursing java functions on return /** Called by Closures and recursing java functions on return
* @param running_calls * @param thread the thread for the call
* @param thread */ * @param calls the number of calls in the call stack
*/
public static void debugOnReturn(LuaThread thread, int calls) { public static void debugOnReturn(LuaThread thread, int calls) {
DebugState ds = getDebugState(thread); DebugState ds = getDebugState(thread);
if ( ds.inhook ) if ( ds.inhook )
@@ -668,7 +672,7 @@ public class DebugLib extends VarArgFunction {
* Get file and line for a particular level, even if it is a java function. * Get file and line for a particular level, even if it is a java function.
* *
* @param level 0-based index of level to get * @param level 0-based index of level to get
* @return * @return String containing file and line info if available
*/ */
public static String fileline(int level) { public static String fileline(int level) {
DebugState ds = getDebugState(LuaThread.getRunning()); DebugState ds = getDebugState(LuaThread.getRunning());

View File

@@ -91,7 +91,10 @@ public class IoLib extends OneArgFunction {
/** /**
* Open a file in a particular mode. * Open a file in a particular mode.
* @param filename * @param filename
* @param mode * @param readMode true if opening in read mode
* @param appendMode true if opening in append mode
* @param updateMode true if opening in update mode
* @param binaryMode true if opening in binary mode
* @return File object if successful * @return File object if successful
* @throws IOException if could not be opened * @throws IOException if could not be opened
*/ */

View File

@@ -19,12 +19,19 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
******************************************************************************/ ******************************************************************************/
package org.luaj.vm2.lib; package org.luaj.vm2.lib.jme;
import org.luaj.vm2.compiler.LuaC; import org.luaj.vm2.compiler.LuaC;
import org.luaj.vm2.LuaTable; import org.luaj.vm2.LuaTable;
import org.luaj.vm2.LuaThread; import org.luaj.vm2.LuaThread;
import org.luaj.vm2.lib.jme.JmeIoLib; import org.luaj.vm2.lib.BaseLib;
import org.luaj.vm2.lib.CoroutineLib;
import org.luaj.vm2.lib.DebugLib;
import org.luaj.vm2.lib.MathLib;
import org.luaj.vm2.lib.OsLib;
import org.luaj.vm2.lib.PackageLib;
import org.luaj.vm2.lib.StringLib;
import org.luaj.vm2.lib.TableLib;
public class JmePlatform { public class JmePlatform {

View File

@@ -32,7 +32,7 @@ import org.luaj.vm2.Lua;
import org.luaj.vm2.LuaFunction; import org.luaj.vm2.LuaFunction;
import org.luaj.vm2.LuaTable; import org.luaj.vm2.LuaTable;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
import org.luaj.vm2.lib.JsePlatform; import org.luaj.vm2.lib.jse.JsePlatform;
import org.luaj.vm2.luajc.LuaJC; import org.luaj.vm2.luajc.LuaJC;

View File

@@ -30,7 +30,7 @@ import java.util.List;
import org.luaj.vm2.Lua; import org.luaj.vm2.Lua;
import org.luaj.vm2.ast.Chunk; import org.luaj.vm2.ast.Chunk;
import org.luaj.vm2.lib.JsePlatform; import org.luaj.vm2.lib.jse.JsePlatform;
import org.luaj.vm2.lua2java.JavaCodeGen; import org.luaj.vm2.lua2java.JavaCodeGen;
import org.luaj.vm2.parser.LuaParser; import org.luaj.vm2.parser.LuaParser;

View File

@@ -32,7 +32,7 @@ import java.util.List;
import org.luaj.vm2.Lua; import org.luaj.vm2.Lua;
import org.luaj.vm2.compiler.DumpState; import org.luaj.vm2.compiler.DumpState;
import org.luaj.vm2.lib.JsePlatform; import org.luaj.vm2.lib.jse.JsePlatform;
import org.luaj.vm2.luajc.LuaJC; import org.luaj.vm2.luajc.LuaJC;
/** /**

View File

@@ -19,16 +19,16 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
******************************************************************************/ ******************************************************************************/
package org.luaj.vm2.lib; package org.luaj.vm2.lib.jse;
import org.luaj.vm2.compiler.LuaC; import org.luaj.vm2.compiler.LuaC;
import org.luaj.vm2.LuaTable; import org.luaj.vm2.LuaTable;
import org.luaj.vm2.LuaThread; import org.luaj.vm2.LuaThread;
import org.luaj.vm2.lib.jse.JseBaseLib; import org.luaj.vm2.lib.CoroutineLib;
import org.luaj.vm2.lib.jse.JseIoLib; import org.luaj.vm2.lib.DebugLib;
import org.luaj.vm2.lib.jse.JseMathLib; import org.luaj.vm2.lib.PackageLib;
import org.luaj.vm2.lib.jse.JseOsLib; import org.luaj.vm2.lib.StringLib;
import org.luaj.vm2.lib.jse.LuajavaLib; import org.luaj.vm2.lib.TableLib;
public class JsePlatform { public class JsePlatform {

View File

@@ -46,7 +46,7 @@ import org.luaj.vm2.LuaError;
import org.luaj.vm2.LuaFunction; import org.luaj.vm2.LuaFunction;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
import org.luaj.vm2.Prototype; import org.luaj.vm2.Prototype;
import org.luaj.vm2.lib.JsePlatform; import org.luaj.vm2.lib.jse.JsePlatform;
/** /**
* *

View File

@@ -30,7 +30,7 @@ import org.luaj.vm2.LuaValue;
import org.luaj.vm2.Print; import org.luaj.vm2.Print;
import org.luaj.vm2.Prototype; import org.luaj.vm2.Prototype;
import org.luaj.vm2.compiler.LuaC; import org.luaj.vm2.compiler.LuaC;
import org.luaj.vm2.lib.JsePlatform; import org.luaj.vm2.lib.jse.JsePlatform;
/** Test the plain old bytecode interpreter */ /** Test the plain old bytecode interpreter */
public class TestLuaJ { public class TestLuaJ {

View File

@@ -30,7 +30,7 @@ import java.util.Hashtable;
import org.luaj.vm2.LuaTable; import org.luaj.vm2.LuaTable;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
import org.luaj.vm2.Varargs; import org.luaj.vm2.Varargs;
import org.luaj.vm2.lib.JsePlatform; import org.luaj.vm2.lib.jse.JsePlatform;
import org.luaj.vm2.luajc.LuaJC; import org.luaj.vm2.luajc.LuaJC;
public class TestLuaJC { public class TestLuaJC {

View File

@@ -71,7 +71,7 @@ public class FragmentsTest extends TestSuite {
public void runFragment( Varargs expected, String script ) { public void runFragment( Varargs expected, String script ) {
try { try {
String name = getName(); String name = getName();
LuaTable _G = org.luaj.vm2.lib.JsePlatform.standardGlobals(); LuaTable _G = org.luaj.vm2.lib.jse.JsePlatform.standardGlobals();
InputStream is = new ByteArrayInputStream(script.getBytes("UTF-8")); InputStream is = new ByteArrayInputStream(script.getBytes("UTF-8"));
LuaValue chunk ; LuaValue chunk ;
switch ( TEST_TYPE ) { switch ( TEST_TYPE ) {

View File

@@ -179,7 +179,7 @@ public class LuaOperationsTest extends TestCase {
public Prototype createPrototype( String script, String name ) { public Prototype createPrototype( String script, String name ) {
try { try {
LuaTable _G = org.luaj.vm2.lib.JsePlatform.standardGlobals(); LuaTable _G = org.luaj.vm2.lib.jse.JsePlatform.standardGlobals();
InputStream is = new ByteArrayInputStream(script.getBytes("UTF-8")); InputStream is = new ByteArrayInputStream(script.getBytes("UTF-8"));
return LuaC.instance.compile(is, name); return LuaC.instance.compile(is, name);
} catch (Exception e) { } catch (Exception e) {
@@ -195,7 +195,7 @@ public class LuaOperationsTest extends TestCase {
// set up suitable environments for execution // set up suitable environments for execution
LuaValue aaa = LuaValue.valueOf("aaa"); LuaValue aaa = LuaValue.valueOf("aaa");
LuaValue eee = LuaValue.valueOf("eee"); LuaValue eee = LuaValue.valueOf("eee");
LuaTable _G = org.luaj.vm2.lib.JsePlatform.standardGlobals(); LuaTable _G = org.luaj.vm2.lib.jse.JsePlatform.standardGlobals();
LuaTable newenv = LuaValue.tableOf( new LuaValue[] { LuaTable newenv = LuaValue.tableOf( new LuaValue[] {
LuaValue.valueOf("a"), LuaValue.valueOf("aaa"), LuaValue.valueOf("a"), LuaValue.valueOf("aaa"),
LuaValue.valueOf("b"), LuaValue.valueOf("bbb"), } ); LuaValue.valueOf("b"), LuaValue.valueOf("bbb"), } );

View File

@@ -2,9 +2,9 @@ package org.luaj.vm2;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.luaj.vm2.lib.JsePlatform;
import org.luaj.vm2.lib.MathLib; import org.luaj.vm2.lib.MathLib;
import org.luaj.vm2.lib.jse.JseMathLib; import org.luaj.vm2.lib.jse.JseMathLib;
import org.luaj.vm2.lib.jse.JsePlatform;
public class MathLibTest extends TestCase { public class MathLibTest extends TestCase {

View File

@@ -2,7 +2,7 @@ package org.luaj.vm2;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.luaj.vm2.lib.JsePlatform; import org.luaj.vm2.lib.jse.JsePlatform;
import org.luaj.vm2.require.RequireSampleClassCastExcep; import org.luaj.vm2.require.RequireSampleClassCastExcep;
import org.luaj.vm2.require.RequireSampleLoadLuaError; import org.luaj.vm2.require.RequireSampleLoadLuaError;
import org.luaj.vm2.require.RequireSampleLoadRuntimeExcep; import org.luaj.vm2.require.RequireSampleLoadRuntimeExcep;

View File

@@ -58,10 +58,10 @@ public class ScriptDrivenTest extends TestCase {
case JSE: case JSE:
case LUAJIT: case LUAJIT:
case LUA2JAVA: case LUA2JAVA:
_G = org.luaj.vm2.lib.JsePlatform.debugGlobals(); _G = org.luaj.vm2.lib.jse.JsePlatform.debugGlobals();
break; break;
case JME: case JME:
_G = org.luaj.vm2.lib.JmePlatform.debugGlobals(); _G = org.luaj.vm2.lib.jme.JmePlatform.debugGlobals();
break; break;
} }
} }

View File

@@ -6,7 +6,7 @@ import java.io.UnsupportedEncodingException;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.luaj.vm2.lib.JsePlatform; import org.luaj.vm2.lib.jse.JsePlatform;
public class StringTest extends TestCase { public class StringTest extends TestCase {

View File

@@ -15,7 +15,7 @@ import org.luaj.vm2.LoadState;
import org.luaj.vm2.LuaTable; import org.luaj.vm2.LuaTable;
import org.luaj.vm2.Print; import org.luaj.vm2.Print;
import org.luaj.vm2.Prototype; import org.luaj.vm2.Prototype;
import org.luaj.vm2.lib.JsePlatform; import org.luaj.vm2.lib.jse.JsePlatform;
abstract public class AbstractUnitTests extends TestCase { abstract public class AbstractUnitTests extends TestCase {

View File

@@ -15,7 +15,7 @@ import org.luaj.vm2.LuaFunction;
import org.luaj.vm2.LuaTable; import org.luaj.vm2.LuaTable;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
import org.luaj.vm2.Prototype; import org.luaj.vm2.Prototype;
import org.luaj.vm2.lib.JsePlatform; import org.luaj.vm2.lib.jse.JsePlatform;
public class DumpLoadEndianIntTest extends TestCase { public class DumpLoadEndianIntTest extends TestCase {

View File

@@ -10,7 +10,7 @@ import org.luaj.vm2.LuaFunction;
import org.luaj.vm2.LuaInteger; import org.luaj.vm2.LuaInteger;
import org.luaj.vm2.LuaTable; import org.luaj.vm2.LuaTable;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
import org.luaj.vm2.lib.JsePlatform; import org.luaj.vm2.lib.jse.JsePlatform;
public class SimpleTests extends TestCase { public class SimpleTests extends TestCase {

View File

@@ -10,7 +10,6 @@ import org.luaj.vm2.LuaUserdata;
import org.luaj.vm2.LuaValue; import org.luaj.vm2.LuaValue;
import org.luaj.vm2.Varargs; import org.luaj.vm2.Varargs;
import org.luaj.vm2.compiler.LuaC; import org.luaj.vm2.compiler.LuaC;
import org.luaj.vm2.lib.JsePlatform;
public class LuaJavaCoercionTest extends TestCase { public class LuaJavaCoercionTest extends TestCase {

View File

@@ -129,7 +129,7 @@ public class Luajvm1CompatibilityTest extends TestCase {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream( outputStream ); PrintStream printStream = new PrintStream( outputStream );
try { try {
org.luaj.vm2.LuaTable _G = org.luaj.vm2.lib.JsePlatform.debugGlobals(); org.luaj.vm2.LuaTable _G = org.luaj.vm2.lib.jse.JsePlatform.debugGlobals();
LuaThread.getRunning().setfenv(_G); LuaThread.getRunning().setfenv(_G);
LuaValue loader = new org.luaj.vm2.lib.OneArgFunction(_G) { LuaValue loader = new org.luaj.vm2.lib.OneArgFunction(_G) {
public LuaValue call(LuaValue arg) { public LuaValue call(LuaValue arg) {