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

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

Introduction

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

Prototype

int NOT_ENUMERABLE

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

Click Source Link

Document

ECMA 8.6.1 - Is this property not enumerable?

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;/*from  w w  w .j  a  va  2s.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);
}

From source file:org.kihara.util.JavascriptEngine.java

License:Open Source License

/**
 * Runs launches "fx:bootstrap.js" with the given JavaScript files provided
 * as arguments.//from w w w  . j a v a 2 s. co  m
 *
 * @param context the nashorn context
 * @param global the global scope
 * @param files the list of script files to provide
 *
 * @return error code
 * @throws IOException when any script file read results in I/O error
 */
private static int runFXScripts(final Context context, final ScriptObject global, final List<String> files)
        throws IOException {
    final ScriptObject oldGlobal = Context.getGlobal();
    final boolean globalChanged = (oldGlobal != global);
    try {
        if (globalChanged) {
            Context.setGlobal(global);
        }

        global.addOwnProperty("$GLOBAL", Property.NOT_ENUMERABLE, global);
        global.addOwnProperty("$SCRIPTS", Property.NOT_ENUMERABLE, files);
        context.load(global, "fx:bootstrap.js");
    } catch (final NashornException e) {
        context.getErrorManager().error(e.toString());
        if (context.getEnv()._dump_on_error) {
            e.printStackTrace(context.getErr());
        }

        return RUNTIME_ERROR;
    } finally {
        context.getOut().flush();
        context.getErr().flush();
        if (globalChanged) {
            Context.setGlobal(oldGlobal);
        }
    }

    return SUCCESS;
}