Java Code Examples for jdk.nashorn.internal.objects.annotations.Attribute#NOT_CONFIGURABLE

The following examples show how to use jdk.nashorn.internal.objects.annotations.Attribute#NOT_CONFIGURABLE . 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: NativeArray.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Length getter
 * @param self self reference
 * @return the length of the object
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
public static Object length(final Object self) {
    if (isArray(self)) {
        final long length = ((ScriptObject) self).getArray().length();
        assert length >= 0L;
        // Cast to the narrowest supported numeric type to help optimistic type calculator
        if (length <= Integer.MAX_VALUE) {
            return (int) length;
        }
        return (double) length;
    }

    return 0;
}
 
Example 2
Source File: NativeArray.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Length getter
 * @param self self reference
 * @return the length of the object
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
public static Object length(final Object self) {
    if (isArray(self)) {
        return JSType.toUint32(((ScriptObject) self).getArray().length());
    }

    return 0;
}
 
Example 3
Source File: NativeArray.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Length getter
 * @param self self reference
 * @return the length of the object
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
public static Object length(final Object self) {
    if (isArray(self)) {
        final long length = ((ScriptObject) self).getArray().length();
        assert length >= 0L;
        // Cast to the narrowest supported numeric type to help optimistic type calculator
        if (length <= Integer.MAX_VALUE) {
            return (int) length;
        }
        return (double) length;
    }

    return 0;
}
 
Example 4
Source File: NativeRegExpExecResult.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Length getter
 * @param self self reference
 * @return length property value
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
public static Object length(final Object self) {
    if (self instanceof ScriptObject) {
        return (double) JSType.toUint32(((ScriptObject)self).getArray().length());
    }

    return 0;
}
 
Example 5
Source File: ArrayBufferView.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Byte length getter as per spec
 * @param self ArrayBufferView instance
 * @return array buffer view length in bytes
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
public static int byteLength(final Object self) {
    final ArrayBufferView view = (ArrayBufferView)self;
    return ((TypedArrayData<?>)view.getArray()).getElementLength() * view.bytesPerElement();
}
 
Example 6
Source File: ArrayBufferView.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Byte length getter as per spec
 * @param self ArrayBufferView instance
 * @return array buffer view length in bytes
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
public static int byteLength(final Object self) {
    final ArrayBufferView view = (ArrayBufferView)self;
    return ((TypedArrayData<?>)view.getArray()).getElementLength() * view.bytesPerElement();
}
 
Example 7
Source File: NativeString.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * ECMA 15.5.3 String.length
 * @param self self reference
 * @return     value of length property for string
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
public static Object length(final Object self) {
    return getCharSequence(self).length();
}
 
Example 8
Source File: NativeArray.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Prototype length setter
 * @param self   self reference
 * @param length new length property
 */
@Setter(name = "length", where = Where.PROTOTYPE, attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
public static void setProtoLength(final Object self, final Object length) {
    length(self, length);  // Same as instance setter but we can't make nasgen use the same method for prototype
}
 
Example 9
Source File: NativeArrayBuffer.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Byte length for native array buffer
 * @param self native array buffer
 * @return byte length
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
public static int byteLength(final Object self) {
    return ((NativeArrayBuffer)self).getByteLength();
}
 
Example 10
Source File: NativeArrayBuffer.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Byte length for native array buffer
 * @param self native array buffer
 * @return byte length
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
public static int byteLength(final Object self) {
    return ((NativeArrayBuffer)self).getByteLength();
}
 
Example 11
Source File: NativeString.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * ECMA 15.5.3 String.length
 * @param self self reference
 * @return     value of length property for string
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
public static Object length(final Object self) {
    return getCharSequence(self).length();
}
 
Example 12
Source File: ArrayBufferView.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Buffer getter as per spec
 * @param self ArrayBufferView instance
 * @return buffer
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
public static Object buffer(final Object self) {
    return ((ArrayBufferView)self).buffer;
}
 
Example 13
Source File: NativeArray.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Prototype length setter
 * @param self   self reference
 * @param length new length property
 */
@Setter(name = "length", where = Where.PROTOTYPE, attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
public static void setProtoLength(final Object self, final Object length) {
    length(self, length);  // Same as instance setter but we can't make nasgen use the same method for prototype
}
 
Example 14
Source File: ArrayBufferView.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Buffer offset getter as per spec
 * @param self ArrayBufferView instance
 * @return buffer offset
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
public static int byteOffset(final Object self) {
    return ((ArrayBufferView)self).byteOffset;
}
 
Example 15
Source File: ArrayBufferView.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Buffer getter as per spec
 * @param self ArrayBufferView instance
 * @return buffer
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
public static Object buffer(final Object self) {
    return ((ArrayBufferView)self).buffer;
}
 
Example 16
Source File: NativeArray.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Prototype length getter
 * @param self self reference
 * @return the length of the object
 */
@Getter(name = "length", where = Where.PROTOTYPE, attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
public static Object getProtoLength(final Object self) {
    return length(self);  // Same as instance getter but we can't make nasgen use the same method for prototype
}
 
Example 17
Source File: NativeArrayBuffer.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Byte length for native array buffer
 * @param self native array buffer
 * @return byte length
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
public static int byteLength(final Object self) {
    return ((NativeArrayBuffer)self).getByteLength();
}
 
Example 18
Source File: NativeString.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * ECMA 15.5.3 String.length
 * @param self self reference
 * @return     value of length property for string
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
public static Object length(final Object self) {
    return getCharSequence(self).length();
}
 
Example 19
Source File: ArrayBufferView.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Buffer offset getter as per spec
 * @param self ArrayBufferView instance
 * @return buffer offset
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
public static int byteOffset(final Object self) {
    return ((ArrayBufferView)self).byteOffset;
}
 
Example 20
Source File: NativeArrayBuffer.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Byte length for native array buffer
 * @param self native array buffer
 * @return byte length
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE)
public static int byteLength(final Object self) {
    return ((NativeArrayBuffer)self).getByteLength();
}