| 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_OUTPUT_TRAITS_H_ | 5 #ifndef PPAPI_CPP_EXTENSIONS_OUTPUT_TRAITS_H_ |
| 6 #define PPAPI_CPP_EXTENSIONS_OUTPUT_TRAITS_H_ | 6 #define PPAPI_CPP_EXTENSIONS_OUTPUT_TRAITS_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 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/extensions/from_var_converter.h" | 11 #include "ppapi/cpp/extensions/from_var_converter.h" |
| 13 #include "ppapi/cpp/logging.h" | 12 #include "ppapi/cpp/logging.h" |
| 14 #include "ppapi/cpp/pass_ref.h" | 13 #include "ppapi/cpp/pass_ref.h" |
| 15 #include "ppapi/cpp/var.h" | 14 #include "ppapi/cpp/var.h" |
| 15 #include "ppapi/cpp/var_array.h" |
| 16 | 16 |
| 17 namespace pp { | 17 namespace pp { |
| 18 namespace ext { | 18 namespace ext { |
| 19 namespace internal { | 19 namespace internal { |
| 20 | 20 |
| 21 template <class T> | 21 template <class T> |
| 22 class VarOutputAdapterWithStorage { | 22 class VarOutputAdapterWithStorage { |
| 23 public: | 23 public: |
| 24 VarOutputAdapterWithStorage() : pp_var_(PP_MakeUndefined()) { | 24 VarOutputAdapterWithStorage() : pp_var_(PP_MakeUndefined()) { |
| 25 } | 25 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 85 } |
| 86 | 86 |
| 87 PP_Var& pp_var() { return pp_var_; } | 87 PP_Var& pp_var() { return pp_var_; } |
| 88 | 88 |
| 89 std::vector<T>& output() { | 89 std::vector<T>& output() { |
| 90 PP_DCHECK(output_storage_.empty()); | 90 PP_DCHECK(output_storage_.empty()); |
| 91 | 91 |
| 92 Var var(PASS_REF, pp_var_); | 92 Var var(PASS_REF, pp_var_); |
| 93 pp_var_ = PP_MakeUndefined(); | 93 pp_var_ = PP_MakeUndefined(); |
| 94 if (var.is_array()) { | 94 if (var.is_array()) { |
| 95 VarArray_Dev array(var); | 95 VarArray array(var); |
| 96 | 96 |
| 97 uint32_t length = array.GetLength(); | 97 uint32_t length = array.GetLength(); |
| 98 output_storage_.reserve(length); | 98 output_storage_.reserve(length); |
| 99 for (uint32_t i = 0; i < length; ++i) { | 99 for (uint32_t i = 0; i < length; ++i) { |
| 100 FromVarConverter<T> converter(array.Get(i).pp_var()); | 100 FromVarConverter<T> converter(array.Get(i).pp_var()); |
| 101 output_storage_.push_back(converter.value()); | 101 output_storage_.push_back(converter.value()); |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 return output_storage_; | 105 return output_storage_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 129 static inline std::vector<T>& StorageToPluginArg(StorageType& t) { | 129 static inline std::vector<T>& StorageToPluginArg(StorageType& t) { |
| 130 return t.output(); | 130 return t.output(); |
| 131 } | 131 } |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 } // namespace internal | 134 } // namespace internal |
| 135 } // namespace ext | 135 } // namespace ext |
| 136 } // namespace pp | 136 } // namespace pp |
| 137 | 137 |
| 138 #endif // PPAPI_CPP_EXTENSIONS_OUTPUT_TRAITS_H_ | 138 #endif // PPAPI_CPP_EXTENSIONS_OUTPUT_TRAITS_H_ |
| OLD | NEW |