Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: ppapi/cpp/var_array_buffer.h

Issue 9395039: C++ documentation for VarArrayBuffer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PPAPI_CPP_VAR_ARRAY_BUFFER_H_ 5 #ifndef PPAPI_CPP_VAR_ARRAY_BUFFER_H_
6 #define PPAPI_CPP_VAR_ARRAY_BUFFER_H_ 6 #define PPAPI_CPP_VAR_ARRAY_BUFFER_H_
7 7
8 #include "ppapi/cpp/var.h" 8 #include "ppapi/cpp/var.h"
9 9
10 /// @file 10 /// @file
11 /// This file defines the API for interacting with an ArrayBuffer. 11 /// This file defines the API for interacting with a JavaScript ArrayBuffer.
12 12
13 namespace pp { 13 namespace pp {
14 14
15 /// VarArrayBuffer provides a way to interact with JavaScript ArrayBuffers, 15 /// <code>VarArrayBuffer</code> provides a way to interact with JavaScript
16 /// which represent a contiguous sequence of bytes. Note that 16 /// ArrayBuffers, which represent a contiguous sequence of bytes. Note that
17 /// VarArrayBuffers are not part of the embedding page's DOM, and can only 17 /// these vars are not part of the embedding page's DOM, and can only be
18 /// be shared with JavaScript via pp::Instance's PostMessage and HandleMessage 18 /// shared with JavaScript using the <code>PostMessage</code> and
19 /// functions. 19 /// <code>HandleMessage</code> functions of <code>Instance</code>.
20 class VarArrayBuffer : public Var { 20 class VarArrayBuffer : public Var {
21 public: 21 public:
22 /// Contruct a VarArrayBuffer given a var for which is_array_buffer() is 22 /// Contruct a <code>VarArrayBuffer</code> given a var for which
23 /// true. This will refer to the same ArrayBuffer as var, but allows you to 23 /// is_array_buffer() is true. This will refer to the same
24 /// access methods specific to VarArrayBuffer. 24 /// <code>ArrayBuffer</code> as var, but allows you to access methods
25 /// specific to <code>VarArrayBuffer</code>.
25 /// 26 ///
26 /// @param[in] var An ArrayBuffer Var. 27 /// @param[in] var An <code>ArrayBuffer</code> var.
27 explicit VarArrayBuffer(const Var& var); 28 explicit VarArrayBuffer(const Var& var);
28 29
29 /// Construct a new VarArrayBuffer_Dev which is size_in_bytes bytes long and 30 /// Construct a new <code>VarArrayBuffer_Dev</code> which is
30 /// initialized to zero. 31 /// <code>size_in_bytes</code> bytes long and initialized to zero.
31 /// 32 ///
32 /// @param[in] size_in_bytes The size of the constructed ArrayBuffer in bytes. 33 /// @param[in] size_in_bytes The size of the constructed
34 /// <code>ArrayBuffer</code> in bytes.
33 explicit VarArrayBuffer(uint32_t size_in_bytes); 35 explicit VarArrayBuffer(uint32_t size_in_bytes);
34 36
35 /// Copy constructor. 37 /// Copy constructor.
36 VarArrayBuffer(const VarArrayBuffer& buffer) : Var(buffer) {} 38 VarArrayBuffer(const VarArrayBuffer& buffer) : Var(buffer) {}
37 39
38 virtual ~VarArrayBuffer() {} 40 virtual ~VarArrayBuffer() {}
39 41
40 /// This function assigns one VarArrayBuffer to another VarArrayBuffer. 42 /// This function assigns one <code>VarArrayBuffer</code> to another
43 /// <code>VarArrayBuffer</code>.
41 /// 44 ///
42 /// @param[in] other The VarArrayBuffer to be assigned. 45 /// @param[in] other The <code>VarArrayBuffer</code> to be assigned.
43 /// 46 ///
44 /// @return The resulting VarArrayBuffer. 47 /// @return The resulting <code>VarArrayBuffer</code>.
45 VarArrayBuffer& operator=(const VarArrayBuffer& other); 48 VarArrayBuffer& operator=(const VarArrayBuffer& other);
46 49
47 /// This function assigns one VarArrayBuffer to another VarArrayBuffer. Var's 50 /// This function assigns one <code>VarArrayBuffer</code> to another
48 /// assignment operator is overloaded here so that we can check for assigning 51 /// <code>VarArrayBuffer</code>. A Var's assignment operator is overloaded
dmichael (off chromium) 2012/02/17 19:45:14 Remove "A "; it should just say "Var" (and probabl
49 /// a non-ArrayBuffer var to a VarArrayBuffer_Dev. 52 /// here so that we can check for assigning a non-ArrayBuffer var to a
53 /// <code>VarArrayBuffer_Dev</code>.
dmichael (off chromium) 2012/02/17 19:45:14 Remove _Dev (my bad)
50 /// 54 ///
51 /// @param[in] other The VarArrayBuffer to be assigned. 55 /// @param[in] other The <code>VarArrayBuffer</code> to be assigned.
52 /// 56 ///
53 /// @return The resulting VarArrayBuffer (as a Var&). 57 /// @return The resulting <code>VarArrayBuffer</code> (as a Var&).
54 virtual Var& operator=(const Var& other); 58 virtual Var& operator=(const Var& other);
55 59
56 /// Return the length of the VarArrayBuffer in bytes. 60 /// ByteLength() retrieves the length of the <code>VarArrayBuffer</code> in
61 /// bytes.
57 /// 62 ///
58 /// @return The length of the VarArrayBuffer in bytes. 63 /// @return The length of the <code>VarArrayBuffer</code> in bytes.
59 uint32_t ByteLength() const; 64 uint32_t ByteLength() const;
60 65
61 /// Maps the ArrayBuffer in to the module's address space and returns a 66 /// Map() maps the <code>ArrayBuffer</code> in to the module's address space
62 /// pointer to the internal buffer for this ArrayBuffer. 67 /// and returns a pointer to the beginning of the internal buffer for
68 /// this <code>ArrayBuffer</code>.
63 /// 69 ///
64 /// Note that calling Map() can be a relatively expensive operation. Use care 70 /// Note that calling Map() can be a relatively expensive operation. Use care
65 /// when calling it in performance-critical code. For example, you should call 71 /// when calling it in performance-critical code. For example, you should call
66 /// it only once when looping over an ArrayBuffer: 72 /// it only once when looping over an <code>ArrayBuffer</code>.
67 /// 73 ///
68 /// <code> 74 /// <strong>Example:</strong>
75 ///
76 /// @code
69 /// char* data = static_cast<char*>(array_buffer_var.Map()); 77 /// char* data = static_cast<char*>(array_buffer_var.Map());
70 /// uint32_t byte_length = array_buffer_var.ByteLength(); 78 /// uint32_t byte_length = array_buffer_var.ByteLength();
71 /// for (uint32_t i = 0; i < byte_length; ++i) 79 /// for (uint32_t i = 0; i < byte_length; ++i)
72 /// data[i] = 'A'; 80 /// data[i] = 'A';
73 /// </code> 81 /// @endcode
74 /// 82 ///
75 /// @return A pointer to the internal buffer for this ArrayBuffer. 83 /// @return A pointer to the internal buffer for this
84 /// <code>ArrayBuffer</code>.
76 void* Map(); 85 void* Map();
77 86
78 /// Unmaps this ArrayBuffer var from the module address space. Use this if 87 /// Unmap() unmaps this <code>ArrayBuffer</code> var from the module address
79 /// you want to save memory but might want to Map the buffer again later. 88 /// space. Use this if you want to save memory but might want to call Map()
89 /// to map the buffer again later.
80 void Unmap(); 90 void Unmap();
81 }; 91 };
82 92
83 } // namespace pp 93 } // namespace pp
84 94
85 #endif // PPAPI_CPP_VAR_ARRAY_BUFFER_H_ 95 #endif // PPAPI_CPP_VAR_ARRAY_BUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698