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

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

Issue 12387073: Add PPB_VarDictionary_Dev support - part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 7 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/var.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('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 #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
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
OLDNEW
« no previous file with comments | « ppapi/cpp/var.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698