directly call java script method instead of parsing GENERATE_MESSAGE calls
This commit is contained in:
parent
1d504be38c
commit
e7a6df77f3
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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;
|
package se.sics.cooja.plugins;
|
||||||
|
@ -67,8 +67,6 @@ public class ScriptParser {
|
||||||
|
|
||||||
code = replaceWaitUntils(code);
|
code = replaceWaitUntils(code);
|
||||||
|
|
||||||
code = replaceGenerateMessages(code);
|
|
||||||
|
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,30 +217,11 @@ public class ScriptParser {
|
||||||
return code;
|
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() {
|
public String getJSCode() {
|
||||||
return
|
return
|
||||||
|
"function GENERATE_MSG(time, msg) { " +
|
||||||
|
" log.generateMessage(time, msg); " +
|
||||||
|
"};\n" +
|
||||||
"function SCRIPT_KILL() { " +
|
"function SCRIPT_KILL() { " +
|
||||||
" SEMAPHORE_SIM.release(100); " +
|
" SEMAPHORE_SIM.release(100); " +
|
||||||
" throw('test script killed'); " +
|
" throw('test script killed'); " +
|
||||||
|
|
Loading…
Reference in a new issue