OLD | NEW |
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 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 var_.value.as_bool = BoolToPPBool(b); | 54 var_.value.as_bool = BoolToPPBool(b); |
55 needs_release_ = false; | 55 needs_release_ = false; |
56 } | 56 } |
57 | 57 |
58 Var::Var(int32_t i) { | 58 Var::Var(int32_t i) { |
59 var_.type = PP_VARTYPE_INT32; | 59 var_.type = PP_VARTYPE_INT32; |
60 var_.value.as_int = i; | 60 var_.value.as_int = i; |
61 needs_release_ = false; | 61 needs_release_ = false; |
62 } | 62 } |
63 | 63 |
| 64 Var::Var(long i) { |
| 65 var_.type = PP_VARTYPE_INT32; |
| 66 var_.value.as_int = i; |
| 67 needs_release_ = false; |
| 68 } |
| 69 |
64 Var::Var(double d) { | 70 Var::Var(double d) { |
65 var_.type = PP_VARTYPE_DOUBLE; | 71 var_.type = PP_VARTYPE_DOUBLE; |
66 var_.value.as_double = d; | 72 var_.value.as_double = d; |
67 needs_release_ = false; | 73 needs_release_ = false; |
68 } | 74 } |
69 | 75 |
70 Var::Var(const char* utf8_str) { | 76 Var::Var(const char* utf8_str) { |
71 if (ppb_var_f) { | 77 if (ppb_var_f) { |
72 uint32_t len = utf8_str ? static_cast<uint32_t>(strlen(utf8_str)) : 0; | 78 uint32_t len = utf8_str ? static_cast<uint32_t>(strlen(utf8_str)) : 0; |
73 var_ = ppb_var_f->VarFromUtf8(Module::Get()->pp_module(), utf8_str, len); | 79 var_ = ppb_var_f->VarFromUtf8(Module::Get()->pp_module(), utf8_str, len); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 else if (is_double()) | 363 else if (is_double()) |
358 snprintf(buf, sizeof(buf), "Var<%f>", AsDouble()); | 364 snprintf(buf, sizeof(buf), "Var<%f>", AsDouble()); |
359 else if (is_string()) | 365 else if (is_string()) |
360 snprintf(buf, sizeof(buf), "Var<'%s'>", AsString().c_str()); | 366 snprintf(buf, sizeof(buf), "Var<'%s'>", AsString().c_str()); |
361 else if (is_object()) | 367 else if (is_object()) |
362 snprintf(buf, sizeof(buf), "Var<OBJECT>"); | 368 snprintf(buf, sizeof(buf), "Var<OBJECT>"); |
363 return buf; | 369 return buf; |
364 } | 370 } |
365 | 371 |
366 } // namespace pp | 372 } // namespace pp |
OLD | NEW |