/** * Creates a new V8Array and associates it with the given runtime. * V8Arrays have native resources and as such, must be released. * * @param v8 The runtime on which to associate the V8Array. */ public V8Array(final V8 v8) { super(v8); v8.checkThread(); }
public final V8ArrayBuffer position(final int newPosition) { v8.checkThread(); checkReleased(); byteBuffer.position(newPosition); return this; }
public final V8ArrayBuffer limit(final int newLimit) { v8.checkThread(); checkReleased(); byteBuffer.limit(newLimit); return this; }
public final V8ArrayBuffer mark() { v8.checkThread(); checkReleased(); byteBuffer.mark(); return this; }
public final V8ArrayBuffer flip() { v8.checkThread(); checkReleased(); byteBuffer.flip(); return this; }
public final int remaining() { v8.checkThread(); checkReleased(); return byteBuffer.remaining(); }
public V8ArrayBuffer put(final byte[] src, final int offset, final int length) { v8.checkThread(); checkReleased(); byteBuffer.put(src, offset, length); return this; }
public char getChar() { v8.checkThread(); checkReleased(); return byteBuffer.getChar(); }
public int getInt() { v8.checkThread(); checkReleased(); return byteBuffer.getInt(); }
public V8ArrayBuffer putInt(final int value) { v8.checkThread(); checkReleased(); byteBuffer.putInt(value); return this; }
public int getInt(final int index) { v8.checkThread(); checkReleased(); return byteBuffer.getInt(index); }
public long getLong(final int index) { v8.checkThread(); checkReleased(); return byteBuffer.getLong(index); }
public V8ArrayBuffer putDouble(final double value) { v8.checkThread(); checkReleased(); byteBuffer.putDouble(value); return this; }
/** * Handles the next message in the message loop. Returns True * if there are more messages to handle, false otherwise. * * @return True if there are more messages to handle, false otherwise. */ public boolean handleMessage() { v8.checkThread(); return v8.pumpMessageLoop(); }
public int doubleLimit() { v8.checkThread(); checkReleased(); return byteBuffer.asDoubleBuffer().limit(); }
public boolean isReadOnly() { v8.checkThread(); checkReleased(); return byteBuffer.isReadOnly(); }
@Override public void close() { v8.checkThread(); if (!released) { try { v8.releaseObjRef(this); } finally { released = true; v8.release(v8.getV8RuntimePtr(), objectHandle); } } }
/** * Returns the type of element at this given index. * * @param index The index at which to lookup the type of. * * @return The type of the element at the index. */ public int getType(final int index) { v8.checkThread(); checkReleased(); return v8.getType(v8.getV8RuntimePtr(), getHandle(), index); }
/** * Gets the type of the array. Returns a 'type' if all the elements in the array * have the same type, otherwise UNDEFINED is returned. * * @return The type of all the elements of the array, or UNDEFINED if they * are not all the same type. */ public int getType() { v8.checkThread(); checkReleased(); return v8.getArrayType(v8.getV8RuntimePtr(), getHandle()); }
/** * Releases the NodeJS runtime. */ public void release() { v8.checkThread(); if (!require.isReleased()) { require.close(); } if (!v8.isReleased()) { v8.close(); } }