| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 28 namespace { | 28 namespace { | 
| 29 | 29 | 
| 30 template <> const char* interface_name<PPB_Var_Deprecated>() { | 30 template <> const char* interface_name<PPB_Var_Deprecated>() { | 
| 31   return PPB_VAR_DEPRECATED_INTERFACE; | 31   return PPB_VAR_DEPRECATED_INTERFACE; | 
| 32 } | 32 } | 
| 33 | 33 | 
| 34 // Technically you can call AddRef and Release on any Var, but it may involve | 34 // Technically you can call AddRef and Release on any Var, but it may involve | 
| 35 // cross-process calls depending on the plugin. This is an optimization so we | 35 // cross-process calls depending on the plugin. This is an optimization so we | 
| 36 // only do refcounting on the necessary objects. | 36 // only do refcounting on the necessary objects. | 
| 37 inline bool NeedsRefcounting(const PP_Var& var) { | 37 inline bool NeedsRefcounting(const PP_Var& var) { | 
| 38   return var.type == PP_VARTYPE_STRING || var.type == PP_VARTYPE_OBJECT; | 38   return var.type > PP_VARTYPE_DOUBLE; | 
| 39 } | 39 } | 
| 40 | 40 | 
| 41 }  // namespace | 41 }  // namespace | 
| 42 | 42 | 
| 43 using namespace deprecated; | 43 using namespace deprecated; | 
| 44 | 44 | 
| 45 Var::Var() { | 45 Var::Var() { | 
| 46   var_.type = PP_VARTYPE_UNDEFINED; | 46   var_.type = PP_VARTYPE_UNDEFINED; | 
| 47   var_.padding = 0; | 47   var_.padding = 0; | 
| 48   needs_release_ = false; | 48   needs_release_ = false; | 
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 160     case PP_VARTYPE_BOOL: | 160     case PP_VARTYPE_BOOL: | 
| 161       return AsBool() == other.AsBool(); | 161       return AsBool() == other.AsBool(); | 
| 162     case PP_VARTYPE_INT32: | 162     case PP_VARTYPE_INT32: | 
| 163       return AsInt() == other.AsInt(); | 163       return AsInt() == other.AsInt(); | 
| 164     case PP_VARTYPE_DOUBLE: | 164     case PP_VARTYPE_DOUBLE: | 
| 165       return AsDouble() == other.AsDouble(); | 165       return AsDouble() == other.AsDouble(); | 
| 166     case PP_VARTYPE_STRING: | 166     case PP_VARTYPE_STRING: | 
| 167       if (var_.value.as_id == other.var_.value.as_id) | 167       if (var_.value.as_id == other.var_.value.as_id) | 
| 168         return true; | 168         return true; | 
| 169       return AsString() == other.AsString(); | 169       return AsString() == other.AsString(); | 
| 170     // TODO(neb): Document that this is === and not ==, unlike strings. | 170     default:  // Objects, arrays, dictionaries. | 
| 171     case PP_VARTYPE_OBJECT: |  | 
| 172       return var_.value.as_id == other.var_.value.as_id; | 171       return var_.value.as_id == other.var_.value.as_id; | 
| 173     default: |  | 
| 174       return false; |  | 
| 175   } | 172   } | 
| 176 } | 173 } | 
| 177 | 174 | 
| 178 bool Var::AsBool() const { | 175 bool Var::AsBool() const { | 
| 179   if (!is_bool()) { | 176   if (!is_bool()) { | 
| 180     PP_NOTREACHED(); | 177     PP_NOTREACHED(); | 
| 181     return false; | 178     return false; | 
| 182   } | 179   } | 
| 183   return PPBoolToBool(var_.value.as_bool); | 180   return PPBoolToBool(var_.value.as_bool); | 
| 184 } | 181 } | 
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 382       str.append("..."); | 379       str.append("..."); | 
| 383     } | 380     } | 
| 384     snprintf(buf, sizeof(buf), format, str.c_str()); | 381     snprintf(buf, sizeof(buf), format, str.c_str()); | 
| 385   } else if (is_object()) { | 382   } else if (is_object()) { | 
| 386     snprintf(buf, sizeof(buf), "Var<OBJECT>"); | 383     snprintf(buf, sizeof(buf), "Var<OBJECT>"); | 
| 387   } | 384   } | 
| 388   return buf; | 385   return buf; | 
| 389 } | 386 } | 
| 390 | 387 | 
| 391 }  // namespace pp | 388 }  // namespace pp | 
| OLD | NEW | 
|---|