OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_EXTENSIONS_TO_VAR_CONVERTOR_H_ | 5 #ifndef PPAPI_CPP_EXTENSIONS_TO_VAR_CONVERTOR_H_ |
6 #define PPAPI_CPP_EXTENSIONS_TO_VAR_CONVERTOR_H_ | 6 #define PPAPI_CPP_EXTENSIONS_TO_VAR_CONVERTOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ppapi/c/pp_var.h" | 10 #include "ppapi/c/pp_var.h" |
| 11 #include "ppapi/cpp/dev/var_array_dev.h" |
| 12 #include "ppapi/cpp/dev/var_dictionary_dev.h" |
11 #include "ppapi/cpp/extensions/optional.h" | 13 #include "ppapi/cpp/extensions/optional.h" |
12 #include "ppapi/cpp/var.h" | 14 #include "ppapi/cpp/var.h" |
| 15 #include "ppapi/cpp/var_array_buffer.h" |
13 | 16 |
14 namespace pp { | 17 namespace pp { |
15 namespace ext { | 18 namespace ext { |
16 namespace internal { | 19 namespace internal { |
17 | 20 |
18 class ToVarConverterBase { | 21 class ToVarConverterBase { |
19 public: | 22 public: |
20 PP_Var pp_var() const { | 23 PP_Var pp_var() const { |
21 return var_.pp_var(); | 24 return var_.pp_var(); |
22 } | 25 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 : ToVarConverterBase( | 62 : ToVarConverterBase( |
60 object.IsSet() ? ToVarConverter<T>(*object).pp_var() : | 63 object.IsSet() ? ToVarConverter<T>(*object).pp_var() : |
61 PP_MakeUndefined()) { | 64 PP_MakeUndefined()) { |
62 } | 65 } |
63 | 66 |
64 ~ToVarConverter() { | 67 ~ToVarConverter() { |
65 } | 68 } |
66 }; | 69 }; |
67 | 70 |
68 template <> | 71 template <> |
| 72 class ToVarConverter<bool> : public ToVarConverterBase { |
| 73 public: |
| 74 explicit ToVarConverter(bool object) : ToVarConverterBase(Var(object)) { |
| 75 } |
| 76 |
| 77 ~ToVarConverter() { |
| 78 } |
| 79 }; |
| 80 |
| 81 template <> |
| 82 class ToVarConverter<int32_t> : public ToVarConverterBase { |
| 83 public: |
| 84 explicit ToVarConverter(int32_t object) : ToVarConverterBase(Var(object)) { |
| 85 } |
| 86 |
| 87 ~ToVarConverter() { |
| 88 } |
| 89 }; |
| 90 |
| 91 template <> |
| 92 class ToVarConverter<double> : public ToVarConverterBase { |
| 93 public: |
| 94 explicit ToVarConverter(double object) : ToVarConverterBase(Var(object)) { |
| 95 } |
| 96 |
| 97 ~ToVarConverter() { |
| 98 } |
| 99 }; |
| 100 |
| 101 template <> |
69 class ToVarConverter<std::string> : public ToVarConverterBase { | 102 class ToVarConverter<std::string> : public ToVarConverterBase { |
70 public: | 103 public: |
71 explicit ToVarConverter(const std::string& object) | 104 explicit ToVarConverter(const std::string& object) |
72 : ToVarConverterBase(Var(object)) { | 105 : ToVarConverterBase(Var(object)) { |
73 } | 106 } |
74 | 107 |
75 ~ToVarConverter() { | 108 ~ToVarConverter() { |
76 } | 109 } |
77 }; | 110 }; |
78 | 111 |
79 template <> | 112 template <> |
80 class ToVarConverter<double> : public ToVarConverterBase { | 113 class ToVarConverter<Var> : public ToVarConverterBase { |
81 public: | 114 public: |
82 explicit ToVarConverter(double object) : ToVarConverterBase(Var(object)) { | 115 explicit ToVarConverter(const Var& object) : ToVarConverterBase(object) { |
83 } | 116 } |
84 | 117 |
85 ~ToVarConverter() { | 118 ~ToVarConverter() { |
| 119 } |
| 120 }; |
| 121 |
| 122 template <> |
| 123 class ToVarConverter<VarArray_Dev> : public ToVarConverterBase { |
| 124 public: |
| 125 explicit ToVarConverter(const Var& object) : ToVarConverterBase(object) { |
| 126 } |
| 127 |
| 128 ~ToVarConverter() { |
| 129 } |
| 130 }; |
| 131 |
| 132 template <> |
| 133 class ToVarConverter<VarDictionary_Dev> : public ToVarConverterBase { |
| 134 public: |
| 135 explicit ToVarConverter(const Var& object) : ToVarConverterBase(object) { |
| 136 } |
| 137 |
| 138 ~ToVarConverter() { |
| 139 } |
| 140 }; |
| 141 |
| 142 template <> |
| 143 class ToVarConverter<VarArrayBuffer> : public ToVarConverterBase { |
| 144 public: |
| 145 explicit ToVarConverter(const Var& object) : ToVarConverterBase(object) { |
| 146 } |
| 147 |
| 148 ~ToVarConverter() { |
86 } | 149 } |
87 }; | 150 }; |
88 | 151 |
89 } // namespace internal | 152 } // namespace internal |
90 } // namespace ext | 153 } // namespace ext |
91 } // namespace pp | 154 } // namespace pp |
92 | 155 |
93 #endif // PPAPI_CPP_EXTENSIONS_TO_VAR_CONVERTOR_H_ | 156 #endif // PPAPI_CPP_EXTENSIONS_TO_VAR_CONVERTOR_H_ |
OLD | NEW |