| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 |
| 13 namespace pp { | 13 namespace pp { |
| 14 | 14 |
| 15 namespace deprecated { | 15 namespace deprecated { |
| 16 class ScriptableObject; | 16 class ScriptableObject; |
| 17 } | 17 } |
| 18 | 18 |
| 19 class Var { | 19 class Var { |
| 20 public: | 20 public: |
| 21 struct Null {}; // Special value passed to constructor to make NULL. | 21 struct Null {}; // Special value passed to constructor to make NULL. |
| 22 | 22 |
| 23 Var(); // PP_Var of type Undefined. | 23 Var(); // PP_Var of type Undefined. |
| 24 Var(Null); // PP_Var of type Null. | 24 Var(Null); // PP_Var of type Null. |
| 25 Var(bool b); | 25 Var(bool b); |
| 26 Var(int32_t i); | 26 Var(int32_t i); |
| 27 Var(long i); |
| 27 Var(double d); | 28 Var(double d); |
| 28 Var(const char* utf8_str); // Must be encoded in UTF-8. | 29 Var(const char* utf8_str); // Must be encoded in UTF-8. |
| 29 Var(const std::string& utf8_str); // Must be encoded in UTF-8. | 30 Var(const std::string& utf8_str); // Must be encoded in UTF-8. |
| 30 | 31 |
| 31 // This magic constructor is used when we've gotten a PP_Var as a return | 32 // This magic constructor is used when we've gotten a PP_Var as a return |
| 32 // value that has already been addref'ed for us. | 33 // value that has already been addref'ed for us. |
| 33 struct PassRef {}; | 34 struct PassRef {}; |
| 34 Var(PassRef, PP_Var var) { | 35 Var(PassRef, PP_Var var) { |
| 35 var_ = var; | 36 var_ = var; |
| 36 needs_release_ = true; | 37 needs_release_ = true; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // get a compilation error. | 197 // get a compilation error. |
| 197 Var(void* non_scriptable_object_pointer); | 198 Var(void* non_scriptable_object_pointer); |
| 198 | 199 |
| 199 PP_Var var_; | 200 PP_Var var_; |
| 200 bool needs_release_; | 201 bool needs_release_; |
| 201 }; | 202 }; |
| 202 | 203 |
| 203 } // namespace pp | 204 } // namespace pp |
| 204 | 205 |
| 205 #endif // PPAPI_CPP_VAR_H_ | 206 #endif // PPAPI_CPP_VAR_H_ |
| OLD | NEW |