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

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

Issue 23913008: C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows build error. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « mojo/public/bindings/lib/bindings.h ('k') | mojo/public/bindings/lib/bindings_serialization.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_BINDINGS_LIB_BINDINGS_INTERNAL_H_
6 #define MOJO_PUBLIC_BINDINGS_LIB_BINDINGS_INTERNAL_H_
7
8 #include <stdint.h>
9
10 namespace mojo {
11 template <typename T> class Array;
12
13 namespace internal {
14
15 struct StructHeader {
16 uint32_t num_bytes;
17 uint32_t num_fields;
18 };
19
20 struct ArrayHeader {
21 uint32_t num_bytes;
22 uint32_t num_elements;
23 };
24
25 template <typename T>
26 union StructPointer {
27 uint64_t offset;
28 T* ptr;
29 };
30
31 template <typename T>
32 union ArrayPointer {
33 uint64_t offset;
34 Array<T>* ptr;
35 };
36
37 union StringPointer {
38 uint64_t offset;
39 Array<char>* ptr;
40 };
41
42 template <typename T>
43 struct ArrayTraits {
44 typedef T StorageType;
45
46 static T& ToRef(StorageType& e) { return e; }
47 static T const& ToConstRef(const StorageType& e) { return e; }
48 };
49
50 template <typename P>
51 struct ArrayTraits<P*> {
52 typedef StructPointer<P> StorageType;
53
54 static P*& ToRef(StorageType& e) { return e.ptr; }
55 static P* const& ToConstRef(const StorageType& e) { return e.ptr; }
56 };
57
58 template <typename T> class ObjectTraits {};
59
60 } // namespace internal
61 } // namespace mojo
62
63 #endif // MOJO_PUBLIC_BINDINGS_LIB_BINDINGS_INTERNAL_H_
OLDNEW
« no previous file with comments | « mojo/public/bindings/lib/bindings.h ('k') | mojo/public/bindings/lib/bindings_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698