• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1{%- set mojom_type = union|get_qualified_name_for_kind %}
2{%- set data_type = union|get_qualified_name_for_kind(internal=True) %}
3
4namespace internal {
5
6template <typename MojomType>
7struct UnionSerializerImpl;
8
9template <>
10struct UnionSerializerImpl<{{mojom_type}}Ptr> {
11  static size_t PrepareToSerialize({{mojom_type}}Ptr& input,
12                                   bool inlined,
13                                   SerializationContext* context);
14
15  static void Serialize({{mojom_type}}Ptr& input,
16                        Buffer* buffer,
17                        {{data_type}}** output,
18                        bool inlined,
19                        SerializationContext* context);
20
21  static bool Deserialize({{data_type}}* input,
22                          {{mojom_type}}Ptr* output,
23                          SerializationContext* context);
24};
25
26template <typename MaybeConstUserType>
27struct Serializer<{{mojom_type}}Ptr, MaybeConstUserType>
28    : public UnionSerializerImpl<{{mojom_type}}Ptr> {
29  using UserType = typename std::remove_const<MaybeConstUserType>::type;
30
31  static_assert(std::is_same<MaybeConstUserType, UserType>::value,
32                "Only support serialization of non-const Unions.");
33  static_assert(std::is_same<UserType, {{mojom_type}}Ptr>::value,
34                "Custom mapping of mojom union is not supported.");
35};
36
37}  // namespace internal
38