Tabnine Logo
V8TypedArray.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
com.eclipsesource.v8.V8TypedArray
constructor

Best Java code snippets using com.eclipsesource.v8.V8TypedArray.<init> (Showing top 20 results out of 315)

origin: eclipsesource/J2V8

@Override
protected V8Value createTwin() {
  v8.checkThread();
  checkReleased();
  return new V8TypedArray(v8);
}
origin: eclipsesource/J2V8

/**
 * Create a new TypedArray from an ArrayBuffer.
 *
 * @param v8 the V8Runtime on which to create the TypedArray
 * @param buffer the ArrayBuffer to use to back the TypedArray
 * @param type the Type of Array to create
 * @param offset the Offset into the ArrayBuffer in which to map the TyepdArray
 * @param size the Size of the TypedArray
 */
public TypedArray(final V8 v8, final ArrayBuffer buffer, final int type, final int offset, final int size) {
  V8ArrayBuffer v8ArrayBuffer = buffer.getV8ArrayBuffer();
  V8TypedArray v8typedArray = new V8TypedArray(v8, v8ArrayBuffer, type, offset, size);
  try {
    typedArray = (V8TypedArray) v8typedArray.twin().setWeak();
  } finally {
    v8ArrayBuffer.close();
    v8typedArray.close();
  }
}
origin: eclipsesource/J2V8

@Override
protected V8Value createTwin() {
  v8.checkThread();
  checkReleased();
  return new V8TypedArray(v8);
}
origin: eclipsesource/J2V8

@Test
public void testV8HandleCreated_V8TypedArray() {
  ReferenceHandler referenceHandler = mock(ReferenceHandler.class);
  v8.addReferenceHandler(referenceHandler);
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 100);
  V8TypedArray object = new V8TypedArray(v8, buffer, V8Value.INT_16_ARRAY, 0, 50);
  verify(referenceHandler, times(1)).v8HandleCreated(buffer);
  verify(referenceHandler, times(1)).v8HandleCreated(object);
  buffer.close();
  object.close();
}
origin: eclipsesource/J2V8

@Test(expected = IllegalArgumentException.class)
public void testCreateTypedArrayWithIllegalType_V8Object() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 10);
  try {
    new V8TypedArray(v8, buffer, V8Value.V8_OBJECT, 0, 10).close();
  } finally {
    buffer.close();
  }
}
origin: eclipsesource/J2V8

@Test(expected = IllegalArgumentException.class)
public void testCreateTypedArrayWithIllegalType_Boolean() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 10);
  try {
    new V8TypedArray(v8, buffer, V8Value.BOOLEAN, 0, 10).close();
  } finally {
    buffer.close();
  }
}
origin: eclipsesource/J2V8

@Test(expected = IllegalArgumentException.class)
public void testCreateTypedArrayWithIllegalType_String() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 10);
  try {
    new V8TypedArray(v8, buffer, V8Value.STRING, 0, 10).close();
  } finally {
    buffer.close();
  }
}
origin: eclipsesource/J2V8

@Test(expected = IllegalArgumentException.class)
public void testCreateTypedArrayWithIllegalType_Null() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 10);
  try {
    new V8TypedArray(v8, buffer, V8Value.NULL, 0, 10).close();
  } finally {
    buffer.close();
  }
}
origin: eclipsesource/J2V8

@Test
public void testCreateFloat64TypedArray() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 8);
  V8TypedArray typedArray = new V8TypedArray(v8, buffer, V8Value.FLOAT_64_ARRAY, 0, 1);
  assertEquals(V8Value.FLOAT_64_ARRAY, typedArray.getType());
  buffer.close();
  typedArray.close();
}
origin: eclipsesource/J2V8

@Test
public void testGetType_TypedArray() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 64);
  V8Array array = new V8TypedArray(v8, buffer, V8Value.INT_8_ARRAY, 0, 8);
  assertEquals(V8Value.V8_TYPED_ARRAY, array.getV8Type());
  array.close();
  buffer.close();
}
origin: eclipsesource/J2V8

@Test
public void testGetArrayBuffer_Int32Array() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 8);
  V8TypedArray v8Int32Array = new V8TypedArray(v8, buffer, V8Value.INTEGER, 0, 2);
  V8ArrayBuffer result = v8Int32Array.getBuffer();
  assertEquals(result, buffer);
  result.close();
  buffer.close();
  v8Int32Array.close();
}
origin: eclipsesource/J2V8

@Test
public void testInt32TypedArray_CustomLength() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 8);
  V8TypedArray v8Int32Array = new V8TypedArray(v8, buffer, V8Value.INTEGER, 0, 1);
  v8.add("v8Int32Array", v8Int32Array);
  assertEquals(1, v8Int32Array.length());
  buffer.close();
  v8Int32Array.close();
}
origin: eclipsesource/J2V8

@Test
public void testGetByteBuffer_Int8Array() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 8);
  V8TypedArray v8Int8Array = new V8TypedArray(v8, buffer, V8Value.BYTE, 0, 2);
  V8ArrayBuffer arrayBuffer = v8Int8Array.getBuffer();
  assertEquals(arrayBuffer, buffer);
  buffer.close();
  v8Int8Array.close();
  arrayBuffer.close();
}
origin: eclipsesource/J2V8

@Test
public void testInt32TypedArray_Length() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 8);
  V8TypedArray v8Int32Array = new V8TypedArray(v8, buffer, V8Value.INTEGER, 0, 2);
  v8.add("v8Int32Array", v8Int32Array);
  assertEquals(2, v8Int32Array.length());
  buffer.close();
  v8Int32Array.close();
}
origin: eclipsesource/J2V8

@Test
public void testInt8TypedArray_CustomOffset() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 8);
  V8TypedArray v8Int8Array = new V8TypedArray(v8, buffer, V8Value.BYTE, 1, 1);
  buffer.put((byte) 4);
  buffer.put((byte) 8);
  assertEquals(1, v8Int8Array.length());
  assertEquals((byte) 8, v8Int8Array.get(0));
  buffer.close();
  v8Int8Array.close();
}
origin: eclipsesource/J2V8

@Test
public void testInt8TypedArray_Twin() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 4);
  V8TypedArray v8Int8Array = new V8TypedArray(v8, buffer, V8Value.BYTE, 0, 4);
  V8Array twinArray = v8Int8Array.twin();
  assertTrue(twinArray instanceof V8TypedArray);
  assertEquals(V8Value.BYTE, twinArray.getType());
  assertEquals(v8Int8Array, twinArray);
  v8Int8Array.close();
  twinArray.close();
  buffer.close();
}
origin: eclipsesource/J2V8

@Test
public void testInt32TypedArray_CustomOffset() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 8);
  V8TypedArray v8Int32Array = new V8TypedArray(v8, buffer, V8Value.INTEGER, 4, 1);
  v8.add("v8Int32Array", v8Int32Array);
  buffer.putInt(4);
  buffer.putInt(8);
  assertEquals(1, v8Int32Array.length());
  assertEquals(8, v8Int32Array.getInteger(0));
  buffer.close();
  v8Int32Array.close();
}
origin: eclipsesource/J2V8

@Test
public void testCreateUInt32TypedArray() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 8);
  V8TypedArray typedArray = new V8TypedArray(v8, buffer, V8Value.UNSIGNED_INT_32_ARRAY, 0, 2);
  typedArray.add("0", 7);
  typedArray.add("1", 8);
  assertEquals(V8Value.UNSIGNED_INT_32_ARRAY, typedArray.getType());
  assertEquals(7, buffer.getInt());
  assertEquals(8, buffer.getInt());
  buffer.close();
  typedArray.close();
}
origin: eclipsesource/J2V8

@Test
public void testUInt32TypedArray_addInJava() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 8);
  V8TypedArray typedArray = new V8TypedArray(v8, buffer, V8Value.UNSIGNED_INT_32_ARRAY, 0, 2);
  typedArray.add("0", (long) (Integer.MAX_VALUE + 1));
  typedArray.add("1", -1);
  assertEquals(2, typedArray.length());
  assertEquals(2147483648L, typedArray.get(0));
  assertEquals(4294967295L, typedArray.get(1));
  buffer.close();
  typedArray.close();
}
origin: eclipsesource/J2V8

@Test
public void testUInt8ClampedTypedArray_addInJava() {
  V8ArrayBuffer buffer = new V8ArrayBuffer(v8, 8);
  V8TypedArray v8Int8Array = new V8TypedArray(v8, buffer, V8Value.UNSIGNED_INT_8_CLAMPED_ARRAY, 0, 8);
  v8Int8Array.add("0", (short) 256);
  v8Int8Array.add("1", -1);
  assertEquals(8, v8Int8Array.length());
  assertEquals((short) 255, v8Int8Array.get(0));
  assertEquals((short) 0, v8Int8Array.get(1));
  buffer.close();
  v8Int8Array.close();
}
com.eclipsesource.v8V8TypedArray<init>

Javadoc

Create a new TypedArray from a specified ArrayBuffer, type, offset and size. For example, a V8Int32Array is a typed array where each value is a 32-bit integer. The typed array is backed by the V8ArrayBuffer.

Popular methods of V8TypedArray

  • get
  • getStructureSize
    Computes the size of the structures required for each TypedArray variation.
  • addObjectReference
  • checkArrayProperties
  • checkOffset
  • checkSize
  • createTypedArray
  • close
  • getBuffer
    Provide access to the underlying ByteBuffer used for this TypedArray. The V8ArrayBuffer must be rele
  • getType
  • twin
  • checkReleased
  • twin,
  • checkReleased,
  • getByteBuffer,
  • isReleased,
  • add,
  • getInteger,
  • length

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • getContentResolver (Context)
  • runOnUiThread (Activity)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now