| OLD | NEW |
| 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 #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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } else if (is_string()) { | 234 } else if (is_string()) { |
| 235 char format[] = "Var<'%s'>"; | 235 char format[] = "Var<'%s'>"; |
| 236 size_t decoration = sizeof(format) - 2; // The %s is removed. | 236 size_t decoration = sizeof(format) - 2; // The %s is removed. |
| 237 size_t available = sizeof(buf) - decoration; | 237 size_t available = sizeof(buf) - decoration; |
| 238 std::string str = AsString(); | 238 std::string str = AsString(); |
| 239 if (str.length() > available) { | 239 if (str.length() > available) { |
| 240 str.resize(available - 3); // Reserve space for ellipsis. | 240 str.resize(available - 3); // Reserve space for ellipsis. |
| 241 str.append("..."); | 241 str.append("..."); |
| 242 } | 242 } |
| 243 snprintf(buf, sizeof(buf), format, str.c_str()); | 243 snprintf(buf, sizeof(buf), format, str.c_str()); |
| 244 } else if (is_object()) { |
| 245 snprintf(buf, sizeof(buf), "Var(OBJECT)"); |
| 246 } else if (is_array()) { |
| 247 snprintf(buf, sizeof(buf), "Var(ARRAY)"); |
| 248 } else if (is_dictionary()) { |
| 249 snprintf(buf, sizeof(buf), "Var(DICTIONARY)"); |
| 244 } else if (is_array_buffer()) { | 250 } else if (is_array_buffer()) { |
| 245 snprintf(buf, sizeof(buf), "Var(ARRAY_BUFFER)"); | 251 snprintf(buf, sizeof(buf), "Var(ARRAY_BUFFER)"); |
| 246 } else if (is_object()) { | 252 } else { |
| 247 snprintf(buf, sizeof(buf), "Var(OBJECT)"); | 253 buf[0] = '\0'; |
| 248 } | 254 } |
| 249 return buf; | 255 return buf; |
| 250 } | 256 } |
| 251 | 257 |
| 252 } // namespace pp | 258 } // namespace pp |
| OLD | NEW |