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

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

Issue 2112093002: Mojo C++ bindings: Merge EncodePointers/DecodePointers into Serialize/Deserialize, respectively. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@61_array_fix
Patch Set: . Created 4 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "mojo/public/cpp/bindings/lib/serialization_util.h" 5 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
6 6
7 namespace mojo { 7 namespace mojo {
8 namespace internal { 8 namespace internal {
9 9
10 namespace { 10 namespace {
11 11
12 const size_t kAlignment = 8; 12 const size_t kAlignment = 8;
13 13
14 template <typename T> 14 template <typename T>
15 T AlignImpl(T t) { 15 T AlignImpl(T t) {
(...skipping 20 matching lines...) Expand all
36 return; 36 return;
37 } 37 }
38 38
39 const char* p_obj = reinterpret_cast<const char*>(ptr); 39 const char* p_obj = reinterpret_cast<const char*>(ptr);
40 const char* p_slot = reinterpret_cast<const char*>(offset); 40 const char* p_slot = reinterpret_cast<const char*>(offset);
41 DCHECK(p_obj > p_slot); 41 DCHECK(p_obj > p_slot);
42 42
43 *offset = static_cast<uint64_t>(p_obj - p_slot); 43 *offset = static_cast<uint64_t>(p_obj - p_slot);
44 } 44 }
45 45
46 const void* DecodePointerRaw(const uint64_t* offset) {
47 if (!*offset)
48 return nullptr;
49 return reinterpret_cast<const char*>(offset) + *offset;
50 }
51
52 } // namespace internal 46 } // namespace internal
53 } // namespace mojo 47 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/bindings_internal.h ('k') | mojo/public/cpp/bindings/lib/control_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698