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