From e7a6df77f343d0c8f8f42e38921f0716edd5e811 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Fri, 12 Jun 2009 15:12:46 +0000 Subject: [PATCH] directly call java script method instead of parsing GENERATE_MESSAGE calls --- .../se/sics/cooja/plugins/ScriptParser.java | 29 +++---------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/plugins/ScriptParser.java b/tools/cooja/java/se/sics/cooja/plugins/ScriptParser.java index 0ef07be75..6d4b73db8 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/ScriptParser.java +++ b/tools/cooja/java/se/sics/cooja/plugins/ScriptParser.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ScriptParser.java,v 1.5 2009/05/26 14:27:00 fros4943 Exp $ + * $Id: ScriptParser.java,v 1.6 2009/06/12 15:12:46 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -67,8 +67,6 @@ public class ScriptParser { code = replaceWaitUntils(code); - code = replaceGenerateMessages(code); - this.code = code; } @@ -219,30 +217,11 @@ public class ScriptParser { return code; } - private String replaceGenerateMessages(String code) throws ScriptSyntaxErrorException { - Pattern pattern = Pattern.compile( - "GENERATE_MSG\\(" + - "([0-9]+)" /* timeout */ + - "[\\s]*,[\\s]*" + - "(.*)" /* code */ + - "\\)" - ); - Matcher matcher = pattern.matcher(code); - - while (matcher.find()) { - long time = Long.parseLong(matcher.group(1))*Simulation.MILLISECOND; - String msg = matcher.group(2); - - code = matcher.replaceFirst( - "log.generateMessage(" + time + "," + msg + ")"); - matcher.reset(code); - } - - return code; - } - public String getJSCode() { return + "function GENERATE_MSG(time, msg) { " + + " log.generateMessage(time, msg); " + + "};\n" + "function SCRIPT_KILL() { " + " SEMAPHORE_SIM.release(100); " + " throw('test script killed'); " +