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

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

Issue 4310002: Make PPAPI headers compile with C compilers (gcc on Linux & Mac and MSVS on W... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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/module.cc ('k') | ppapi/examples/2d/graphics_2d_example.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "ppapi/c/pp_var.h" 11 #include "ppapi/c/pp_var.h"
12 #include "ppapi/c/dev/ppb_var_deprecated.h" 12 #include "ppapi/c/dev/ppb_var_deprecated.h"
13 #include "ppapi/cpp/common.h"
13 #include "ppapi/cpp/logging.h" 14 #include "ppapi/cpp/logging.h"
14 #include "ppapi/cpp/module.h" 15 #include "ppapi/cpp/module.h"
15 #include "ppapi/cpp/module_impl.h" 16 #include "ppapi/cpp/module_impl.h"
16 #include "ppapi/cpp/dev/scriptable_object_deprecated.h" 17 #include "ppapi/cpp/dev/scriptable_object_deprecated.h"
17 18
18 // Defining snprintf 19 // Defining snprintf
19 #include <stdio.h> 20 #include <stdio.h>
20 #if defined(_MSC_VER) 21 #if defined(_MSC_VER)
21 # define snprintf _snprintf_s 22 # define snprintf _snprintf_s
22 #endif 23 #endif
(...skipping 20 matching lines...) Expand all
43 needs_release_ = false; 44 needs_release_ = false;
44 } 45 }
45 46
46 Var::Var(Null) { 47 Var::Var(Null) {
47 var_.type = PP_VARTYPE_NULL; 48 var_.type = PP_VARTYPE_NULL;
48 needs_release_ = false; 49 needs_release_ = false;
49 } 50 }
50 51
51 Var::Var(bool b) { 52 Var::Var(bool b) {
52 var_.type = PP_VARTYPE_BOOL; 53 var_.type = PP_VARTYPE_BOOL;
53 var_.value.as_bool = b; 54 var_.value.as_bool = BoolToPPBool(b);
54 needs_release_ = false; 55 needs_release_ = false;
55 } 56 }
56 57
57 Var::Var(int32_t i) { 58 Var::Var(int32_t i) {
58 var_.type = PP_VARTYPE_INT32; 59 var_.type = PP_VARTYPE_INT32;
59 var_.value.as_int = i; 60 var_.value.as_int = i;
60 needs_release_ = false; 61 needs_release_ = false;
61 } 62 }
62 63
63 Var::Var(double d) { 64 Var::Var(double d) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 default: 160 default:
160 return false; 161 return false;
161 } 162 }
162 } 163 }
163 164
164 bool Var::AsBool() const { 165 bool Var::AsBool() const {
165 if (!is_bool()) { 166 if (!is_bool()) {
166 PP_NOTREACHED(); 167 PP_NOTREACHED();
167 return false; 168 return false;
168 } 169 }
169 return var_.value.as_bool; 170 return PPBoolToBool(var_.value.as_bool);
170 } 171 }
171 172
172 int32_t Var::AsInt() const { 173 int32_t Var::AsInt() const {
173 if (is_int()) 174 if (is_int())
174 return var_.value.as_int; 175 return var_.value.as_int;
175 if (is_double()) 176 if (is_double())
176 return static_cast<int>(var_.value.as_double); 177 return static_cast<int>(var_.value.as_double);
177 PP_NOTREACHED(); 178 PP_NOTREACHED();
178 return 0; 179 return 0;
179 } 180 }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 else if (is_double()) 357 else if (is_double())
357 snprintf(buf, sizeof(buf), "Var<%f>", AsDouble()); 358 snprintf(buf, sizeof(buf), "Var<%f>", AsDouble());
358 else if (is_string()) 359 else if (is_string())
359 snprintf(buf, sizeof(buf), "Var<'%s'>", AsString().c_str()); 360 snprintf(buf, sizeof(buf), "Var<'%s'>", AsString().c_str());
360 else if (is_object()) 361 else if (is_object())
361 snprintf(buf, sizeof(buf), "Var<OBJECT>"); 362 snprintf(buf, sizeof(buf), "Var<OBJECT>");
362 return buf; 363 return buf;
363 } 364 }
364 365
365 } // namespace pp 366 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/module.cc ('k') | ppapi/examples/2d/graphics_2d_example.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698