| OLD | NEW |
| 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 #ifndef PPAPI_CPP_VAR_H_ | 5 #ifndef PPAPI_CPP_VAR_H_ |
| 6 #define PPAPI_CPP_VAR_H_ | 6 #define PPAPI_CPP_VAR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 /// This function determines if this <code>Var</code> is a number. | 154 /// This function determines if this <code>Var</code> is a number. |
| 155 /// | 155 /// |
| 156 /// @return true if this <code>Var</code> is an int32 or double number, | 156 /// @return true if this <code>Var</code> is an int32 or double number, |
| 157 /// otherwise false. | 157 /// otherwise false. |
| 158 bool is_number() const { | 158 bool is_number() const { |
| 159 return var_.type == PP_VARTYPE_INT32 || | 159 return var_.type == PP_VARTYPE_INT32 || |
| 160 var_.type == PP_VARTYPE_DOUBLE; | 160 var_.type == PP_VARTYPE_DOUBLE; |
| 161 } | 161 } |
| 162 | 162 |
| 163 /// This function determines if this <code>Var</code> is an ArrayBuffer. |
| 164 bool is_array_buffer() const { return var_.type == PP_VARTYPE_ARRAY_BUFFER; } |
| 165 |
| 163 /// AsBool() converts this <code>Var</code> to a bool. Assumes the | 166 /// AsBool() converts this <code>Var</code> to a bool. Assumes the |
| 164 /// internal representation is_bool(). If it's not, it will assert in debug | 167 /// internal representation is_bool(). If it's not, it will assert in debug |
| 165 /// mode, and return false. | 168 /// mode, and return false. |
| 166 /// | 169 /// |
| 167 /// @return A bool version of this <code>Var</code>. | 170 /// @return A bool version of this <code>Var</code>. |
| 168 bool AsBool() const; | 171 bool AsBool() const; |
| 169 | 172 |
| 170 /// AsInt() converts this <code>Var</code> to an int32_t. This function | 173 /// AsInt() converts this <code>Var</code> to an int32_t. This function |
| 171 /// is required because JavaScript doesn't have a concept of ints and doubles, | 174 /// is required because JavaScript doesn't have a concept of ints and doubles, |
| 172 /// only numbers. The distinction between the two is an optimization inside | 175 /// only numbers. The distinction between the two is an optimization inside |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 // Prevent an arbitrary pointer argument from being implicitly converted to | 295 // Prevent an arbitrary pointer argument from being implicitly converted to |
| 293 // a bool at Var construction. If somebody makes such a mistake, (s)he will | 296 // a bool at Var construction. If somebody makes such a mistake, (s)he will |
| 294 // get a compilation error. | 297 // get a compilation error. |
| 295 Var(void* non_scriptable_object_pointer); | 298 Var(void* non_scriptable_object_pointer); |
| 296 | 299 |
| 297 }; | 300 }; |
| 298 | 301 |
| 299 } // namespace pp | 302 } // namespace pp |
| 300 | 303 |
| 301 #endif // PPAPI_CPP_VAR_H_ | 304 #endif // PPAPI_CPP_VAR_H_ |
| OLD | NEW |