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

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

Issue 1412733002: C++ bindings: separate out serialization source set, have "mojom" targets optionally use serializat… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: address comments from previous patch Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // TODO(vardhan): Currently, the logic for serializing a mojom type exists in 5 // TODO(vardhan): Currently, the logic for serializing a mojom type exists in
6 // two places: the C++ code generator template, and here. However, most types 6 // two places: the C++ code generator template, and here. However, most types
7 // are serialized the same way within Arrays or outside, with the exception of 7 // are serialized the same way within Arrays or outside, with the exception of
8 // |bool|. Consider defining serialization/deserialization traits for each 8 // |bool|. Consider defining serialization/deserialization traits for each
9 // serializable type and call those traits from here. This should help us 9 // serializable type and call those traits from here. This should help us
10 // remove most of the ArraySerializer<> specializations here. 10 // remove most of the ArraySerializer<> specializations here.
11 11
12 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_H_ 12 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_H_
13 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_H_ 13 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_H_
14 14
15 #include <string.h> // For |memcpy()|. 15 #include <string.h> // For |memcpy()|.
16 #include <type_traits> 16 #include <type_traits>
17 #include <vector> 17 #include <vector>
18 18
19 #include "mojo/public/c/system/macros.h" 19 #include "mojo/public/c/system/macros.h"
20 #include "mojo/public/cpp/bindings/interface_request.h"
21 #include "mojo/public/cpp/bindings/lib/array_internal.h" 20 #include "mojo/public/cpp/bindings/lib/array_internal.h"
22 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" 21 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
23 #include "mojo/public/cpp/bindings/lib/iterator_util.h" 22 #include "mojo/public/cpp/bindings/lib/iterator_util.h"
24 #include "mojo/public/cpp/bindings/lib/map_data_internal.h" 23 #include "mojo/public/cpp/bindings/lib/map_data_internal.h"
25 #include "mojo/public/cpp/bindings/lib/map_serialization_forward.h" 24 #include "mojo/public/cpp/bindings/lib/map_serialization_forward.h"
26 #include "mojo/public/cpp/bindings/lib/string_serialization.h" 25 #include "mojo/public/cpp/bindings/lib/string_serialization.h"
27 #include "mojo/public/cpp/bindings/lib/validation_errors.h" 26 #include "mojo/public/cpp/bindings/lib/validation_errors.h"
28 27
29 namespace mojo { 28 namespace mojo {
29
30 template <typename Interface>
31 InterfaceRequest<Interface> MakeRequest(ScopedMessagePipeHandle handle);
32
30 namespace internal { 33 namespace internal {
31 34
32 // The ArraySerializer template contains static methods for serializing |Array|s 35 // The ArraySerializer template contains static methods for serializing |Array|s
33 // of various types. These methods include: 36 // of various types. These methods include:
34 // * size_t GetSerializedSize(..) 37 // * size_t GetSerializedSize(..)
35 // Computes the size of the serialized version of the |Array|. 38 // Computes the size of the serialized version of the |Array|.
36 // * void SerializeElements(..) 39 // * void SerializeElements(..)
37 // Takes an |Iterator| and a size and serializes it. 40 // Takes an |Iterator| and a size and serializes it.
38 // * void DeserializeElements(..) 41 // * void DeserializeElements(..)
39 // Takes a pointer to an |Array_Data| and deserializes it into a given 42 // Takes a pointer to an |Array_Data| and deserializes it into a given
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 if (input) { 525 if (input) {
523 internal::ArraySerializer<E, F>::DeserializeElements(input, output); 526 internal::ArraySerializer<E, F>::DeserializeElements(input, output);
524 } else { 527 } else {
525 output->reset(); 528 output->reset();
526 } 529 }
527 } 530 }
528 531
529 } // namespace mojo 532 } // namespace mojo
530 533
531 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_H_ 534 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/interface_request.h ('k') | mojo/public/cpp/bindings/lib/bindings_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698