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

Side by Side 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: reorder 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 unified diff | Download patch
« no previous file with comments | « mojo/public/cpp/bindings/array.h ('k') | mojo/public/cpp/bindings/lib/map_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_
7 7
8 #include "mojo/public/cpp/bindings/lib/template_util.h" 8 #include "mojo/public/cpp/bindings/lib/template_util.h"
9 #include "mojo/public/cpp/bindings/struct_ptr.h" 9 #include "mojo/public/cpp/bindings/struct_ptr.h"
10 #include "mojo/public/cpp/system/core.h" 10 #include "mojo/public/cpp/system/core.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 class String; 13 class String;
14 14
15 template <typename T>
16 class Array;
17
18 template <typename K, typename V>
19 class Map;
20
15 namespace internal { 21 namespace internal {
16 template <typename T> 22 template <typename T>
17 class Array_Data; 23 class Array_Data;
18 24
19 #pragma pack(push, 1) 25 #pragma pack(push, 1)
20 26
21 struct StructHeader { 27 struct StructHeader {
22 uint32_t num_bytes; 28 uint32_t num_bytes;
23 uint32_t num_fields; 29 uint32_t num_fields;
24 }; 30 };
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 }; 93 };
88 template <typename S> 94 template <typename S>
89 struct WrapperTraits<InlinedStructPtr<S>, true> { 95 struct WrapperTraits<InlinedStructPtr<S>, true> {
90 typedef typename S::Data_* DataType; 96 typedef typename S::Data_* DataType;
91 }; 97 };
92 template <typename S> 98 template <typename S>
93 struct WrapperTraits<S, true> { 99 struct WrapperTraits<S, true> {
94 typedef typename S::Data_* DataType; 100 typedef typename S::Data_* DataType;
95 }; 101 };
96 102
103 template <typename T, typename Enable = void>
104 struct ValueTraits {
105 static bool Equals(const T& a, const T& b) { return a == b; }
106 };
107
108 template <typename T>
109 struct ValueTraits<
110 T,
111 typename EnableIf<IsSpecializationOf<Array, T>::value ||
112 IsSpecializationOf<Map, T>::value ||
113 IsSpecializationOf<StructPtr, T>::value ||
114 IsSpecializationOf<InlinedStructPtr, T>::value>::type> {
115 static bool Equals(const T& a, const T& b) { return a.Equals(b); }
116 };
117
118 template <typename T>
119 struct ValueTraits<ScopedHandleBase<T>> {
120 static bool Equals(const ScopedHandleBase<T>& a,
121 const ScopedHandleBase<T>& b) {
122 return a.get().value() == b.get().value();
123 }
124 };
125
97 } // namespace internal 126 } // namespace internal
98 } // namespace mojo 127 } // namespace mojo
99 128
100 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ 129 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/array.h ('k') | mojo/public/cpp/bindings/lib/map_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698