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

Side by Side Diff: mojo/public/cpp/bindings/lib/bindings_internal.h

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more Created 6 years, 7 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 | Annotate | Revision Log
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/system/core.h" 8 #include "mojo/public/cpp/system/core.h"
9 9
10 namespace mojo { 10 namespace mojo {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 static const bool kIsHandle = true; 151 static const bool kIsHandle = true;
152 static const bool kIsObject = false; 152 static const bool kIsObject = false;
153 }; 153 };
154 template <typename S> struct TypeTraits<InterfaceHandle<S> > { 154 template <typename S> struct TypeTraits<InterfaceHandle<S> > {
155 static const bool kIsHandle = true; 155 static const bool kIsHandle = true;
156 static const bool kIsObject = false; 156 static const bool kIsObject = false;
157 }; 157 };
158 158
159 template <typename T> class ObjectTraits {}; 159 template <typename T> class ObjectTraits {};
160 160
161 template<class T, T v>
162 struct integral_constant {
163 static const T value = v;
164 typedef T value_type;
165 typedef integral_constant<T, v> type;
166 };
167
168 template <class T, T v> const T integral_constant<T, v>::value;
169
170 typedef integral_constant<bool, true> true_type;
171 typedef integral_constant<bool, false> false_type;
172
173 template <class T> struct is_const : false_type {};
174 template <class T> struct is_const<const T> : true_type {};
175
176 // Types YesType and NoType are guaranteed such that sizeof(YesType) <
177 // sizeof(NoType).
178 typedef char YesType;
179
180 struct NoType {
181 YesType dummy[2];
182 };
183
184 // A helper template to determine if given type is non-const move-only-type,
185 // i.e. if a value of the given type should be passed via .Pass() in a
186 // destructive way.
187 template <typename T> struct IsMoveOnlyType {
188 template <typename U>
189 static YesType Test(const typename U::MoveOnlyTypeForCPP03*);
190
191 template <typename U>
192 static NoType Test(...);
193
194 static const bool value = sizeof(Test<T>(0)) == sizeof(YesType) &&
195 !is_const<T>::value;
196 };
197
161 } // namespace internal 198 } // namespace internal
162 } // namespace mojo 199 } // namespace mojo
163 200
164 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_ 201 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698