From 364f548c2c5db2991e51e6bb0f2fe5cdc86e5c85 Mon Sep 17 00:00:00 2001 From: zaoqi Date: Sat, 16 Mar 2019 19:05:03 +0800 Subject: [PATCH 01/71] Fix build bug. #33 --- examples/jse/SampleApplet.java | 4 ++-- examples/jse/SampleSandboxed.java | 6 +++--- src/core/org/luaj/vm2/lib/StringLib.java | 2 +- src/jse/org/luaj/vm2/lib/jse/JsePlatform.java | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/jse/SampleApplet.java b/examples/jse/SampleApplet.java index adf77cb5..a48d7448 100644 --- a/examples/jse/SampleApplet.java +++ b/examples/jse/SampleApplet.java @@ -17,7 +17,7 @@ import org.luaj.vm2.lib.jse.JseBaseLib; import org.luaj.vm2.lib.jse.JseIoLib; import org.luaj.vm2.lib.jse.JseMathLib; import org.luaj.vm2.lib.jse.JseOsLib; -import org.luaj.vm2.lib.jse.JseStringLib; +import org.luaj.vm2.lib.jse.StringLib; import org.luaj.vm2.lib.jse.LuajavaLib; /** @@ -76,7 +76,7 @@ public class SampleApplet extends Applet implements ResourceFinder { globals.load(new PackageLib()); globals.load(new Bit32Lib()); globals.load(new TableLib()); - globals.load(new JseStringLib()); + globals.load(new StringLib()); globals.load(new CoroutineLib()); globals.load(new JseMathLib()); globals.load(new JseIoLib()); diff --git a/examples/jse/SampleSandboxed.java b/examples/jse/SampleSandboxed.java index ee1738af..c4ca9365 100644 --- a/examples/jse/SampleSandboxed.java +++ b/examples/jse/SampleSandboxed.java @@ -15,7 +15,7 @@ import org.luaj.vm2.lib.TwoArgFunction; import org.luaj.vm2.lib.ZeroArgFunction; import org.luaj.vm2.lib.jse.JseBaseLib; import org.luaj.vm2.lib.jse.JseMathLib; -import org.luaj.vm2.lib.jse.JseStringLib; +import org.luaj.vm2.lib.jse.StringLib; /** Simple program that illustrates basic sand-boxing of client scripts * in a server environment. @@ -43,7 +43,7 @@ public class SampleSandboxed { server_globals = new Globals(); server_globals.load(new JseBaseLib()); server_globals.load(new PackageLib()); - server_globals.load(new JseStringLib()); + server_globals.load(new StringLib()); // To load scripts, we occasionally need a math library in addition to compiler support. // To limit scripts using the debug library, they must be closures, so we only install LuaC. @@ -96,7 +96,7 @@ public class SampleSandboxed { user_globals.load(new PackageLib()); user_globals.load(new Bit32Lib()); user_globals.load(new TableLib()); - user_globals.load(new JseStringLib()); + user_globals.load(new StringLib()); user_globals.load(new JseMathLib()); // This library is dangerous as it gives unfettered access to the diff --git a/src/core/org/luaj/vm2/lib/StringLib.java b/src/core/org/luaj/vm2/lib/StringLib.java index 6b75ee8a..b75666fd 100644 --- a/src/core/org/luaj/vm2/lib/StringLib.java +++ b/src/core/org/luaj/vm2/lib/StringLib.java @@ -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 JseStringLib()); + * globals.load(new StringLib()); * System.out.println( globals.get("string").get("upper").call( LuaValue.valueOf("abcde") ) ); * } *

diff --git a/src/jse/org/luaj/vm2/lib/jse/JsePlatform.java b/src/jse/org/luaj/vm2/lib/jse/JsePlatform.java index 00575aaf..a96bc427 100644 --- a/src/jse/org/luaj/vm2/lib/jse/JsePlatform.java +++ b/src/jse/org/luaj/vm2/lib/jse/JsePlatform.java @@ -97,7 +97,7 @@ public class JsePlatform { globals.load(new PackageLib()); globals.load(new Bit32Lib()); globals.load(new TableLib()); - globals.load(new JseStringLib()); + globals.load(new StringLib()); globals.load(new CoroutineLib()); globals.load(new JseMathLib()); globals.load(new JseIoLib()); -- 2.49.1 From a7c8a408ce88b8818fda60eb19c0dc3f739dd86b Mon Sep 17 00:00:00 2001 From: Enyby Date: Sun, 17 Mar 2019 03:06:05 +0200 Subject: [PATCH 02/71] Fix build bug. #33 --- .../org/luaj/vm2/lib/jse/JseStringLib.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/jse/org/luaj/vm2/lib/jse/JseStringLib.java diff --git a/src/jse/org/luaj/vm2/lib/jse/JseStringLib.java b/src/jse/org/luaj/vm2/lib/jse/JseStringLib.java new file mode 100644 index 00000000..41177787 --- /dev/null +++ b/src/jse/org/luaj/vm2/lib/jse/JseStringLib.java @@ -0,0 +1,39 @@ +/******************************************************************************* +* Copyright (c) 2009 Luaj.org. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +******************************************************************************/ +package org.luaj.vm2.lib.jse; + +public class JseStringLib extends org.luaj.vm2.lib.StringLib { + + /** public constructor */ + public JseStringLib() { + } + + protected String format(String src, double x) { + String out; + try { + out = String.format(src, new Object[] {Double.valueOf(x)}); + } catch (Throwable e) { + out = super.format(src, x); + } + return out; + } +} -- 2.49.1 From 177fe4e09f081de776d2c92a53dcfdcb3e3e30b5 Mon Sep 17 00:00:00 2001 From: Enyby Date: Sun, 17 Mar 2019 03:12:52 +0200 Subject: [PATCH 03/71] Fix path to build files in Readme.md --- README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index c3caa4c1..c0749068 100644 --- a/README.md +++ b/README.md @@ -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.2.jar lua examples/lua/hello.lua
+	java -cp luaj-jse-3.0.2.jar lua examples/lua/hello.lua
 

@@ -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:

-	java -cp lib/luaj-jse-3.0.2.jar lua examples/lua/swingapp.lua
+	java -cp luaj-jse-3.0.2.jar lua examples/lua/swingapp.lua
 

@@ -213,8 +213,8 @@ Links to sources:

 From the main distribution directory line type:
 
 
-	java -cp lib/luaj-jse-3.0.2.jar luac examples/lua/hello.lua
-	java -cp lib/luaj-jse-3.0.2.jar lua luac.out
+	java -cp luaj-jse-3.0.2.jar luac examples/lua/hello.lua
+	java -cp luaj-jse-3.0.2.jar lua luac.out
 

@@ -228,8 +228,8 @@ Luaj can compile lua sources or binaries directly to java bytecode if the bcel l

 	ant bcel-lib
-	java -cp "lib/luaj-jse-3.0.2.jar;lib/bcel-5.2.jar" luajc -s examples/lua -d . hello.lua
-	java -cp "lib/luaj-jse-3.0.2.jar;." lua -l hello
+	java -cp "luaj-jse-3.0.2.jar;lib/bcel-5.2.jar" luajc -s examples/lua -d . hello.lua
+	java -cp "luaj-jse-3.0.2.jar;." lua -l hello
 

@@ -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:

-	java -cp "lib/luaj-jse-3.0.2.jar;lib/bcel-5.2.jar" lua -b examples/lua/hello.lua
+	java -cp "luaj-jse-3.0.2.jar;lib/bcel-5.2.jar" lua -b examples/lua/hello.lua
 
@@ -284,7 +284,7 @@ A simple example may be found in

-You must include the library lib/luaj-jse-3.0.2.jar in your class path. +You must include the library luaj-jse-3.0.2.jar in your class path.

Run a script in a MIDlet

@@ -311,7 +311,7 @@ A simple example may be found in

-You must include the library lib/luaj-jme-3.0.2.jar in your midlet jar. +You must include the library luaj-jme-3.0.2.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.2.jar in your class path. +You must include the library luaj-jse-3.0.2.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:

-	javac -cp lib/luaj-jse-3.0.2.jar examples/jse/ScriptEngineSample.java
-	java -cp "lib/luaj-jse-3.0.2.jar;examples/jse" ScriptEngineSample
+	javac -cp luaj-jse-3.0.2.jar examples/jse/ScriptEngineSample.java
+	java -cp "luaj-jse-3.0.2.jar;examples/jse" ScriptEngineSample
 

Excluding the lua bytecode compiler

@@ -593,7 +593,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.2.jar lua examples/lua/swingapp.lua
+	java -cp luaj-jse-3.0.2.jar lua examples/lua/swingapp.lua
 

@@ -930,7 +930,7 @@ Files are no longer hosted at LuaForge.

  • Enhance javadoc, put it in distribution and at http://luaj.sourceforge.net/api/2.0/
  • Major refactor of luajava type coercion logic, improve method selection.
  • -
  • Add lib/luaj-sources-2.0.2.jar for easier integration into an IDE such as Netbeans
  • +
  • Add luaj-sources-2.0.2.jar for easier integration into an IDE such as Netbeans
  •   2.0.3