OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 /* | 5 /* |
6 This file contains the declaration for CppVariant, a type used by C++ classes | 6 This file contains the declaration for CppVariant, a type used by C++ classes |
7 that are to be bound to JavaScript objects. | 7 that are to be bound to JavaScript objects. |
8 | 8 |
9 CppVariant exists primarily as an interface between C++ callers and the | 9 CppVariant exists primarily as an interface between C++ callers and the |
10 corresponding NPVariant type. CppVariant also provides a number of | 10 corresponding NPVariant type. CppVariant also provides a number of |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 // Converters. The CppVariant must be of a type convertible to these values. | 91 // Converters. The CppVariant must be of a type convertible to these values. |
92 // For example, ToInteger() works only if isNumber() is true. | 92 // For example, ToInteger() works only if isNumber() is true. |
93 std::string ToString() const; | 93 std::string ToString() const; |
94 int32_t ToInt32() const; | 94 int32_t ToInt32() const; |
95 double ToDouble() const; | 95 double ToDouble() const; |
96 bool ToBoolean() const; | 96 bool ToBoolean() const; |
97 // Returns a vector of strings for the specified argument. This is useful | 97 // Returns a vector of strings for the specified argument. This is useful |
98 // for converting a JavaScript array of strings into a vector of strings. | 98 // for converting a JavaScript array of strings into a vector of strings. |
99 std::vector<std::string> ToStringVector() const; | 99 std::vector<std::string> ToStringVector() const; |
| 100 // Returns a vector of CppVariant for the specified variant. This should only |
| 101 // be called on an Object. If the object has no "length" property an empty |
| 102 // vector is returned. |
| 103 std::vector<CppVariant> ToVector() const; |
100 | 104 |
101 // Invoke method of the given name on an object with the supplied arguments. | 105 // Invoke method of the given name on an object with the supplied arguments. |
102 // The first argument should be the object on which the method is to be | 106 // The first argument should be the object on which the method is to be |
103 // invoked. Returns whether the method was successfully invoked. If the | 107 // invoked. Returns whether the method was successfully invoked. If the |
104 // method was invoked successfully, any return value is stored in the | 108 // method was invoked successfully, any return value is stored in the |
105 // CppVariant specified by result. | 109 // CppVariant specified by result. |
106 bool Invoke(const std::string& method, const CppVariant* args, | 110 bool Invoke(const std::string& method, const CppVariant* args, |
107 uint32 arg_count, CppVariant& result) const; | 111 uint32 arg_count, CppVariant& result) const; |
108 }; | 112 }; |
109 | 113 |
110 #endif // WEBKIT_GLUE_CPP_VARIANT_H__ | 114 #endif // WEBKIT_GLUE_CPP_VARIANT_H__ |
OLD | NEW |