Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1306)

Unified Diff: mojo/public/cpp/bindings/array.h

Issue 507173003: Change TypeConverter<X,Y>::ConvertFrom and ConvertTo into a single symmetric (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile for real Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/examples/pepper_container_app/type_converters.h ('k') | mojo/public/cpp/bindings/string.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/array.h
diff --git a/mojo/public/cpp/bindings/array.h b/mojo/public/cpp/bindings/array.h
index daf7125bb3c57d7e6355b64c9549ce91be25fbc7..9b5aff898587ca71bb04ee1dda0f04c1d35f70cc 100644
--- a/mojo/public/cpp/bindings/array.h
+++ b/mojo/public/cpp/bindings/array.h
@@ -50,12 +50,12 @@ class Array {
template <typename U>
static Array From(const U& other) {
- return TypeConverter<Array, U>::ConvertFrom(other);
+ return TypeConverter<Array, U>::Convert(other);
}
template <typename U>
U To() const {
- return TypeConverter<Array, U>::ConvertTo(*this);
+ return TypeConverter<U, Array>::Convert(*this);
}
void reset() {
@@ -119,20 +119,23 @@ class Array {
};
template <typename T, typename E>
-class TypeConverter<Array<T>, std::vector<E> > {
- public:
- static Array<T> ConvertFrom(const std::vector<E>& input) {
+struct TypeConverter<Array<T>, std::vector<E> > {
+ static Array<T> Convert(const std::vector<E>& input) {
Array<T> result(input.size());
for (size_t i = 0; i < input.size(); ++i)
- result[i] = TypeConverter<T, E>::ConvertFrom(input[i]);
+ result[i] = TypeConverter<T, E>::Convert(input[i]);
return result.Pass();
}
- static std::vector<E> ConvertTo(const Array<T>& input) {
+};
+
+template <typename E, typename T>
+struct TypeConverter<std::vector<E>, Array<T> > {
+ static std::vector<E> Convert(const Array<T>& input) {
std::vector<E> result;
if (!input.is_null()) {
result.resize(input.size());
for (size_t i = 0; i < input.size(); ++i)
- result[i] = TypeConverter<T, E>::ConvertTo(input[i]);
+ result[i] = TypeConverter<E, T>::Convert(input[i]);
}
return result;
}
« no previous file with comments | « mojo/examples/pepper_container_app/type_converters.h ('k') | mojo/public/cpp/bindings/string.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698