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

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

Issue 7237039: Remove PPBoolToBool and BoolToPPBool and use PP_FromBool and PP_ToBool instead. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 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>
11 11
12 #include "ppapi/c/pp_var.h" 12 #include "ppapi/c/pp_var.h"
13 #ifndef PPAPI_VAR_REMOVE_SCRIPTING 13 #ifndef PPAPI_VAR_REMOVE_SCRIPTING
14 # include "ppapi/c/dev/ppb_var_deprecated.h" 14 # include "ppapi/c/dev/ppb_var_deprecated.h"
15 #endif 15 #endif
16 #include "ppapi/c/ppb_var.h" 16 #include "ppapi/c/ppb_var.h"
17 #include "ppapi/cpp/common.h"
18 #include "ppapi/cpp/instance.h" 17 #include "ppapi/cpp/instance.h"
19 #include "ppapi/cpp/logging.h" 18 #include "ppapi/cpp/logging.h"
20 #include "ppapi/cpp/module.h" 19 #include "ppapi/cpp/module.h"
21 #include "ppapi/cpp/module_impl.h" 20 #include "ppapi/cpp/module_impl.h"
22 #include "ppapi/cpp/dev/scriptable_object_deprecated.h" 21 #include "ppapi/cpp/dev/scriptable_object_deprecated.h"
23 22
24 // Define equivalent to snprintf on Windows. 23 // Define equivalent to snprintf on Windows.
25 #if defined(_MSC_VER) 24 #if defined(_MSC_VER)
26 # define snprintf sprintf_s 25 # define snprintf sprintf_s
27 #endif 26 #endif
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 62
64 Var::Var(Null) { 63 Var::Var(Null) {
65 memset(&var_, 0, sizeof(var_)); 64 memset(&var_, 0, sizeof(var_));
66 var_.type = PP_VARTYPE_NULL; 65 var_.type = PP_VARTYPE_NULL;
67 needs_release_ = false; 66 needs_release_ = false;
68 } 67 }
69 68
70 Var::Var(bool b) { 69 Var::Var(bool b) {
71 var_.type = PP_VARTYPE_BOOL; 70 var_.type = PP_VARTYPE_BOOL;
72 var_.padding = 0; 71 var_.padding = 0;
73 var_.value.as_bool = BoolToPPBool(b); 72 var_.value.as_bool = PP_FromBool(b);
74 needs_release_ = false; 73 needs_release_ = false;
75 } 74 }
76 75
77 Var::Var(int32_t i) { 76 Var::Var(int32_t i) {
78 var_.type = PP_VARTYPE_INT32; 77 var_.type = PP_VARTYPE_INT32;
79 var_.padding = 0; 78 var_.padding = 0;
80 var_.value.as_int = i; 79 var_.value.as_int = i;
81 needs_release_ = false; 80 needs_release_ = false;
82 } 81 }
83 82
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 default: // Objects, arrays, dictionaries. 170 default: // Objects, arrays, dictionaries.
172 return var_.value.as_id == other.var_.value.as_id; 171 return var_.value.as_id == other.var_.value.as_id;
173 } 172 }
174 } 173 }
175 174
176 bool Var::AsBool() const { 175 bool Var::AsBool() const {
177 if (!is_bool()) { 176 if (!is_bool()) {
178 PP_NOTREACHED(); 177 PP_NOTREACHED();
179 return false; 178 return false;
180 } 179 }
181 return PPBoolToBool(var_.value.as_bool); 180 return PP_ToBool(var_.value.as_bool);
182 } 181 }
183 182
184 int32_t Var::AsInt() const { 183 int32_t Var::AsInt() const {
185 if (is_int()) 184 if (is_int())
186 return var_.value.as_int; 185 return var_.value.as_int;
187 if (is_double()) 186 if (is_double())
188 return static_cast<int>(var_.value.as_double); 187 return static_cast<int>(var_.value.as_double);
189 PP_NOTREACHED(); 188 PP_NOTREACHED();
190 return 0; 189 return 0;
191 } 190 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 str.append("..."); 394 str.append("...");
396 } 395 }
397 snprintf(buf, sizeof(buf), format, str.c_str()); 396 snprintf(buf, sizeof(buf), format, str.c_str());
398 } else if (is_object()) { 397 } else if (is_object()) {
399 snprintf(buf, sizeof(buf), "Var<OBJECT>"); 398 snprintf(buf, sizeof(buf), "Var<OBJECT>");
400 } 399 }
401 return buf; 400 return buf;
402 } 401 }
403 402
404 } // namespace pp 403 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698