X-Git-Url: http://git.megacz.com/?p=nestedvm.git;a=blobdiff_plain;f=src%2Ftests%2FCallTest.java;h=1d57bceab3241f82c922c779b56115320bab7670;hp=0e56a5f40c5eb053ad2a56beb873509a18f3af01;hb=b11e7c6c29f2b5f7b0828bf93eb741c4a30ec411;hpb=3eb15f58ca0911489d7d9bdc0ac2c575d27a68d8 diff --git a/src/tests/CallTest.java b/src/tests/CallTest.java index 0e56a5f..1d57bce 100644 --- a/src/tests/CallTest.java +++ b/src/tests/CallTest.java @@ -1,9 +1,12 @@ +// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Licensed under the Apache License 2.0 ("the License"). +// You may not use this file except in compliance with the License. + package tests; -import org.xwt.mips.Runtime; -import org.xwt.mips.Interpreter; +import org.ibex.nestedvm.Runtime; import java.io.*; -import java.util.*; +import java.util.Date; public class CallTest { public static void main(String[] args) throws Exception { @@ -15,26 +18,28 @@ public class CallTest { int a6 = args.length > 5 ? Integer.parseInt(args[5]) : 0; System.out.println("Version is: " + System.getProperty("os.version")); - Runtime rt; + final Runtime rt; if(a1 == 99) // yeah.. this is ugly - rt = new Interpreter("build/tests/Test.mips"); + rt = new org.ibex.nestedvm.Interpreter("build/tests/Test.mips"); else - rt = new Test() { - protected int callJava(int a, int b, int c, int d) { + rt = (Runtime) Class.forName("tests.Test").newInstance(); + + rt.setCallJavaCB(new Runtime.CallJavaCB() { + public int call(int a, int b, int c, int d) { switch(a) { - case 1: return strdup("OS: " + System.getProperty("os.name")); - case 2: return strdup(System.getProperty("os.version")); - case 3: return strdup(new Date().toString()); - case 4: return allocFDEnt(new OutputStreamFD(new CustomOS())); + case 1: return rt.strdup("OS: " + System.getProperty("os.name")); + case 2: return rt.strdup(System.getProperty("os.version")); + case 3: return rt.strdup(new Date().toString()); + case 4: return rt.addFD(new Runtime.InputOutputStreamFD(null,new CustomOS())); case 5: System.out.println("In callJava() in Java"); - try { call("backinmips"); } catch(CallException e) { } + try { rt.call("backinmips"); } catch(Runtime.CallException e) { } System.out.println("Back in callJava() in Java"); return 0; - default: return super.callJava(a,b,c,d); + default: return 0; } } - }; + }); System.out.println("Runtime: " + rt); rt.start(new String[]{"Test","calltest"}); @@ -42,12 +47,13 @@ public class CallTest { System.out.println("== Start of CallTest =="); System.out.println("Back in java... calling callme()"); - int ret = rt.call("callme",a1,a2,a3,a4,a5,a6); + int ret = rt.call("callme",new int[]{a1,a2,a3,a4,a5,a6}); System.out.println("callme returned: " + ret); int addr = rt.strdup("Hello, World from java"); rt.call("echo",addr,4); rt.free(addr); + rt.call("echo",new Object[]{"Hello, World, from the Object[] call method",new Integer(2)}); System.out.println("== End of CallTest =="); rt.execute();