Native Client

pp::VarArrayBuffer Class Reference

VarArrayBuffer provides a way to interact with JavaScript ArrayBuffers, which represent a contiguous sequence of bytes. More...

Inheritance diagram for pp::VarArrayBuffer:

List of all members.

Public Functions

 VarArrayBuffer (const Var &var)
 VarArrayBuffer (uint32_t size_in_bytes)
 VarArrayBuffer (const VarArrayBuffer &buffer)
virtual ~VarArrayBuffer ()
VarArrayBufferoperator= (const VarArrayBuffer &other)
virtual Varoperator= (const Var &other)
uint32_t ByteLength () const
void * Map ()
void Unmap ()

Detailed Description

VarArrayBuffer provides a way to interact with JavaScript ArrayBuffers, which represent a contiguous sequence of bytes.

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 Instance.


Constructor and Destructor Details

pp::VarArrayBuffer::VarArrayBuffer ( const Var var) [explicit]

Contruct a VarArrayBuffer given a var for which is_array_buffer() is true.

This will refer to the same ArrayBuffer as var, but allows you to access methods specific to VarArrayBuffer.

Parameters:
[in]varAn ArrayBuffer var.
pp::VarArrayBuffer::VarArrayBuffer ( uint32_t  size_in_bytes) [explicit]

Construct a new VarArrayBuffer_Dev which is size_in_bytes bytes long and initialized to zero.

Parameters:
[in]size_in_bytesThe size of the constructed ArrayBuffer in bytes.
pp::VarArrayBuffer::VarArrayBuffer ( const VarArrayBuffer buffer) [inline]

Copy constructor.

virtual pp::VarArrayBuffer::~VarArrayBuffer ( ) [inline, virtual]

Function Details

uint32_t pp::VarArrayBuffer::ByteLength ( ) const

ByteLength() retrieves the length of the VarArrayBuffer in bytes.

Returns:
The length of the VarArrayBuffer in bytes.
void* pp::VarArrayBuffer::Map ( )

Map() maps the ArrayBuffer in to the module's address space and returns a pointer to the beginning of the internal buffer for this ArrayBuffer.

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 = static_cast<char*>(array_buffer_var.Map());
   uint32_t byte_length = array_buffer_var.ByteLength();
   for (uint32_t i = 0; i < byte_length; ++i)
     data[i] = 'A';
Returns:
A pointer to the internal buffer for this ArrayBuffer.
virtual Var& pp::VarArrayBuffer::operator= ( const Var other) [virtual]

This function assigns one VarArrayBuffer to another VarArrayBuffer.

A Var's assignment operator is overloaded here so that we can check for assigning a non-ArrayBuffer var to a VarArrayBuffer_Dev.

Parameters:
[in]otherThe VarArrayBuffer to be assigned.
Returns:
The resulting VarArrayBuffer (as a Var&).

Reimplemented from pp::Var.

VarArrayBuffer& pp::VarArrayBuffer::operator= ( const VarArrayBuffer other)

This function assigns one VarArrayBuffer to another VarArrayBuffer.

Parameters:
[in]otherThe VarArrayBuffer to be assigned.
Returns:
The resulting VarArrayBuffer.
void pp::VarArrayBuffer::Unmap ( )

Unmap() unmaps this 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 documentation for this class was generated from the following file:

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.