本文整理汇总了Java中org.mozilla.javascript.ScriptRuntime.toNumber方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptRuntime.toNumber方法的具体用法?Java ScriptRuntime.toNumber怎么用?Java ScriptRuntime.toNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.ScriptRuntime
的用法示例。
在下文中一共展示了ScriptRuntime.toNumber方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: js_setFloat
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private void js_setFloat(int bytes, Object[] args)
{
checkOffset(args, 0);
checkValue(args, 1);
int pos = ScriptRuntime.toInt32(args[0]);
rangeCheck(pos, bytes);
boolean littleEndian =
(isArg(args, 2) && (bytes > 1) && ScriptRuntime.toBoolean(args[2]));
double val = ScriptRuntime.toNumber(args[1]);
switch (bytes) {
case 4:
ByteIo.writeFloat32(arrayBuffer.buffer, offset + pos, val, littleEndian);
break;
case 8:
ByteIo.writeFloat64(arrayBuffer.buffer, offset + pos, val, littleEndian);
break;
default:
throw new AssertionError();
}
}
示例2: toUint8Clamp
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
public static int toUint8Clamp(Object arg)
{
double d = ScriptRuntime.toNumber(arg);
if (d <= 0.0) {
return 0;
}
if (d >= 255.0) {
return 255;
}
// Complex rounding behavior -- see 7.1.11
double f = Math.floor(d);
if ((f + 0.5) < d) {
return (int)(f + 1.0);
}
if (d < (f + 0.5)) {
return (int)f;
}
if (((int)f % 2) != 0) {
return (int)f + 1;
}
return (int)f;
}
示例3: js_set
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
@Override
protected Object js_set(int index, Object c)
{
if (checkIndex(index)) {
return Undefined.instance;
}
double val = ScriptRuntime.toNumber(c);
long base = Double.doubleToLongBits(val);
ByteIo.writeUint64(arrayBuffer.buffer, (index * BYTES_PER_ELEMENT) + offset, base, false);
return null;
}
示例4: js_set
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
@Override
protected Object js_set(int index, Object c)
{
if (checkIndex(index)) {
return Undefined.instance;
}
double val = ScriptRuntime.toNumber(c);
ByteIo.writeFloat32(arrayBuffer.buffer, (index * BYTES_PER_ELEMENT) + offset, val, false);
return null;
}
示例5: setInstanceIdValue
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
@Override
protected void setInstanceIdValue(int id, Object value)
{
switch (id) {
case Id_lastIndex:
lastIndex = ScriptRuntime.toNumber(value);
return;
case Id_source:
case Id_global:
case Id_ignoreCase:
case Id_multiline:
return;
}
super.setInstanceIdValue(id, value);
}
示例6: toInt32
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
public static int toInt32(Object arg)
{
long lv = (long)ScriptRuntime.toNumber(arg);
long int32Bit = lv % THIRTYTWO_BIT;
return (int)((int32Bit >= (1L << 31L)) ? (int32Bit - THIRTYTWO_BIT) : int32Bit);
}
示例7: toUint32
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
public static long toUint32(Object arg)
{
long lv = (long)ScriptRuntime.toNumber(arg);
return lv % THIRTYTWO_BIT;
}