OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 /// @return true if this <code>Var</code> is an object, otherwise false. | 125 /// @return true if this <code>Var</code> is an object, otherwise false. |
126 bool is_object() const { return var_.type == PP_VARTYPE_OBJECT; } | 126 bool is_object() const { return var_.type == PP_VARTYPE_OBJECT; } |
127 | 127 |
128 /// This function determines if this <code>Var</code> is an array. | 128 /// This function determines if this <code>Var</code> is an array. |
129 /// | 129 /// |
130 /// @return true if this <code>Var</code> is an array, otherwise false. | 130 /// @return true if this <code>Var</code> is an array, otherwise false. |
131 bool is_array() const { return var_.type == PP_VARTYPE_ARRAY; } | 131 bool is_array() const { return var_.type == PP_VARTYPE_ARRAY; } |
132 | 132 |
133 /// This function determines if this <code>Var</code> is a dictionary. | 133 /// This function determines if this <code>Var</code> is a dictionary. |
134 /// | 134 /// |
135 /// @return true if this <code>Var</code> is a dictinoary, otherwise false. | 135 /// @return true if this <code>Var</code> is a dictionary, otherwise false. |
136 bool is_dictionary() const { return var_.type == PP_VARTYPE_DICTIONARY; } | 136 bool is_dictionary() const { return var_.type == PP_VARTYPE_DICTIONARY; } |
137 | 137 |
138 /// This function determines if this <code>Var</code> is an integer value. | 138 /// This function determines if this <code>Var</code> is an integer value. |
139 /// The <code>is_int</code> function returns the internal representation. | 139 /// The <code>is_int</code> function returns the internal representation. |
140 /// The JavaScript runtime may convert between the two as needed, so the | 140 /// The JavaScript runtime may convert between the two as needed, so the |
141 /// distinction may not be relevant in all cases (int is really an | 141 /// distinction may not be relevant in all cases (int is really an |
142 /// optimization inside the runtime). So most of the time, you will want | 142 /// optimization inside the runtime). So most of the time, you will want |
143 /// to check is_number(). | 143 /// to check is_number(). |
144 /// | 144 /// |
145 /// @return true if this <code>Var</code> is an integer, otherwise false. | 145 /// @return true if this <code>Var</code> is an integer, otherwise false. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 230 |
231 /// DebugString() returns a short description "Var<X>" that can be used for | 231 /// DebugString() returns a short description "Var<X>" that can be used for |
232 /// logging, where "X" is the underlying scalar or "UNDEFINED" or "OBJ" as | 232 /// logging, where "X" is the underlying scalar or "UNDEFINED" or "OBJ" as |
233 /// it does not call into the browser to get the object description. | 233 /// it does not call into the browser to get the object description. |
234 /// | 234 /// |
235 /// @return A string displaying the value of this <code>Var</code>. This | 235 /// @return A string displaying the value of this <code>Var</code>. This |
236 /// function is used for debugging. | 236 /// function is used for debugging. |
237 std::string DebugString() const; | 237 std::string DebugString() const; |
238 | 238 |
239 /// This class is used when calling the raw C PPAPI when using the C++ | 239 /// This class is used when calling the raw C PPAPI when using the C++ |
240 /// <code>Var</code> as a possibe NULL exception. This class will handle | 240 /// <code>Var</code> as a possible NULL exception. This class will handle |
241 /// getting the address of the internal value out if it's non-NULL and | 241 /// getting the address of the internal value out if it's non-NULL and |
242 /// fixing up the reference count. | 242 /// fixing up the reference count. |
243 /// | 243 /// |
244 /// <strong>Warning:</strong> this will only work for things with exception | 244 /// <strong>Warning:</strong> this will only work for things with exception |
245 /// semantics, i.e. that the value will not be changed if it's a | 245 /// semantics, i.e. that the value will not be changed if it's a |
246 /// non-undefined exception. Otherwise, this class will mess up the | 246 /// non-undefined exception. Otherwise, this class will mess up the |
247 /// refcounting. | 247 /// refcounting. |
248 /// | 248 /// |
249 /// This is a bit subtle: | 249 /// This is a bit subtle: |
250 /// - If NULL is passed, we return NULL from get() and do nothing. | 250 /// - If NULL is passed, we return NULL from get() and do nothing. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 private: | 301 private: |
302 // Prevent an arbitrary pointer argument from being implicitly converted to | 302 // Prevent an arbitrary pointer argument from being implicitly converted to |
303 // a bool at Var construction. If somebody makes such a mistake, (s)he will | 303 // a bool at Var construction. If somebody makes such a mistake, (s)he will |
304 // get a compilation error. | 304 // get a compilation error. |
305 Var(void* non_scriptable_object_pointer); | 305 Var(void* non_scriptable_object_pointer); |
306 }; | 306 }; |
307 | 307 |
308 } // namespace pp | 308 } // namespace pp |
309 | 309 |
310 #endif // PPAPI_CPP_VAR_H_ | 310 #endif // PPAPI_CPP_VAR_H_ |
OLD | NEW |