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

Unified Diff: mojo/public/cpp/bindings/lib/bindings_internal.h

Issue 649633003: Add Equals() to mojom structs and related types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 6 years, 2 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
Index: mojo/public/cpp/bindings/lib/bindings_internal.h
diff --git a/mojo/public/cpp/bindings/lib/bindings_internal.h b/mojo/public/cpp/bindings/lib/bindings_internal.h
index df3c620f084d2d1558e263b271b16f99a28cc635..80ec18ab01f9951dfdeb7156aacf9d5d2a5d803c 100644
--- a/mojo/public/cpp/bindings/lib/bindings_internal.h
+++ b/mojo/public/cpp/bindings/lib/bindings_internal.h
@@ -12,6 +12,12 @@
namespace mojo {
class String;
+template <typename T>
+class Array;
+
+template <typename K, typename V>
+class Map;
+
namespace internal {
template <typename T>
class Array_Data;
@@ -94,6 +100,50 @@ struct WrapperTraits<S, true> {
typedef typename S::Data_* DataType;
};
+template <typename T>
+struct ValueTraits {
+ static bool Equals(const T& a, const T& b) { return a == b; }
+};
+
+// TODO(aa): It would be cool to have IsSpecializationOf<> template helper, but
+// got lost in the goop when I tried.
+template <typename T>
+struct ValueTraits<Array<T>> {
+ static bool Equals(const Array<T>& a, const Array<T>& b) {
+ return a.Equals(b);
+ }
+};
+
+template <typename T, typename U>
+struct ValueTraits<Map<T, U>> {
+ static bool Equals(const Map<T, U>& a, const Map<T, U>& b) {
+ return a.Equals(b);
+ }
+};
+
+template <typename T>
+struct ValueTraits<StructPtr<T>> {
+ static bool Equals(const StructPtr<T>& a, const StructPtr<T>& b) {
+ return a.Equals(b);
+ }
+};
+
+template <typename T>
+struct ValueTraits<InlinedStructPtr<T>> {
+ static bool Equals(const InlinedStructPtr<T>& a,
+ const InlinedStructPtr<T>& b) {
+ return a.Equals(b);
+ }
+};
+
+template <typename T>
+struct ValueTraits<ScopedHandleBase<T>> {
+ static bool Equals(const ScopedHandleBase<T>& a,
+ const ScopedHandleBase<T>& b) {
+ return a.get().value() == b.get().value();
+ }
+};
+
} // namespace internal
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698