1.1 --- a/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java Tue Oct 22 17:38:12 2013 +0530 1.2 +++ b/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java Tue Oct 22 16:43:27 2013 +0200 1.3 @@ -43,6 +43,7 @@ 1.4 import javax.script.Bindings; 1.5 import jdk.nashorn.internal.runtime.Context; 1.6 import jdk.nashorn.internal.runtime.GlobalObject; 1.7 +import jdk.nashorn.internal.runtime.JSType; 1.8 import jdk.nashorn.internal.runtime.ScriptFunction; 1.9 import jdk.nashorn.internal.runtime.ScriptObject; 1.10 import jdk.nashorn.internal.runtime.ScriptRuntime; 1.11 @@ -705,4 +706,45 @@ 1.12 } 1.13 } 1.14 } 1.15 + 1.16 + /** 1.17 + * JavaScript compliant Object to int32 conversion 1.18 + * See ECMA 9.5 ToInt32 1.19 + * 1.20 + * @return this object's int32 representation 1.21 + */ 1.22 + public int toInt32() { 1.23 + return inGlobal(new Callable<Integer>() { 1.24 + @Override public Integer call() { 1.25 + return JSType.toInt32(sobj); 1.26 + } 1.27 + }); 1.28 + } 1.29 + 1.30 + /** 1.31 + * JavaScript compliant Object to int64 conversion 1.32 + * 1.33 + * @return this object's int64 representation 1.34 + */ 1.35 + public long toInt64() { 1.36 + return inGlobal(new Callable<Long>() { 1.37 + @Override public Long call() { 1.38 + return JSType.toInt64(sobj); 1.39 + } 1.40 + }); 1.41 + } 1.42 + 1.43 + /** 1.44 + * JavaScript compliant conversion of Object to number 1.45 + * See ECMA 9.3 ToNumber 1.46 + * 1.47 + * @return this object's number representation 1.48 + */ 1.49 + public double toNumber() { 1.50 + return inGlobal(new Callable<Double>() { 1.51 + @Override public Double call() { 1.52 + return JSType.toNumber(sobj); 1.53 + } 1.54 + }); 1.55 + } 1.56 }