Pepper_31_C_interfaces
Public Attributes | List of all members
PPB_VarArrayBuffer_1_0 Struct Reference

#include <ppb_var_array_buffer.h>

Collaboration diagram for PPB_VarArrayBuffer_1_0:
Collaboration graph

Public Attributes

struct PP_Var(* Create )(uint32_t size_in_bytes)
 
PP_Bool(* ByteLength )(struct PP_Var array, uint32_t *byte_length)
 
void *(* Map )(struct PP_Var array)
 
void(* Unmap )(struct PP_Var array)
 

Detailed Description

The PPB_VarArrayBuffer interface provides a way to interact with JavaScript ArrayBuffers, which represent a contiguous sequence of bytes. Use PPB_Var to manage the reference count for a VarArrayBuffer. Note that these Vars are not part of the embedding page's DOM, and can only be shared with JavaScript using the PostMessage and HandleMessage functions of pp::Instance.

Definition at line 39 of file ppb_var_array_buffer.h.

Member Data Documentation

PP_Bool(* PPB_VarArrayBuffer_1_0::ByteLength)(struct PP_Var array, uint32_t *byte_length)

ByteLength() retrieves the length of the VarArrayBuffer in bytes. On success, byte_length is set to the length of the given ArrayBuffer var. On failure, byte_length is unchanged (this could happen, for instance, if the given PP_Var is not of type PP_VARTYPE_ARRAY_BUFFER). Note that ByteLength() will successfully retrieve the size of an ArrayBuffer even if the ArrayBuffer is not currently mapped.

Parameters
[in]arrayThe ArrayBuffer whose length should be returned.
[out]byte_lengthA variable which is set to the length of the given ArrayBuffer on success.
Returns
PP_TRUE on success, PP_FALSE on failure.

Definition at line 68 of file ppb_var_array_buffer.h.

struct PP_Var(* PPB_VarArrayBuffer_1_0::Create)(uint32_t size_in_bytes)

Create() creates a zero-initialized VarArrayBuffer.

Parameters
[in]size_in_bytesThe size of the ArrayBuffer to be created.
Returns
A PP_Var representing a VarArrayBuffer of the requested size and with a reference count of 1.

Definition at line 49 of file ppb_var_array_buffer.h.

void*(* PPB_VarArrayBuffer_1_0::Map)(struct PP_Var array)

Map() maps the ArrayBuffer in to the module's address space and returns a pointer to the beginning of the buffer for the given ArrayBuffer PP_Var. ArrayBuffers are copied when transmitted, so changes to the underlying memory are not automatically available to the embedding page.

Note that calling Map() can be a relatively expensive operation. Use care when calling it in performance-critical code. For example, you should call it only once when looping over an ArrayBuffer.

Example:

char* data = (char*)(array_buffer_if.Map(array_buffer_var));
uint32_t byte_length = 0;
PP_Bool ok = array_buffer_if.ByteLength(array_buffer_var, &byte_length);
if (!ok)
return DoSomethingBecauseMyVarIsNotAnArrayBuffer();
for (uint32_t i = 0; i < byte_length; ++i)
data[i] = 'A';
Parameters
[in]arrayThe ArrayBuffer whose internal buffer should be returned.
Returns
A pointer to the internal buffer for this ArrayBuffer. Returns NULL if the given PP_Var is not of type PP_VARTYPE_ARRAY_BUFFER.

Definition at line 100 of file ppb_var_array_buffer.h.

void(* PPB_VarArrayBuffer_1_0::Unmap)(struct PP_Var array)

Unmap() unmaps the given ArrayBuffer var from the module address space. Use this if you want to save memory but might want to call Map() to map the buffer again later. The PP_Var remains valid and should still be released using PPB_Var when you are done with the ArrayBuffer.

Parameters
[in]arrayThe ArrayBuffer to be released.

Definition at line 110 of file ppb_var_array_buffer.h.


The documentation for this struct was generated from the following file: