Example usage for jdk.nashorn.internal.runtime Property NOT_WRITABLE

List of usage examples for jdk.nashorn.internal.runtime Property NOT_WRITABLE

Introduction

In this page you can find the example usage for jdk.nashorn.internal.runtime Property NOT_WRITABLE.

Prototype

int NOT_WRITABLE

To view the source code for jdk.nashorn.internal.runtime Property NOT_WRITABLE.

Click Source Link

Document

ECMA 8.6.1 - Is this property not writable?

Usage

From source file:com.mckoi.mwpui.nodejs.nashorn.NashornJSSystem.java

License:Open Source License

@Override
public ByteBuffer allocateExternalArrayDataOf(GJSObject source, int alloc_size) {

    ScriptObjectMirror nashorn_ob = (ScriptObjectMirror) source.internalGetNative();
    // Allocate the buffer,
    ByteBuffer bb = ByteBuffer.allocate(alloc_size);
    // We use the unwrapped nashorn object as a key,
    ScriptObject script_ob = (ScriptObject) instance_global.unwrap(nashorn_ob);

    // The ByteBuffer property should be read only,
    int ro_flags = Property.NOT_WRITABLE | Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE;

    script_ob.addOwnProperty(BYTEBUFFER_OBJECT_PROPERTY_NAME, ro_flags, bb);
    nashorn_ob.setIndexedPropertiesToExternalArrayData(bb);
    return bb;//w w w . j  ava 2 s.co  m
}

From source file:com.mckoi.mwpui.nodejs.nashorn.NashornJSSystem.java

License:Open Source License

void setROHiddenMember(JSObject ob, String name, Object value) {
    // We use the unwrapped nashorn object,
    ScriptObject script_ob = (ScriptObject) instance_global.unwrap(ob);
    // Read-only hidden property flags,
    int ro_flags = Property.NOT_WRITABLE | Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE;
    script_ob.addOwnProperty(name, ro_flags, value);
}