struct_p_p_b___var_array_buffer__1__0.html revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
1{{+bindTo:partials.standard_nacl_article}}
2<h1>PPB_VarArrayBuffer Struct Reference</h1>
3<div id="doxygen-ref">
4{{- dummy div to appease doxygen -}}
5  <div>
6<!-- Generated by Doxygen 1.7.6.1 -->
7
8
9</div>
10<!--header-->
11<div class="contents">
12<!-- doxytag: class="PPB_VarArrayBuffer" --><h2>
13Data Fields</h2><table class="memberdecls">
14
15<tr><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="struct_p_p___var.html">PP_Var</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#a348f1470a2fc6cba9d430d0544e84225">Create</a> )(uint32_t size_in_bytes)</td></tr>
16<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___enums.html#ga4f272d99be14aacafe08dfd4ef830918">PP_Bool</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#a0ad6305942f991daa6dfe3b579931ea1">ByteLength</a> )(struct <a class="el" href="struct_p_p___var.html">PP_Var</a> array, uint32_t *byte_length)</td></tr>
17<tr><td class="memItemLeft" align="right" valign="top">void *(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#a4c7c25b939f56de64fa3f6f906a7da8c">Map</a> )(struct <a class="el" href="struct_p_p___var.html">PP_Var</a> array)</td></tr>
18<tr><td class="memItemLeft" align="right" valign="top">void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#ac841a12b7eb93dd05bd2b864920e22a7">Unmap</a> )(struct <a class="el" href="struct_p_p___var.html">PP_Var</a> array)</td></tr>
19</table>
20<hr /><a name="details" id="details"></a><h2>Detailed Description</h2>
21<div class="textblock"><p>The <code>PPB_VarArrayBuffer</code> interface provides a way to interact with JavaScript ArrayBuffers, which represent a contiguous sequence of bytes. </p>
22<p>Use <code>PPB_Var</code> to manage the reference count for a <code>VarArrayBuffer</code>. Note that these Vars are not part of the embedding page's DOM, and can only be shared with JavaScript using the <code>PostMessage</code> and <code>HandleMessage</code> functions of <code>pp::Instance</code>. </p>
23</div><hr /><h2>Field Documentation</h2>
24<a class="anchor" id="a0ad6305942f991daa6dfe3b579931ea1"></a><!-- doxytag: member="PPB_VarArrayBuffer::ByteLength" ref="a0ad6305942f991daa6dfe3b579931ea1" args=")(struct PP_Var array, uint32_t *byte_length)" -->
25<div class="memitem">
26<div class="memproto">
27<table class="memname">
28<tr>
29<td class="memname"><a class="el" href="group___enums.html#ga4f272d99be14aacafe08dfd4ef830918">PP_Bool</a>(* <a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#a0ad6305942f991daa6dfe3b579931ea1">PPB_VarArrayBuffer::ByteLength</a>)(struct <a class="el" href="struct_p_p___var.html">PP_Var</a> array, uint32_t *byte_length)</td>
30</tr>
31</table>
32</div>
33<div class="memdoc">
34<p><a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#a0ad6305942f991daa6dfe3b579931ea1" title="ByteLength() retrieves the length of the VarArrayBuffer in bytes.">ByteLength()</a> retrieves the length of the <code>VarArrayBuffer</code> in bytes. </p>
35<p>On success, <code>byte_length</code> is set to the length of the given <code>ArrayBuffer</code> var. On failure, <code>byte_length</code> is unchanged (this could happen, for instance, if the given <code><a class="el" href="struct_p_p___var.html" title="The PP_VAR struct is a variant data type and can contain any value of one of the types named in the P...">PP_Var</a></code> is not of type <code>PP_VARTYPE_ARRAY_BUFFER</code>). Note that <a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#a0ad6305942f991daa6dfe3b579931ea1" title="ByteLength() retrieves the length of the VarArrayBuffer in bytes.">ByteLength()</a> will successfully retrieve the size of an <code>ArrayBuffer</code> even if the <code>ArrayBuffer</code> is not currently mapped.</p>
36<dl class="params"><dt><b>Parameters:</b></dt><dd>
37<table class="params">
38<tr><td class="paramdir">[in]</td><td class="paramname">array</td><td>The <code>ArrayBuffer</code> whose length should be returned.</td></tr>
39<tr><td class="paramdir">[out]</td><td class="paramname">byte_length</td><td>A variable which is set to the length of the given <code>ArrayBuffer</code> on success.</td></tr>
40</table>
41</dd>
42</dl>
43<dl class="return"><dt><b>Returns:</b></dt><dd><code>PP_TRUE</code> on success, <code>PP_FALSE</code> on failure. </dd></dl>
44</div>
45</div>
46<a class="anchor" id="a348f1470a2fc6cba9d430d0544e84225"></a><!-- doxytag: member="PPB_VarArrayBuffer::Create" ref="a348f1470a2fc6cba9d430d0544e84225" args=")(uint32_t size_in_bytes)" -->
47<div class="memitem">
48<div class="memproto">
49<table class="memname">
50<tr>
51<td class="memname">struct <a class="el" href="struct_p_p___var.html">PP_Var</a>(* <a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#a348f1470a2fc6cba9d430d0544e84225">PPB_VarArrayBuffer::Create</a>)(uint32_t size_in_bytes)<code> [read]</code></td>
52</tr>
53</table>
54</div>
55<div class="memdoc">
56<p><a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#a348f1470a2fc6cba9d430d0544e84225" title="Create() creates a zero-initialized VarArrayBuffer.">Create()</a> creates a zero-initialized <code>VarArrayBuffer</code>. </p>
57<dl class="params"><dt><b>Parameters:</b></dt><dd>
58<table class="params">
59<tr><td class="paramdir">[in]</td><td class="paramname">size_in_bytes</td><td>The size of the <code>ArrayBuffer</code> to be created.</td></tr>
60</table>
61</dd>
62</dl>
63<dl class="return"><dt><b>Returns:</b></dt><dd>A <code><a class="el" href="struct_p_p___var.html" title="The PP_VAR struct is a variant data type and can contain any value of one of the types named in the P...">PP_Var</a></code> representing a <code>VarArrayBuffer</code> of the requested size and with a reference count of 1. </dd></dl>
64</div>
65</div>
66<a class="anchor" id="a4c7c25b939f56de64fa3f6f906a7da8c"></a><!-- doxytag: member="PPB_VarArrayBuffer::Map" ref="a4c7c25b939f56de64fa3f6f906a7da8c" args=")(struct PP_Var array)" -->
67<div class="memitem">
68<div class="memproto">
69<table class="memname">
70<tr>
71<td class="memname">void*(* <a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#a4c7c25b939f56de64fa3f6f906a7da8c">PPB_VarArrayBuffer::Map</a>)(struct <a class="el" href="struct_p_p___var.html">PP_Var</a> array)</td>
72</tr>
73</table>
74</div>
75<div class="memdoc">
76<p><a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#a4c7c25b939f56de64fa3f6f906a7da8c" title="Map() maps the ArrayBuffer in to the module's address space and returns a pointer to the beginning of...">Map()</a> maps the <code>ArrayBuffer</code> in to the module's address space and returns a pointer to the beginning of the buffer for the given <code>ArrayBuffer <a class="el" href="struct_p_p___var.html" title="The PP_VAR struct is a variant data type and can contain any value of one of the types named in the P...">PP_Var</a></code>. </p>
77<p>ArrayBuffers are copied when transmitted, so changes to the underlying memory are not automatically available to the embedding page.</p>
78<p>Note that calling <a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#a4c7c25b939f56de64fa3f6f906a7da8c" title="Map() maps the ArrayBuffer in to the module's address space and returns a pointer to the beginning of...">Map()</a> 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 <code>ArrayBuffer</code>.</p>
79<p><b>Example:</b></p>
80<div class="fragment"><pre class="fragment"> <span class="keywordtype">char</span>* data = (<span class="keywordtype">char</span>*)(array_buffer_if.Map(array_buffer_var));
81 uint32_t byte_length = 0;
82 <a class="code" href="group___enums.html#ga4f272d99be14aacafe08dfd4ef830918" title="The PP_Bool enum is a boolean value for use in PPAPI C headers.">PP_Bool</a> ok = array_buffer_if.ByteLength(array_buffer_var, &amp;byte_length);
83 <span class="keywordflow">if</span> (!ok)
84   <span class="keywordflow">return</span> DoSomethingBecauseMyVarIsNotAnArrayBuffer();
85 <span class="keywordflow">for</span> (uint32_t i = 0; i &lt; byte_length; ++i)
86   data[i] = <span class="charliteral">&#39;A&#39;</span>;
87</pre></div><dl class="params"><dt><b>Parameters:</b></dt><dd>
88<table class="params">
89<tr><td class="paramdir">[in]</td><td class="paramname">array</td><td>The <code>ArrayBuffer</code> whose internal buffer should be returned.</td></tr>
90</table>
91</dd>
92</dl>
93<dl class="return"><dt><b>Returns:</b></dt><dd>A pointer to the internal buffer for this <code>ArrayBuffer</code>. Returns <code>NULL</code> if the given <code><a class="el" href="struct_p_p___var.html" title="The PP_VAR struct is a variant data type and can contain any value of one of the types named in the P...">PP_Var</a></code> is not of type <code>PP_VARTYPE_ARRAY_BUFFER</code>. </dd></dl>
94</div>
95</div>
96<a class="anchor" id="ac841a12b7eb93dd05bd2b864920e22a7"></a><!-- doxytag: member="PPB_VarArrayBuffer::Unmap" ref="ac841a12b7eb93dd05bd2b864920e22a7" args=")(struct PP_Var array)" -->
97<div class="memitem">
98<div class="memproto">
99<table class="memname">
100<tr>
101<td class="memname">void(* <a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#ac841a12b7eb93dd05bd2b864920e22a7">PPB_VarArrayBuffer::Unmap</a>)(struct <a class="el" href="struct_p_p___var.html">PP_Var</a> array)</td>
102</tr>
103</table>
104</div>
105<div class="memdoc">
106<p><a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#ac841a12b7eb93dd05bd2b864920e22a7" title="Unmap() unmaps the given ArrayBuffer var from the module address space.">Unmap()</a> unmaps the given <code>ArrayBuffer</code> var from the module address space. </p>
107<p>Use this if you want to save memory but might want to call <a class="el" href="struct_p_p_b___var_array_buffer__1__0.html#a4c7c25b939f56de64fa3f6f906a7da8c" title="Map() maps the ArrayBuffer in to the module's address space and returns a pointer to the beginning of...">Map()</a> to map the buffer again later. The <code><a class="el" href="struct_p_p___var.html" title="The PP_VAR struct is a variant data type and can contain any value of one of the types named in the P...">PP_Var</a></code> remains valid and should still be released using <code>PPB_Var</code> when you are done with the <code>ArrayBuffer</code>.</p>
108<dl class="params"><dt><b>Parameters:</b></dt><dd>
109<table class="params">
110<tr><td class="paramdir">[in]</td><td class="paramname">array</td><td>The <code>ArrayBuffer</code> to be released. </td></tr>
111</table>
112</dd>
113</dl>
114</div>
115</div>
116<hr />The documentation for this struct was generated from the following file:<ul>
117<li><a class="el" href="ppb__var__array__buffer_8h.html">ppb_var_array_buffer.h</a></li>
118</ul>
119</div><!-- contents -->
120</div>
121{{/partials.standard_nacl_article}}
122