| // Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef MOJO_PUBLIC_INTERFACES_BINDINGS_TESTS_SAMPLE_INTERFACES_MOJOM_SHARED_H_ |
| #define MOJO_PUBLIC_INTERFACES_BINDINGS_TESTS_SAMPLE_INTERFACES_MOJOM_SHARED_H_ |
| |
| #include <stdint.h> |
| |
| #include <functional> |
| #include <ostream> |
| #include <type_traits> |
| #include <utility> |
| |
| #include "base/compiler_specific.h" |
| #include "base/containers/flat_map.h" |
| #include "mojo/public/cpp/bindings/array_data_view.h" |
| #include "mojo/public/cpp/bindings/enum_traits.h" |
| #include "mojo/public/cpp/bindings/interface_data_view.h" |
| #include "mojo/public/cpp/bindings/lib/bindings_internal.h" |
| #include "mojo/public/cpp/bindings/lib/serialization.h" |
| #include "mojo/public/cpp/bindings/map_data_view.h" |
| #include "mojo/public/cpp/bindings/string_data_view.h" |
| #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom-shared-internal.h" |
| #include "mojo/public/mojom/base/generic_pending_receiver.mojom-shared.h" |
| |
| #include "mojo/public/cpp/bindings/lib/interface_serialization.h" |
| |
| |
| #include "mojo/public/cpp/bindings/native_enum.h" |
| #include "mojo/public/cpp/bindings/lib/native_struct_serialization.h" |
| |
| #ifdef KYTHE_IS_RUNNING |
| #pragma kythe_inline_metadata "Metadata comment" |
| #endif |
| |
| |
| namespace sample { |
| |
| |
| } // namespace sample |
| |
| namespace mojo { |
| namespace internal { |
| |
| } // namespace internal |
| } // namespace mojo |
| |
| |
| namespace sample { |
| |
| |
| // @generated_from: sample.Enum |
| enum class Enum : int32_t { |
| |
| // @generated_from: sample.Enum.VALUE |
| VALUE, |
| kMinValue = 0, |
| kMaxValue = 0, |
| }; |
| |
| std::ostream& operator<<(std::ostream& os, Enum value); |
| inline bool IsKnownEnumValue(Enum value) { |
| return internal::Enum_Data::IsKnownValue( |
| static_cast<int32_t>(value)); |
| } |
| // Interface base classes. They are used for type safety check. |
| class PingTestInterfaceBase {}; |
| |
| using PingTestPtrDataView = |
| mojo::InterfacePtrDataView<PingTestInterfaceBase>; |
| using PingTestRequestDataView = |
| mojo::InterfaceRequestDataView<PingTestInterfaceBase>; |
| using PingTestAssociatedPtrInfoDataView = |
| mojo::AssociatedInterfacePtrInfoDataView<PingTestInterfaceBase>; |
| using PingTestAssociatedRequestDataView = |
| mojo::AssociatedInterfaceRequestDataView<PingTestInterfaceBase>; |
| class ProviderInterfaceBase {}; |
| |
| using ProviderPtrDataView = |
| mojo::InterfacePtrDataView<ProviderInterfaceBase>; |
| using ProviderRequestDataView = |
| mojo::InterfaceRequestDataView<ProviderInterfaceBase>; |
| using ProviderAssociatedPtrInfoDataView = |
| mojo::AssociatedInterfacePtrInfoDataView<ProviderInterfaceBase>; |
| using ProviderAssociatedRequestDataView = |
| mojo::AssociatedInterfaceRequestDataView<ProviderInterfaceBase>; |
| class IntegerAccessorInterfaceBase {}; |
| |
| using IntegerAccessorPtrDataView = |
| mojo::InterfacePtrDataView<IntegerAccessorInterfaceBase>; |
| using IntegerAccessorRequestDataView = |
| mojo::InterfaceRequestDataView<IntegerAccessorInterfaceBase>; |
| using IntegerAccessorAssociatedPtrInfoDataView = |
| mojo::AssociatedInterfacePtrInfoDataView<IntegerAccessorInterfaceBase>; |
| using IntegerAccessorAssociatedRequestDataView = |
| mojo::AssociatedInterfaceRequestDataView<IntegerAccessorInterfaceBase>; |
| class InterfaceFactoryInterfaceBase {}; |
| |
| using InterfaceFactoryPtrDataView = |
| mojo::InterfacePtrDataView<InterfaceFactoryInterfaceBase>; |
| using InterfaceFactoryRequestDataView = |
| mojo::InterfaceRequestDataView<InterfaceFactoryInterfaceBase>; |
| using InterfaceFactoryAssociatedPtrInfoDataView = |
| mojo::AssociatedInterfacePtrInfoDataView<InterfaceFactoryInterfaceBase>; |
| using InterfaceFactoryAssociatedRequestDataView = |
| mojo::AssociatedInterfaceRequestDataView<InterfaceFactoryInterfaceBase>; |
| |
| |
| } // namespace sample |
| |
| namespace std { |
| |
| template <> |
| struct hash<::sample::Enum> |
| : public mojo::internal::EnumHashImpl<::sample::Enum> {}; |
| |
| } // namespace std |
| |
| namespace mojo { |
| |
| |
| template <> |
| struct EnumTraits<::sample::Enum, ::sample::Enum> { |
| static ::sample::Enum ToMojom(::sample::Enum input) { return input; } |
| static bool FromMojom(::sample::Enum input, ::sample::Enum* output) { |
| *output = input; |
| return true; |
| } |
| }; |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::sample::Enum, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = EnumTraits<::sample::Enum, UserType>; |
| |
| static void Serialize(UserType input, int32_t* output) { |
| *output = static_cast<int32_t>(Traits::ToMojom(input)); |
| } |
| |
| static bool Deserialize(int32_t input, UserType* output) { |
| return Traits::FromMojom(static_cast<::sample::Enum>(input), output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| } // namespace mojo |
| |
| |
| namespace sample { |
| |
| |
| } // namespace sample |
| |
| #endif // MOJO_PUBLIC_INTERFACES_BINDINGS_TESTS_SAMPLE_INTERFACES_MOJOM_SHARED_H_ |
| |
| /* Metadata comment |
| eyJtZXRhIjogW3siZW5kIjogMTUyOCwgImJlZ2luIjogMTUyNCwgImVkZ2UiOiAiJS9reXRoZS9l |
| ZGdlL2dlbmVyYXRlcyIsICJ0eXBlIjogImFuY2hvcl9kZWZpbmVzIiwgInZuYW1lIjogeyJjb3Jw |
| dXMiOiAiY2hyb21pdW0uZ29vZ2xlc291cmNlLmNvbS9jaHJvbWl1bS9zcmMiLCAibGFuZ3VhZ2Ui |
| OiAibW9qb20iLCAic2lnbmF0dXJlIjogInNhbXBsZS5FbnVtIn19LCB7ImVuZCI6IDE1ODksICJi |
| ZWdpbiI6IDE1ODQsICJlZGdlIjogIiUva3l0aGUvZWRnZS9nZW5lcmF0ZXMiLCAidHlwZSI6ICJh |
| bmNob3JfZGVmaW5lcyIsICJ2bmFtZSI6IHsiY29ycHVzIjogImNocm9taXVtLmdvb2dsZXNvdXJj |
| ZS5jb20vY2hyb21pdW0vc3JjIiwgImxhbmd1YWdlIjogIm1vam9tIiwgInNpZ25hdHVyZSI6ICJz |
| YW1wbGUuRW51bS5WQUxVRSJ9fV0sICJ0eXBlIjogImt5dGhlMCJ9 |
| */ |