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

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: Use correct base branch. 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
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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } else if (is_string()) { 222 } else if (is_string()) {
223 char format[] = "Var<'%s'>"; 223 char format[] = "Var<'%s'>";
224 size_t decoration = sizeof(format) - 2; // The %s is removed. 224 size_t decoration = sizeof(format) - 2; // The %s is removed.
225 size_t available = sizeof(buf) - decoration; 225 size_t available = sizeof(buf) - decoration;
226 std::string str = AsString(); 226 std::string str = AsString();
227 if (str.length() > available) { 227 if (str.length() > available) {
228 str.resize(available - 3); // Reserve space for ellipsis. 228 str.resize(available - 3); // Reserve space for ellipsis.
229 str.append("..."); 229 str.append("...");
230 } 230 }
231 snprintf(buf, sizeof(buf), format, str.c_str()); 231 snprintf(buf, sizeof(buf), format, str.c_str());
232 } else if (is_object()) {
233 snprintf(buf, sizeof(buf), "Var(OBJECT)");
234 } else if (is_array()) {
235 snprintf(buf, sizeof(buf), "Var(ARRAY)");
236 } else if (is_dictionary()) {
237 snprintf(buf, sizeof(buf), "Var(DICTIONARY)");
232 } else if (is_array_buffer()) { 238 } else if (is_array_buffer()) {
233 snprintf(buf, sizeof(buf), "Var(ARRAY_BUFFER)"); 239 snprintf(buf, sizeof(buf), "Var(ARRAY_BUFFER)");
234 } else if (is_object()) { 240 } else {
235 snprintf(buf, sizeof(buf), "Var(OBJECT)"); 241 buf[0] = '\0';
236 } 242 }
237 return buf; 243 return buf;
238 } 244 }
239 245
240 } // namespace pp 246 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698