1. bug fix: reset the VM when EOF occurs, which indicates that debug client or debug service exit abnormally

2. make LUA_PATH a system property instead of a command line option to StandardLuaJVM
This commit is contained in:
Shu Lei
2007-12-13 21:41:03 +00:00
parent 976c405033
commit 5612201e43
3 changed files with 10 additions and 12 deletions

View File

@@ -53,7 +53,6 @@ public class StandardLuaJVM {
protected boolean bSuspendOnStart = false; protected boolean bSuspendOnStart = false;
protected String script; protected String script;
protected String[] scriptArgs; protected String[] scriptArgs;
protected String luaPath;
protected LuaState state; protected LuaState state;
protected boolean isReady = false; protected boolean isReady = false;
protected boolean isTerminated = false; protected boolean isTerminated = false;
@@ -124,11 +123,6 @@ public class StandardLuaJVM {
index++; index++;
} }
if (args[index] != null && args[index].startsWith("-L")) {
luaPath = args[index].substring(2); //remove -L fromt the arg
index++;
}
String[] scriptArgStrs; String[] scriptArgStrs;
if (index != 0) { if (index != 0) {
int scriptArgsCount = args.length - index; int scriptArgsCount = args.length - index;
@@ -184,7 +178,7 @@ public class StandardLuaJVM {
} }
String getLuaPath() { String getLuaPath() {
return this.luaPath; return System.getProperty("LUA_PATH");
} }
public void run() { public void run() {
@@ -235,6 +229,7 @@ public class StandardLuaJVM {
LuaC.install(); LuaC.install();
// set the lua path if present // set the lua path if present
String luaPath = getLuaPath();
if (luaPath != null && luaPath.trim().length() > 0) { if (luaPath != null && luaPath.trim().length() > 0) {
PackageLib.setLuaPath(luaPath); PackageLib.setLuaPath(luaPath);
} }

View File

@@ -83,7 +83,8 @@ public class ClientConnectionTask implements Runnable, DebugEventListener {
} }
} catch (EOFException e) { } catch (EOFException e) {
// client has terminated the connection // client has terminated the connection
// it's time to exit. // it may be time to exit.
handleRequest(new DebugMessage(DebugMessageType.reset));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();

View File

@@ -218,22 +218,24 @@ public class LuaJVMTest extends TestCase {
fail("Should never reach this line."); fail("Should never reach this line.");
} }
args = new String[] { "-LC:\\lua\\scripts", "dummy.lua" }; System.setProperty("LUA_PATH", "c:/work/CSI/prototypes/uidemo/?.lua");
args = new String[] {"dummy.lua" };
vm = new StandardLuaJVM(); vm = new StandardLuaJVM();
try { try {
vm.parse(args); vm.parse(args);
assertEquals("C:\\lua\\scripts", vm.getLuaPath()); assertEquals("c:/work/CSI/prototypes/uidemo/?.lua", vm.getLuaPath());
assertEquals("dummy.lua", vm.getScript()); assertEquals("dummy.lua", vm.getScript());
} catch (ParseException e) { } catch (ParseException e) {
fail("Should never reach this line."); fail("Should never reach this line.");
} }
args = new String[] { "-Dport=1044", "-LC:\\lua\\scripts", "dummy.lua" }; System.setProperty("LUA_PATH", "c:/work/CSI/prototypes/uidemo/?.lua");
args = new String[] { "-Dport=1044", "dummy.lua" };
vm = new StandardLuaJVM(); vm = new StandardLuaJVM();
try { try {
vm.parse(args); vm.parse(args);
assertEquals(1044, vm.getDebugPort()); assertEquals(1044, vm.getDebugPort());
assertEquals("C:\\lua\\scripts", vm.getLuaPath()); assertEquals("c:/work/CSI/prototypes/uidemo/?.lua", vm.getLuaPath());
assertEquals("dummy.lua", vm.getScript()); assertEquals("dummy.lua", vm.getScript());
} catch (ParseException e) { } catch (ParseException e) {
fail("Should never reach this line."); fail("Should never reach this line.");