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

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

Issue 9731003: PPAPI: Remove out-dated or unnecessary TODOs from public files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
« ppapi/api/ppb_graphics_2d.idl ('K') | « ppapi/c/ppb_graphics_2d.h ('k') | no next file » | 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 std::string Var::DebugString() const { 213 std::string Var::DebugString() const {
214 char buf[256]; 214 char buf[256];
215 if (is_undefined()) { 215 if (is_undefined()) {
216 snprintf(buf, sizeof(buf), "Var(UNDEFINED)"); 216 snprintf(buf, sizeof(buf), "Var(UNDEFINED)");
217 } else if (is_null()) { 217 } else if (is_null()) {
218 snprintf(buf, sizeof(buf), "Var(NULL)"); 218 snprintf(buf, sizeof(buf), "Var(NULL)");
219 } else if (is_bool()) { 219 } else if (is_bool()) {
220 snprintf(buf, sizeof(buf), AsBool() ? "Var(true)" : "Var(false)"); 220 snprintf(buf, sizeof(buf), AsBool() ? "Var(true)" : "Var(false)");
221 } else if (is_int()) { 221 } else if (is_int()) {
222 // Note that the following static_cast is necessary because
223 // NativeClient's int32_t is actually "long".
224 // TODO(sehr,polina): remove this after newlib is changed.
dmichael (off chromium) 2012/03/19 17:41:52 this static_cast is correct; there's no need to re
225 snprintf(buf, sizeof(buf), "Var(%d)", static_cast<int>(AsInt())); 222 snprintf(buf, sizeof(buf), "Var(%d)", static_cast<int>(AsInt()));
226 } else if (is_double()) { 223 } else if (is_double()) {
227 snprintf(buf, sizeof(buf), "Var(%f)", AsDouble()); 224 snprintf(buf, sizeof(buf), "Var(%f)", AsDouble());
228 } else if (is_string()) { 225 } else if (is_string()) {
229 char format[] = "Var<'%s'>"; 226 char format[] = "Var<'%s'>";
230 size_t decoration = sizeof(format) - 2; // The %s is removed. 227 size_t decoration = sizeof(format) - 2; // The %s is removed.
231 size_t available = sizeof(buf) - decoration; 228 size_t available = sizeof(buf) - decoration;
232 std::string str = AsString(); 229 std::string str = AsString();
233 if (str.length() > available) { 230 if (str.length() > available) {
234 str.resize(available - 3); // Reserve space for ellipsis. 231 str.resize(available - 3); // Reserve space for ellipsis.
235 str.append("..."); 232 str.append("...");
236 } 233 }
237 snprintf(buf, sizeof(buf), format, str.c_str()); 234 snprintf(buf, sizeof(buf), format, str.c_str());
238 } else if (is_array_buffer()) { 235 } else if (is_array_buffer()) {
239 // TODO(dmichael): We could make this dump hex. Maybe DebugString should be
240 // virtual?
dmichael (off chromium) 2012/03/19 17:41:52 Just a nice-to-have.
241 snprintf(buf, sizeof(buf), "Var(ARRAY_BUFFER)"); 236 snprintf(buf, sizeof(buf), "Var(ARRAY_BUFFER)");
242 } else if (is_object()) { 237 } else if (is_object()) {
243 snprintf(buf, sizeof(buf), "Var(OBJECT)"); 238 snprintf(buf, sizeof(buf), "Var(OBJECT)");
244 } 239 }
245 return buf; 240 return buf;
246 } 241 }
247 242
248 } // namespace pp 243 } // namespace pp
OLDNEW
« ppapi/api/ppb_graphics_2d.idl ('K') | « ppapi/c/ppb_graphics_2d.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698