Method

WPEJavaScriptCoreValuetyped_array_get_data

Declaration [src]

gpointer
jsc_value_typed_array_get_data (
  JSCValue* value,
  gsize* length
)

Description [src]

Obtains a pointer to the memory region that holds the elements of the typed array; modifications done to them will be visible to JavaScript code. If length is not NULL, the number of elements contained in the typed array are also stored in the pointed location.

The returned pointer needs to be casted to the appropriate type (see JSCTypedArrayType), and has the offset over the underlying array buffer data applied—that is, points to the first element of the typed array:

if (jsc_value_typed_array_get_type(value) != JSC_TYPED_ARRAY_UINT32)
    g_error ("Only arrays of uint32_t are supported");

gsize count = 0;
uint32_t *elements = jsc_value_typed_array_get_contents (value, &count);
for (gsize i = 0; i < count; i++)
     g_print ("index %zu, value %" PRIu32 "\n", i, elements[i]);

Note that the pointer returned by this function is not guaranteed to remain the same after calls to other JSC API functions. See jsc_value_array_buffer_get_data() for details.

Available since:2.38

Parameters

length gsize*
 

Location to return the number of elements contained.

 The argument will be set by the function.
 The argument can be set to NULL.

Return value

Returns: gpointer
 

Pointer to memory.

 The data is owned by the instance.
 The return value can be NULL.