diff --git a/README.html b/README.html index 217457d0..5a7f4746 100644 --- a/README.html +++ b/README.html @@ -16,7 +16,7 @@ Getting Started with LuaJ -James Roseborough, Ian Farmer, Version 3.0 +James Roseborough, Ian Farmer, Version 3.0.1
Copyright © 2009-2014 Luaj.org.
@@ -120,7 +120,7 @@ in comparison with the standard C distribution.
@@ -198,7 +198,7 @@ You should see the following output:
To see how luaj can be used to acccess most Java API's including swing, try:
@@ -213,8 +213,8 @@ Links to sources:
@@ -228,8 +228,8 @@ Luaj can compile lua sources or binaries directly to java bytecode if the bcel l
@@ -240,7 +240,7 @@ but the compiled classes must be in the class path at runtime, unless runtime ji
Lua scripts can also be run directly in this mode without precompiling using the lua command with the -b option and providing the bcel library in the class path:
-You must include the library lib/luaj-jse-3.0.jar in your class path.
+You must include the library lib/luaj-jse-3.0.1.jar in your class path.
-You must include the library lib/luaj-jme-3.0.jar in your midlet jar.
+You must include the library lib/luaj-jme-3.0.1.jar in your midlet jar.
An ant script to build and run the midlet is in
@@ -341,7 +341,7 @@ You can also look up the engine by language "lua" or mimetypes "text/lua" or "ap
All standard aspects of script engines including compiled statements are supported.
-You must include the library lib/luaj-jse-3.0.jar in your class path.
+You must include the library lib/luaj-jse-3.0.1.jar in your class path.
A working example may be found in
@@ -352,8 +352,8 @@ A working example may be found in
To compile and run it using Java 1.6 or higher:
@@ -817,7 +817,7 @@ For JSE projects, add this dependency for the luaj-jse jar:
<dependency>
<groupId>org.luaj</groupId>
<artifactId>luaj-jse</artifactId>
- <version>3.0</version>
+ <version>3.0.1</version>
</dependency>
while for JME projects, use the luaj-jme jar:
@@ -825,7 +825,7 @@ while for JME projects, use the luaj-jme jar:
<dependency>
<groupId>org.luaj</groupId>
<artifactId>luaj-jme</artifactId>
- <version>3.0</version>
+ <version>3.0.1</version>
</dependency>
@@ -855,7 +855,7 @@ Unit test scripts can be found in these locations
test/lua/*.lua
test/lua/errors/*.lua
test/lua/perf/*.lua
- test/lua/luaj3.0-tests.zip
+ test/lua/luaj3.0.1-tests.zip
16.794
11.274
Java
- java -cp luaj-jse-3.0.jar;bcel-5.2.jar lua -b fannkuch.lua 10
+ java -cp luaj-jse-3.0.1.jar;bcel-5.2.jar lua -b fannkuch.lua 10
+
@@ -130,7 +130,7 @@ in comparison with the standard C distribution.
36.894
15.163
- java -cp luaj-jse-3.0.jar lua -n fannkuch.lua 10 java -cp luaj-jse-3.0.1.jar lua -n fannkuch.lua 10
lua
5.1.4
@@ -186,7 +186,7 @@ It is also faster than Java-lua implementations Jill, Kahlua, and Mochalua for a
From the main distribution directory line type:
- java -cp lib/luaj-jse-3.0.jar lua examples/lua/hello.lua
+ java -cp lib/luaj-jse-3.0.1.jar lua examples/lua/hello.lua
- java -cp lib/luaj-jse-3.0.jar lua examples/lua/swingapp.lua
+ java -cp lib/luaj-jse-3.0.1.jar lua examples/lua/swingapp.lua
From the main distribution directory line type:
- java -cp lib/luaj-jse-3.0.jar luac examples/lua/hello.lua
- java -cp lib/luaj-jse-3.0.jar lua luac.out
+ java -cp lib/luaj-jse-3.0.1.jar luac examples/lua/hello.lua
+ java -cp lib/luaj-jse-3.0.1.jar lua luac.out
ant bcel-lib
- java -cp "lib/luaj-jse-3.0.jar;lib/bcel-5.2.jar" luajc -s examples/lua -d . hello.lua
- java -cp "lib/luaj-jse-3.0.jar;." lua -l hello
+ java -cp "lib/luaj-jse-3.0.1.jar;lib/bcel-5.2.jar" luajc -s examples/lua -d . hello.lua
+ java -cp "lib/luaj-jse-3.0.1.jar;." lua -l hello
- java -cp "lib/luaj-jse-3.0.jar;lib/bcel-5.2.jar" lua -b examples/lua/hello.lua
+ java -cp "lib/luaj-jse-3.0.1.jar;lib/bcel-5.2.jar" lua -b examples/lua/hello.lua
@@ -284,7 +284,7 @@ A simple example may be found in
Run a script in a MIDlet
@@ -311,7 +311,7 @@ A simple example may be found in
- javac -cp lib/luaj-jse-3.0.jar examples/jse/ScriptEngineSample.java
- java -cp "lib/luaj-jse-3.0.jar;examples/jse" ScriptEngineSample
+ javac -cp lib/luaj-jse-3.0.1.jar examples/jse/ScriptEngineSample.java
+ java -cp "lib/luaj-jse-3.0.1.jar;examples/jse" ScriptEngineSample
Excluding the lua bytecode compiler
@@ -570,7 +570,7 @@ The following lua script will open a swing frame on Java SE:
See a longer sample in examples/lua/swingapp.lua for details, including a simple animation loop, rendering graphics, mouse and key handling, and image loading.
Or try running it using:
- java -cp lib/luaj-jse-3.0.jar lua examples/lua/swingapp.lua
+ java -cp lib/luaj-jse-3.0.1.jar lua examples/lua/swingapp.lua
Code coverage
@@ -916,25 +916,19 @@ Files are no longer hosted at LuaForge.
3.0-alpha1
+
3.0
3.0-alpha2
3.0-alpha3
3.0-beta1
3.0-beta2
diff --git a/src/core/org/luaj/vm2/LoadState.java b/src/core/org/luaj/vm2/LoadState.java
index e583d509..9f7377f7 100644
--- a/src/core/org/luaj/vm2/LoadState.java
+++ b/src/core/org/luaj/vm2/LoadState.java
@@ -82,10 +82,15 @@ import org.luaj.vm2.compiler.DumpState;
* @see LuaC
* @see LuaJC
*/
-public class LoadState implements Globals.Undumper {
+public class LoadState {
/** Shared instance of Globals.Undumper to use loading prototypes from binary lua files */
- public static final Globals.Undumper instance = new LoadState();
+ public static final Globals.Undumper instance = new Globals.Undumper() {
+ public Prototype undump(InputStream stream, String chunkname)
+ throws IOException {
+ return LoadState.undump(stream, chunkname);
+ }
+ };
/** format corresponding to non-number-patched lua, all numbers are floats or doubles */
public static final int NUMBER_FORMAT_FLOATS_OR_DOUBLES = 0;
@@ -387,7 +392,7 @@ public class LoadState implements Globals.Undumper {
* @return {@link Prototype} that was loaded, or null if the first 4 bytes were not the lua signature.
* @throws IOException if an IOException occurs
*/
- public Prototype undump(InputStream stream, String chunkname) throws IOException {
+ public static Prototype undump(InputStream stream, String chunkname) throws IOException {
// check rest of signature
if ( stream.read() != LUA_SIGNATURE[0]
|| stream.read() != LUA_SIGNATURE[1]
@@ -432,8 +437,4 @@ public class LoadState implements Globals.Undumper {
this.is = new DataInputStream( stream );
}
- private LoadState() {
- this.name = "";
- this.is = null;
- }
}
diff --git a/src/core/org/luaj/vm2/LuaTable.java b/src/core/org/luaj/vm2/LuaTable.java
index ddbecb18..9680cc71 100644
--- a/src/core/org/luaj/vm2/LuaTable.java
+++ b/src/core/org/luaj/vm2/LuaTable.java
@@ -299,7 +299,7 @@ public class LuaTable extends LuaValue implements Metatable {
* @return The removed item, or {@link #NONE} if not removed
*/
public LuaValue remove(int pos) {
- int n = length();
+ int n = rawlen();
if ( pos == 0 )
pos = n;
else if (pos > n)
@@ -319,7 +319,7 @@ public class LuaTable extends LuaValue implements Metatable {
*/
public void insert(int pos, LuaValue value) {
if ( pos == 0 )
- pos = length()+1;
+ pos = rawlen()+1;
while ( ! value.isnil() ) {
LuaValue v = rawget( pos );
rawset(pos++, value);
@@ -347,6 +347,17 @@ public class LuaTable extends LuaValue implements Metatable {
}
public int length() {
+ return m_metatable != null? len().toint(): rawlen();
+ }
+
+ public LuaValue len() {
+ final LuaValue h = metatag(LEN);
+ if (h.toboolean())
+ return h.call(this);
+ return LuaInteger.valueOf(rawlen());
+ }
+
+ public int rawlen() {
int a = getArrayLength();
int n = a+1,m=0;
while ( !rawget(n).isnil() ) {
@@ -362,14 +373,6 @@ public class LuaTable extends LuaValue implements Metatable {
}
return m;
}
-
- public LuaValue len() {
- return LuaInteger.valueOf(length());
- }
-
- public int rawlen() {
- return length();
- }
/**
* Get the next element after a particular key in the table
@@ -879,12 +882,12 @@ public class LuaTable extends LuaValue implements Metatable {
/** Unpack all the elements of this table */
public Varargs unpack() {
- return unpack(1, this.length());
+ return unpack(1, this.rawlen());
}
/** Unpack all the elements of this table from element i */
public Varargs unpack(int i) {
- return unpack(i, this.length());
+ return unpack(i, this.rawlen());
}
/** Unpack the elements from i to j inclusive */
diff --git a/src/core/org/luaj/vm2/LuaValue.java b/src/core/org/luaj/vm2/LuaValue.java
index 648d756a..8700d6b1 100644
--- a/src/core/org/luaj/vm2/LuaValue.java
+++ b/src/core/org/luaj/vm2/LuaValue.java
@@ -2965,12 +2965,11 @@ public class LuaValue extends Varargs {
* @see #lteq(LuaValue)
*/
public LuaValue comparemt( LuaValue tag, LuaValue op1 ) {
- LuaValue h = metatag(tag);
- if ( !h.isnil() )
- return h.call(this, op1);
- h = op1.metatag(tag);
- if ( !h.isnil() )
+ LuaValue h;
+ if (!(h = metatag(tag)).isnil() || !(h = op1.metatag(tag)).isnil())
return h.call(this, op1);
+ if (LuaValue.LE.raweq(tag) && (!(h = metatag(LT)).isnil() || !(h = op1.metatag(LT)).isnil()))
+ return h.call(op1, this).not();
return error("attempt to compare "+tag+" on "+typename()+" and "+op1.typename());
}
diff --git a/src/core/org/luaj/vm2/TailcallVarargs.java b/src/core/org/luaj/vm2/TailcallVarargs.java
index 0b5d5254..fb0e84aa 100644
--- a/src/core/org/luaj/vm2/TailcallVarargs.java
+++ b/src/core/org/luaj/vm2/TailcallVarargs.java
@@ -21,9 +21,6 @@
******************************************************************************/
package org.luaj.vm2;
-import org.luaj.vm2.Varargs.ArrayPartVarargs;
-import org.luaj.vm2.Varargs.PairVarargs;
-
/**
* Subclass of {@link Varargs} that represents a lua tail call
* in a Java library function execution environment.
3.0
-
3.0.1
+