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

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

Issue 1410053006: Move third_party/mojo/src/mojo/public to mojo/public (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 years, 1 month 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_
7
8 #include "mojo/public/cpp/bindings/lib/template_util.h"
9 #include "mojo/public/cpp/bindings/struct_ptr.h"
10 #include "mojo/public/cpp/system/core.h"
11
12 namespace mojo {
13 namespace internal {
14
15 template <typename T>
16 class Array_Data;
17
18 #pragma pack(push, 1)
19
20 struct StructHeader {
21 uint32_t num_bytes;
22 uint32_t version;
23 };
24 static_assert(sizeof(StructHeader) == 8, "Bad sizeof(StructHeader)");
25
26 struct ArrayHeader {
27 uint32_t num_bytes;
28 uint32_t num_elements;
29 };
30 static_assert(sizeof(ArrayHeader) == 8, "Bad_sizeof(ArrayHeader)");
31
32 template <typename T>
33 union StructPointer {
34 uint64_t offset;
35 T* ptr;
36 };
37 static_assert(sizeof(StructPointer<char>) == 8, "Bad_sizeof(StructPointer)");
38
39 template <typename T>
40 union ArrayPointer {
41 uint64_t offset;
42 Array_Data<T>* ptr;
43 };
44 static_assert(sizeof(ArrayPointer<char>) == 8, "Bad_sizeof(ArrayPointer)");
45
46 union StringPointer {
47 uint64_t offset;
48 Array_Data<char>* ptr;
49 };
50 static_assert(sizeof(StringPointer) == 8, "Bad_sizeof(StringPointer)");
51
52
53 template <typename T>
54 union UnionPointer {
55 uint64_t offset;
56 T* ptr;
57 };
58 static_assert(sizeof(UnionPointer<char>) == 8, "Bad_sizeof(UnionPointer)");
59
60 struct Interface_Data {
61 MessagePipeHandle handle;
62 uint32_t version;
63 };
64 static_assert(sizeof(Interface_Data) == 8, "Bad_sizeof(Interface_Data)");
65
66 struct AssociatedInterface_Data {
67 uint32_t interface_id;
68 uint32_t version;
69 };
70 static_assert(sizeof(AssociatedInterface_Data) == 8,
71 "Bad_sizeof(AssociatedInterface_Data)");
72
73 using AssociatedInterfaceRequest_Data = uint32_t;
74
75 #pragma pack(pop)
76
77 template <typename T>
78 void ResetIfNonNull(T* ptr) {
79 if (ptr)
80 *ptr = T();
81 }
82
83 template <typename T>
84 T FetchAndReset(T* ptr) {
85 T temp = *ptr;
86 *ptr = T();
87 return temp;
88 }
89
90 template <typename H>
91 struct IsHandle {
92 enum { value = IsBaseOf<Handle, H>::value };
93 };
94
95 template <typename T>
96 struct IsUnionDataType {
97 template <typename U>
98 static YesType Test(const typename U::MojomUnionDataType*);
99
100 template <typename U>
101 static NoType Test(...);
102
103 static const bool value =
104 sizeof(Test<T>(0)) == sizeof(YesType) && !IsConst<T>::value;
105 };
106
107 template <typename T, bool move_only = IsMoveOnlyType<T>::value>
108 struct WrapperTraits;
109
110 template <typename T>
111 struct WrapperTraits<T, false> {
112 typedef T DataType;
113 };
114 template <typename H>
115 struct WrapperTraits<ScopedHandleBase<H>, true> {
116 typedef H DataType;
117 };
118 template <typename S>
119 struct WrapperTraits<StructPtr<S>, true> {
120 typedef typename S::Data_* DataType;
121 };
122 template <typename S>
123 struct WrapperTraits<InlinedStructPtr<S>, true> {
124 typedef typename S::Data_* DataType;
125 };
126 template <typename S>
127 struct WrapperTraits<S, true> {
128 typedef typename S::Data_* DataType;
129 };
130
131 } // namespace internal
132 } // namespace mojo
133
134 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_INTERNAL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698