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

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

Issue 9381010: Convert resources to take an instance key instead of an Instance*. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: USELESS PATCH TITLE Created 8 years, 9 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/url_response_info.cc ('k') | ppapi/cpp/websocket.h » ('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 12 #include "ppapi/cpp/pass_ref.h"
13 13
14 /// @file 14 /// @file
15 /// This file defines the API for handling the passing of data types between 15 /// This file defines the API for handling the passing of data types between
16 /// your module and the page. 16 /// your module and the page.
17 namespace pp { 17 namespace pp {
18 18
19 /// A generic type used for passing data types between the module and the page. 19 /// A generic type used for passing data types between the module and the page.
20 class Var { 20 class Var {
21 public: 21 public:
22 /// Special value passed to constructor to make <code>NULL</code>. 22 /// Special value passed to constructor to make <code>NULL</code>.
(...skipping 20 matching lines...) Expand all
43 /// 43 ///
44 /// @param[in] d A double value. 44 /// @param[in] d A double value.
45 Var(double d); 45 Var(double d);
46 46
47 /// A constructor used to create a UTF-8 character <code>Var</code>. 47 /// A constructor used to create a UTF-8 character <code>Var</code>.
48 Var(const char* utf8_str); // Must be encoded in UTF-8. 48 Var(const char* utf8_str); // Must be encoded in UTF-8.
49 49
50 /// A constructor used to create a UTF-8 character <code>Var</code>. 50 /// 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. 51 Var(const std::string& utf8_str); // Must be encoded in UTF-8.
52 52
53 /// PassRef can be used to construct a <code>Var</code> with a
54 /// <code>PP_Var</code> when the <code>PP_Var</code>
55 /// already has had its reference count incremented. For example:
56 /// <code>pp::Var my_var(PassRef(), my_pp_var);</code>
57 struct PassRef {};
58
59 /// A constructor used when you have received a <code>Var</code> as a return 53 /// A constructor used when you have received a <code>Var</code> as a return
60 /// value that has had its reference count incremented for you. 54 /// value that has had its reference count incremented for you.
61 /// 55 ///
62 /// You will not normally need to use this constructor because 56 /// You will not normally need to use this constructor because
63 /// the reference count will not normally be incremented for you. 57 /// the reference count will not normally be incremented for you.
64 Var(PassRef, PP_Var var) { 58 Var(PassRef, PP_Var var) {
65 var_ = var; 59 var_ = var;
66 needs_release_ = true; 60 needs_release_ = true;
67 } 61 }
68 62
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 temp_ = output_->var_; 256 temp_ = output_->var_;
263 } else { 257 } else {
264 temp_.padding = 0; 258 temp_.padding = 0;
265 temp_.type = PP_VARTYPE_UNDEFINED; 259 temp_.type = PP_VARTYPE_UNDEFINED;
266 } 260 }
267 } 261 }
268 262
269 /// Destructor. 263 /// Destructor.
270 ~OutException() { 264 ~OutException() {
271 if (output_ && !originally_had_exception_) 265 if (output_ && !originally_had_exception_)
272 *output_ = Var(PassRef(), temp_); 266 *output_ = Var(PASS_REF, temp_);
273 } 267 }
274 268
275 PP_Var* get() { 269 PP_Var* get() {
276 if (output_) 270 if (output_)
277 return &temp_; 271 return &temp_;
278 return NULL; 272 return NULL;
279 } 273 }
280 274
281 private: 275 private:
282 Var* output_; 276 Var* output_;
283 bool originally_had_exception_; 277 bool originally_had_exception_;
284 PP_Var temp_; 278 PP_Var temp_;
285 }; 279 };
286 280
287 protected: 281 protected:
288 PP_Var var_; 282 PP_Var var_;
289 bool needs_release_; 283 bool needs_release_;
290 284
291 private: 285 private:
292 // Prevent an arbitrary pointer argument from being implicitly converted to 286 // Prevent an arbitrary pointer argument from being implicitly converted to
293 // a bool at Var construction. If somebody makes such a mistake, (s)he will 287 // a bool at Var construction. If somebody makes such a mistake, (s)he will
294 // get a compilation error. 288 // get a compilation error.
295 Var(void* non_scriptable_object_pointer); 289 Var(void* non_scriptable_object_pointer);
296 }; 290 };
297 291
298 } // namespace pp 292 } // namespace pp
299 293
300 #endif // PPAPI_CPP_VAR_H_ 294 #endif // PPAPI_CPP_VAR_H_
OLDNEW
« no previous file with comments | « ppapi/cpp/url_response_info.cc ('k') | ppapi/cpp/websocket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698