Java Code Examples for jdk.nashorn.internal.runtime.JSType#toUint16()

The following examples show how to use jdk.nashorn.internal.runtime.JSType#toUint16() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NativeString.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , ... ] ] ] )
 * @param self  self reference
 * @param args  array of arguments to be interpreted as char
 * @return string with arguments translated to charcodes
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1, where = Where.CONSTRUCTOR)
public static String fromCharCode(final Object self, final Object... args) {
    final char[] buf = new char[args.length];
    int index = 0;
    for (final Object arg : args) {
        buf[index++] = (char)JSType.toUint16(arg);
    }
    return new String(buf);
}
 
Example 2
Source File: NativeString.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , ... ] ] ] )
 * @param self  self reference
 * @param args  array of arguments to be interpreted as char
 * @return string with arguments translated to charcodes
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1, where = Where.CONSTRUCTOR)
public static String fromCharCode(final Object self, final Object... args) {
    final char[] buf = new char[args.length];
    int index = 0;
    for (final Object arg : args) {
        buf[index++] = (char)JSType.toUint16(arg);
    }
    return new String(buf);
}
 
Example 3
Source File: NativeString.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , ... ] ] ] )
 * @param self  self reference
 * @param args  array of arguments to be interpreted as char
 * @return string with arguments translated to charcodes
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1, where = Where.CONSTRUCTOR)
public static String fromCharCode(final Object self, final Object... args) {
    final char[] buf = new char[args.length];
    int index = 0;
    for (final Object arg : args) {
        buf[index++] = (char)JSType.toUint16(arg);
    }
    return new String(buf);
}
 
Example 4
Source File: NativeString.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , ... ] ] ] )
 * @param self  self reference
 * @param args  array of arguments to be interpreted as char
 * @return string with arguments translated to charcodes
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1, where = Where.CONSTRUCTOR)
public static String fromCharCode(final Object self, final Object... args) {
    final char[] buf = new char[args.length];
    int index = 0;
    for (final Object arg : args) {
        buf[index++] = (char)JSType.toUint16(arg);
    }
    return new String(buf);
}
 
Example 5
Source File: NativeString.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , ... ] ] ] )
 * @param self  self reference
 * @param args  array of arguments to be interpreted as char
 * @return string with arguments translated to charcodes
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1, where = Where.CONSTRUCTOR)
public static String fromCharCode(final Object self, final Object... args) {
    final char[] buf = new char[args.length];
    int index = 0;
    for (final Object arg : args) {
        buf[index++] = (char)JSType.toUint16(arg);
    }
    return new String(buf);
}
 
Example 6
Source File: NativeString.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , ... ] ] ] )
 * @param self  self reference
 * @param args  array of arguments to be interpreted as char
 * @return string with arguments translated to charcodes
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1, where = Where.CONSTRUCTOR)
public static String fromCharCode(final Object self, final Object... args) {
    final char[] buf = new char[args.length];
    int index = 0;
    for (final Object arg : args) {
        buf[index++] = (char)JSType.toUint16(arg);
    }
    return new String(buf);
}
 
Example 7
Source File: NativeString.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , ... ] ] ] )
 * @param self  self reference
 * @param args  array of arguments to be interpreted as char
 * @return string with arguments translated to charcodes
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1, where = Where.CONSTRUCTOR)
public static Object fromCharCode(final Object self, final Object... args) {
    final char[] buf = new char[args.length];
    int index = 0;
    for (final Object arg : args) {
        buf[index++] = (char)JSType.toUint16(arg);
    }
    return new String(buf);
}
 
Example 8
Source File: NativeString.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.5.3.2 - specialization for one char
 * @param self  self reference
 * @param value one argument to be interpreted as char
 * @return string with one charcode
 */
@SpecializedFunction
public static Object fromCharCode(final Object self, final Object value) {
    try {
        return "" + (char)JSType.toUint16(((Number)value).doubleValue());
    } catch (final ClassCastException e) {
        return fromCharCode(self, new Object[] { value });
    }
}
 
Example 9
Source File: NativeString.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , ... ] ] ] )
 * @param self  self reference
 * @param args  array of arguments to be interpreted as char
 * @return string with arguments translated to charcodes
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1, where = Where.CONSTRUCTOR)
public static Object fromCharCode(final Object self, final Object... args) {
    final char[] buf = new char[args.length];
    int index = 0;
    for (final Object arg : args) {
        buf[index++] = (char)JSType.toUint16(arg);
    }
    return new String(buf);
}
 
Example 10
Source File: NativeString.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.5.3.2 - specialization for one char
 * @param self  self reference
 * @param value one argument to be interpreted as char
 * @return string with one charcode
 */
@SpecializedFunction
public static Object fromCharCode(final Object self, final Object value) {
    try {
        return "" + (char)JSType.toUint16(((Number)value).doubleValue());
    } catch (final ClassCastException e) {
        return fromCharCode(self, new Object[] { value });
    }
}
 
Example 11
Source File: NativeString.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , ... ] ] ] )
 * @param self  self reference
 * @param args  array of arguments to be interpreted as char
 * @return string with arguments translated to charcodes
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1, where = Where.CONSTRUCTOR)
public static String fromCharCode(final Object self, final Object... args) {
    final char[] buf = new char[args.length];
    int index = 0;
    for (final Object arg : args) {
        buf[index++] = (char)JSType.toUint16(arg);
    }
    return new String(buf);
}
 
Example 12
Source File: NativeString.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , ... ] ] ] )
 * @param self  self reference
 * @param args  array of arguments to be interpreted as char
 * @return string with arguments translated to charcodes
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1, where = Where.CONSTRUCTOR)
public static Object fromCharCode(final Object self, final Object... args) {
    final char[] buf = new char[args.length];
    int index = 0;
    for (final Object arg : args) {
        buf[index++] = (char)JSType.toUint16(arg);
    }
    return new String(buf);
}
 
Example 13
Source File: NativeString.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.5.3.2 - specialization for one char
 * @param self  self reference
 * @param value one argument to be interpreted as char
 * @return string with one charcode
 */
@SpecializedFunction
public static Object fromCharCode(final Object self, final Object value) {
    try {
        return "" + (char)JSType.toUint16(((Number)value).doubleValue());
    } catch (final ClassCastException e) {
        return fromCharCode(self, new Object[] { value });
    }
}
 
Example 14
Source File: NativeString.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * ECMA 15.5.3.2 - specialization for one char of double type
 * @param self  self reference
 * @param value one argument to be interpreted as char
 * @return string with one charcode
 */
@SpecializedFunction
public static Object fromCharCode(final Object self, final double value) {
    return "" + (char)JSType.toUint16(value);
}
 
Example 15
Source File: NativeString.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * ECMA 15.5.3.2 - specialization for one char of double type
 * @param self  self reference
 * @param value one argument to be interpreted as char
 * @return string with one charcode
 */
@SpecializedFunction
public static Object fromCharCode(final Object self, final double value) {
    return "" + (char)JSType.toUint16(value);
}
 
Example 16
Source File: NativeString.java    From nashorn with GNU General Public License v2.0 2 votes vote down vote up
/**
 * ECMA 15.5.3.2 - specialization for one char of double type
 * @param self  self reference
 * @param value one argument to be interpreted as char
 * @return string with one charcode
 */
@SpecializedFunction
public static Object fromCharCode(final Object self, final double value) {
    return "" + (char)JSType.toUint16(value);
}