| 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 #include "ppapi/cpp/var.h" | 5 #include "ppapi/cpp/var.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 | 11 |
| 12 #include "ppapi/c/pp_var.h" | 12 #include "ppapi/c/pp_var.h" |
| 13 #include "ppapi/c/dev/ppb_var_deprecated.h" | 13 #include "ppapi/c/dev/ppb_var_deprecated.h" |
| 14 #include "ppapi/cpp/common.h" | 14 #include "ppapi/cpp/common.h" |
| 15 #include "ppapi/cpp/instance.h" |
| 15 #include "ppapi/cpp/logging.h" | 16 #include "ppapi/cpp/logging.h" |
| 16 #include "ppapi/cpp/module.h" | 17 #include "ppapi/cpp/module.h" |
| 17 #include "ppapi/cpp/module_impl.h" | 18 #include "ppapi/cpp/module_impl.h" |
| 18 #include "ppapi/cpp/dev/scriptable_object_deprecated.h" | 19 #include "ppapi/cpp/dev/scriptable_object_deprecated.h" |
| 19 | 20 |
| 20 // Define equivalent to snprintf on Windows. | 21 // Define equivalent to snprintf on Windows. |
| 21 #if defined(_MSC_VER) | 22 #if defined(_MSC_VER) |
| 22 # define snprintf sprintf_s | 23 # define snprintf sprintf_s |
| 23 #endif | 24 #endif |
| 24 | 25 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 var_ = get_interface<PPB_Var_Deprecated>()->VarFromUtf8( | 86 var_ = get_interface<PPB_Var_Deprecated>()->VarFromUtf8( |
| 86 Module::Get()->pp_module(), | 87 Module::Get()->pp_module(), |
| 87 utf8_str.c_str(), | 88 utf8_str.c_str(), |
| 88 static_cast<uint32_t>(utf8_str.size())); | 89 static_cast<uint32_t>(utf8_str.size())); |
| 89 } else { | 90 } else { |
| 90 var_.type = PP_VARTYPE_NULL; | 91 var_.type = PP_VARTYPE_NULL; |
| 91 } | 92 } |
| 92 needs_release_ = (var_.type == PP_VARTYPE_STRING); | 93 needs_release_ = (var_.type == PP_VARTYPE_STRING); |
| 93 } | 94 } |
| 94 | 95 |
| 95 Var::Var(ScriptableObject* object) { | 96 Var::Var(Instance* instance, ScriptableObject* object) { |
| 96 if (has_interface<PPB_Var_Deprecated>()) { | 97 if (has_interface<PPB_Var_Deprecated>()) { |
| 97 var_ = get_interface<PPB_Var_Deprecated>()->CreateObject( | 98 var_ = get_interface<PPB_Var_Deprecated>()->CreateObject( |
| 98 Module::Get()->pp_module(), object->GetClass(), object); | 99 instance->pp_instance(), object->GetClass(), object); |
| 99 needs_release_ = true; | 100 needs_release_ = true; |
| 100 } else { | 101 } else { |
| 101 var_.type = PP_VARTYPE_NULL; | 102 var_.type = PP_VARTYPE_NULL; |
| 102 needs_release_ = false; | 103 needs_release_ = false; |
| 103 } | 104 } |
| 104 } | 105 } |
| 105 | 106 |
| 106 Var::Var(const Var& other) { | 107 Var::Var(const Var& other) { |
| 107 var_ = other.var_; | 108 var_ = other.var_; |
| 108 if (NeedsRefcounting(var_)) { | 109 if (NeedsRefcounting(var_)) { |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 str.append("..."); | 374 str.append("..."); |
| 374 } | 375 } |
| 375 snprintf(buf, sizeof(buf), format, str.c_str()); | 376 snprintf(buf, sizeof(buf), format, str.c_str()); |
| 376 } else if (is_object()) { | 377 } else if (is_object()) { |
| 377 snprintf(buf, sizeof(buf), "Var<OBJECT>"); | 378 snprintf(buf, sizeof(buf), "Var<OBJECT>"); |
| 378 } | 379 } |
| 379 return buf; | 380 return buf; |
| 380 } | 381 } |
| 381 | 382 |
| 382 } // namespace pp | 383 } // namespace pp |
| OLD | NEW |