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 CONTENT_RENDERER_CPP_VARIANT_H_ |
| 6 #define CONTENT_RENDERER_CPP_VARIANT_H_ |
| 7 |
5 /* | 8 /* |
6 This file contains the declaration for CppVariant, a type used by C++ classes | 9 This file contains the declaration for CppVariant, a type used by C++ classes |
7 that are to be bound to JavaScript objects. | 10 that are to be bound to JavaScript objects. |
8 | 11 |
9 CppVariant exists primarily as an interface between C++ callers and the | 12 CppVariant exists primarily as an interface between C++ callers and the |
10 corresponding NPVariant type. CppVariant also provides a number of | 13 corresponding NPVariant type. CppVariant also provides a number of |
11 convenience constructors and accessors, so that the NPVariantType values | 14 convenience constructors and accessors, so that the NPVariantType values |
12 don't need to be exposed, and a destructor to free any memory allocated for | 15 don't need to be exposed, and a destructor to free any memory allocated for |
13 string values. | 16 string values. |
14 | 17 |
15 For a usage example, see cpp_binding_example.{h|cc}. | 18 For a usage example, see cpp_binding_example.{h|cc}. |
16 */ | 19 */ |
17 | 20 |
18 #ifndef WEBKIT_RENDERER_CPP_VARIANT_H__ | |
19 #define WEBKIT_RENDERER_CPP_VARIANT_H__ | |
20 | |
21 #include <string> | 21 #include <string> |
22 #include <vector> | 22 #include <vector> |
23 | 23 |
24 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
| 25 #include "content/common/content_export.h" |
25 #include "third_party/npapi/bindings/npruntime.h" | 26 #include "third_party/npapi/bindings/npruntime.h" |
26 #include "webkit/renderer/webkit_renderer_export.h" | |
27 | 27 |
28 namespace webkit_glue { | 28 namespace content { |
29 | 29 |
30 class WEBKIT_RENDERER_EXPORT CppVariant : public NPVariant { | 30 class CONTENT_EXPORT CppVariant : public NPVariant { |
31 public: | 31 public: |
32 CppVariant(); | 32 CppVariant(); |
33 ~CppVariant(); | 33 ~CppVariant(); |
34 void SetNull(); | 34 void SetNull(); |
35 void Set(bool value); | 35 void Set(bool value); |
36 void Set(int32_t value); | 36 void Set(int32_t value); |
37 void Set(double value); | 37 void Set(double value); |
38 | 38 |
39 // Note that setting a CppVariant to a string value involves copying the | 39 // Note that setting a CppVariant to a string value involves copying the |
40 // string data, which must be freed with a call to FreeData() when the | 40 // string data, which must be freed with a call to FreeData() when the |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // Returns a vector of CppVariant for the specified variant. This should only | 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 | 101 // be called on an Object. If the object has no "length" property an empty |
102 // vector is returned. | 102 // vector is returned. |
103 std::vector<CppVariant> ToVector() const; | 103 std::vector<CppVariant> ToVector() const; |
104 | 104 |
105 // 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. |
106 // 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 |
107 // invoked. Returns whether the method was successfully invoked. If the | 107 // invoked. Returns whether the method was successfully invoked. If the |
108 // method was invoked successfully, any return value is stored in the | 108 // method was invoked successfully, any return value is stored in the |
109 // CppVariant specified by result. | 109 // CppVariant specified by result. |
110 bool Invoke(const std::string& method, const CppVariant* args, | 110 bool Invoke(const std::string& method, |
111 uint32 arg_count, CppVariant& result) const; | 111 const CppVariant* args, |
| 112 uint32 arg_count, |
| 113 CppVariant& result) const; |
112 }; | 114 }; |
113 | 115 |
114 } // namespace webkit_glue | 116 } // namespace content |
115 | 117 |
116 #endif // WEBKIT_RENDERER_CPP_VARIANT_H__ | 118 #endif // CONTENT_RENDERER_CPP_VARIANT_H_ |
OLD | NEW |