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

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

Issue 148213016: [PPAPI] Moving pp::VarResource_Dev API into pp::Var (now stable). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 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 | « ppapi/cpp/resource.h ('k') | ppapi/cpp/var.cc » ('j') | 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_H_ 5 #ifndef PPAPI_CPP_VAR_H_
6 #define PPAPI_CPP_VAR_H_ 6 #define PPAPI_CPP_VAR_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ppapi/c/pp_var.h" 11 #include "ppapi/c/pp_var.h"
12 #include "ppapi/cpp/pass_ref.h" 12 #include "ppapi/cpp/pass_ref.h"
13 #include "ppapi/cpp/resource.h"
13 14
14 /// @file 15 /// @file
15 /// This file defines the API for handling the passing of data types between 16 /// This file defines the API for handling the passing of data types between
16 /// your module and the page. 17 /// your module and the page.
17 namespace pp { 18 namespace pp {
18 19
19 /// A generic type used for passing data types between the module and the page. 20 /// A generic type used for passing data types between the module and the page.
20 class Var { 21 class Var {
21 public: 22 public:
22 /// Special value passed to constructor to make <code>NULL</code>. 23 /// Special value passed to constructor to make <code>NULL</code>.
(...skipping 20 matching lines...) Expand all
43 /// 44 ///
44 /// @param[in] d A double value. 45 /// @param[in] d A double value.
45 Var(double d); 46 Var(double d);
46 47
47 /// A constructor used to create a UTF-8 character <code>Var</code>. 48 /// A constructor used to create a UTF-8 character <code>Var</code>.
48 Var(const char* utf8_str); // Must be encoded in UTF-8. 49 Var(const char* utf8_str); // Must be encoded in UTF-8.
49 50
50 /// A constructor used to create a UTF-8 character <code>Var</code>. 51 /// A constructor used to create a UTF-8 character <code>Var</code>.
51 Var(const std::string& utf8_str); // Must be encoded in UTF-8. 52 Var(const std::string& utf8_str); // Must be encoded in UTF-8.
52 53
54 /// A constructor used to create a resource <code>Var</code>.
55 explicit Var(const pp::Resource& resource);
56
53 /// A constructor used when you have received a <code>Var</code> as a return 57 /// A constructor used when you have received a <code>Var</code> as a return
54 /// value that has had its reference count incremented for you. 58 /// value that has had its reference count incremented for you.
55 /// 59 ///
56 /// You will not normally need to use this constructor because 60 /// You will not normally need to use this constructor because
57 /// the reference count will not normally be incremented for you. 61 /// the reference count will not normally be incremented for you.
58 Var(PassRef, const PP_Var& var) { 62 Var(PassRef, const PP_Var& var) {
59 var_ = var; 63 var_ = var;
60 is_managed_ = true; 64 is_managed_ = true;
61 } 65 }
62 66
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 /// 206 ///
203 /// @return An double version of this <code>Var</code>. 207 /// @return An double version of this <code>Var</code>.
204 double AsDouble() const; 208 double AsDouble() const;
205 209
206 /// AsString() converts this <code>Var</code> to a string. If this object is 210 /// AsString() converts this <code>Var</code> to a string. If this object is
207 /// not a string, it will assert in debug mode, and return an empty string. 211 /// not a string, it will assert in debug mode, and return an empty string.
208 /// 212 ///
209 /// @return A string version of this <code>Var</code>. 213 /// @return A string version of this <code>Var</code>.
210 std::string AsString() const; 214 std::string AsString() const;
211 215
216 /// Gets the resource contained in the var. If this object is not a resource,
217 /// it will assert in debug mode, and return a null resource.
218 ///
219 /// @return The <code>pp::Resource</code> that is contained in the var.
220 pp::Resource AsResource() const;
221
212 /// This function returns the internal <code>PP_Var</code> 222 /// This function returns the internal <code>PP_Var</code>
213 /// managed by this <code>Var</code> object. 223 /// managed by this <code>Var</code> object.
214 /// 224 ///
215 /// @return A const reference to a <code>PP_Var</code>. 225 /// @return A const reference to a <code>PP_Var</code>.
216 const PP_Var& pp_var() const { 226 const PP_Var& pp_var() const {
217 return var_; 227 return var_;
218 } 228 }
219 229
220 /// Detach() detaches from the internal <code>PP_Var</code> of this 230 /// Detach() detaches from the internal <code>PP_Var</code> of this
221 /// object, keeping the reference count the same. This is used when returning 231 /// object, keeping the reference count the same. This is used when returning
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 private: 314 private:
305 // Prevent an arbitrary pointer argument from being implicitly converted to 315 // Prevent an arbitrary pointer argument from being implicitly converted to
306 // a bool at Var construction. If somebody makes such a mistake, (s)he will 316 // a bool at Var construction. If somebody makes such a mistake, (s)he will
307 // get a compilation error. 317 // get a compilation error.
308 Var(void* non_scriptable_object_pointer); 318 Var(void* non_scriptable_object_pointer);
309 }; 319 };
310 320
311 } // namespace pp 321 } // namespace pp
312 322
313 #endif // PPAPI_CPP_VAR_H_ 323 #endif // PPAPI_CPP_VAR_H_
OLDNEW
« no previous file with comments | « ppapi/cpp/resource.h ('k') | ppapi/cpp/var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698