| // 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 DEVICE_BLUETOOTH_PUBLIC_MOJOM_ADAPTER_MOJOM_SHARED_H_ |
| #define DEVICE_BLUETOOTH_PUBLIC_MOJOM_ADAPTER_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 "device/bluetooth/public/mojom/adapter.mojom-shared-internal.h" |
| #include "device/bluetooth/public/mojom/device.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 bluetooth { |
| namespace mojom { |
| class AdapterInfoDataView; |
| |
| |
| |
| } // namespace mojom |
| } // namespace bluetooth |
| |
| namespace mojo { |
| namespace internal { |
| |
| template <> |
| struct MojomTypeTraits<::bluetooth::mojom::AdapterInfoDataView> { |
| using Data = ::bluetooth::mojom::internal::AdapterInfo_Data; |
| using DataAsArrayElement = Pointer<Data>; |
| static constexpr MojomTypeCategory category = MojomTypeCategory::STRUCT; |
| }; |
| |
| } // namespace internal |
| } // namespace mojo |
| |
| |
| namespace bluetooth { |
| namespace mojom { |
| |
| |
| // @generated_from: bluetooth.mojom.ConnectResult |
| enum class ConnectResult : int32_t { |
| |
| // @generated_from: bluetooth.mojom.ConnectResult.SUCCESS |
| SUCCESS, |
| |
| // @generated_from: bluetooth.mojom.ConnectResult.AUTH_CANCELED |
| AUTH_CANCELED, |
| |
| // @generated_from: bluetooth.mojom.ConnectResult.AUTH_FAILED |
| AUTH_FAILED, |
| |
| // @generated_from: bluetooth.mojom.ConnectResult.AUTH_REJECTED |
| AUTH_REJECTED, |
| |
| // @generated_from: bluetooth.mojom.ConnectResult.AUTH_TIMEOUT |
| AUTH_TIMEOUT, |
| |
| // @generated_from: bluetooth.mojom.ConnectResult.FAILED |
| FAILED, |
| |
| // @generated_from: bluetooth.mojom.ConnectResult.INPROGRESS |
| INPROGRESS, |
| |
| // @generated_from: bluetooth.mojom.ConnectResult.UNKNOWN |
| UNKNOWN, |
| |
| // @generated_from: bluetooth.mojom.ConnectResult.UNSUPPORTED_DEVICE |
| UNSUPPORTED_DEVICE, |
| |
| // @generated_from: bluetooth.mojom.ConnectResult.DEVICE_NO_LONGER_IN_RANGE |
| DEVICE_NO_LONGER_IN_RANGE, |
| kMinValue = 0, |
| kMaxValue = 9, |
| }; |
| |
| std::ostream& operator<<(std::ostream& os, ConnectResult value); |
| inline bool IsKnownEnumValue(ConnectResult value) { |
| return internal::ConnectResult_Data::IsKnownValue( |
| static_cast<int32_t>(value)); |
| } |
| // Interface base classes. They are used for type safety check. |
| class DiscoverySessionInterfaceBase {}; |
| |
| using DiscoverySessionPtrDataView = |
| mojo::InterfacePtrDataView<DiscoverySessionInterfaceBase>; |
| using DiscoverySessionRequestDataView = |
| mojo::InterfaceRequestDataView<DiscoverySessionInterfaceBase>; |
| using DiscoverySessionAssociatedPtrInfoDataView = |
| mojo::AssociatedInterfacePtrInfoDataView<DiscoverySessionInterfaceBase>; |
| using DiscoverySessionAssociatedRequestDataView = |
| mojo::AssociatedInterfaceRequestDataView<DiscoverySessionInterfaceBase>; |
| class AdapterInterfaceBase {}; |
| |
| using AdapterPtrDataView = |
| mojo::InterfacePtrDataView<AdapterInterfaceBase>; |
| using AdapterRequestDataView = |
| mojo::InterfaceRequestDataView<AdapterInterfaceBase>; |
| using AdapterAssociatedPtrInfoDataView = |
| mojo::AssociatedInterfacePtrInfoDataView<AdapterInterfaceBase>; |
| using AdapterAssociatedRequestDataView = |
| mojo::AssociatedInterfaceRequestDataView<AdapterInterfaceBase>; |
| class AdapterClientInterfaceBase {}; |
| |
| using AdapterClientPtrDataView = |
| mojo::InterfacePtrDataView<AdapterClientInterfaceBase>; |
| using AdapterClientRequestDataView = |
| mojo::InterfaceRequestDataView<AdapterClientInterfaceBase>; |
| using AdapterClientAssociatedPtrInfoDataView = |
| mojo::AssociatedInterfacePtrInfoDataView<AdapterClientInterfaceBase>; |
| using AdapterClientAssociatedRequestDataView = |
| mojo::AssociatedInterfaceRequestDataView<AdapterClientInterfaceBase>; |
| class AdapterInfoDataView { |
| public: |
| AdapterInfoDataView() {} |
| |
| AdapterInfoDataView( |
| internal::AdapterInfo_Data* data, |
| mojo::internal::SerializationContext* context) |
| : data_(data), context_(context) {} |
| |
| bool is_null() const { return !data_; } |
| inline void GetAddressDataView( |
| mojo::StringDataView* output); |
| |
| template <typename UserType> |
| WARN_UNUSED_RESULT bool ReadAddress(UserType* output) { |
| auto* pointer = data_->address.Get(); |
| return mojo::internal::Deserialize<mojo::StringDataView>( |
| pointer, output, context_); |
| } |
| inline void GetNameDataView( |
| mojo::StringDataView* output); |
| |
| template <typename UserType> |
| WARN_UNUSED_RESULT bool ReadName(UserType* output) { |
| auto* pointer = data_->name.Get(); |
| return mojo::internal::Deserialize<mojo::StringDataView>( |
| pointer, output, context_); |
| } |
| bool initialized() const { |
| return data_->initialized; |
| } |
| bool present() const { |
| return data_->present; |
| } |
| bool powered() const { |
| return data_->powered; |
| } |
| bool discoverable() const { |
| return data_->discoverable; |
| } |
| bool discovering() const { |
| return data_->discovering; |
| } |
| private: |
| internal::AdapterInfo_Data* data_ = nullptr; |
| mojo::internal::SerializationContext* context_ = nullptr; |
| }; |
| |
| |
| |
| } // namespace mojom |
| } // namespace bluetooth |
| |
| namespace std { |
| |
| template <> |
| struct hash<::bluetooth::mojom::ConnectResult> |
| : public mojo::internal::EnumHashImpl<::bluetooth::mojom::ConnectResult> {}; |
| |
| } // namespace std |
| |
| namespace mojo { |
| |
| |
| template <> |
| struct EnumTraits<::bluetooth::mojom::ConnectResult, ::bluetooth::mojom::ConnectResult> { |
| static ::bluetooth::mojom::ConnectResult ToMojom(::bluetooth::mojom::ConnectResult input) { return input; } |
| static bool FromMojom(::bluetooth::mojom::ConnectResult input, ::bluetooth::mojom::ConnectResult* output) { |
| *output = input; |
| return true; |
| } |
| }; |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::bluetooth::mojom::ConnectResult, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = EnumTraits<::bluetooth::mojom::ConnectResult, 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<::bluetooth::mojom::ConnectResult>(input), output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::bluetooth::mojom::AdapterInfoDataView, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = StructTraits<::bluetooth::mojom::AdapterInfoDataView, UserType>; |
| |
| static void Serialize(MaybeConstUserType& input, |
| Buffer* buffer, |
| ::bluetooth::mojom::internal::AdapterInfo_Data::BufferWriter* output, |
| SerializationContext* context) { |
| if (CallIsNullIfExists<Traits>(input)) |
| return; |
| (*output).Allocate(buffer); |
| decltype(Traits::address(input)) in_address = Traits::address(input); |
| typename decltype((*output)->address)::BaseType::BufferWriter |
| address_writer; |
| mojo::internal::Serialize<mojo::StringDataView>( |
| in_address, buffer, &address_writer, context); |
| (*output)->address.Set( |
| address_writer.is_null() ? nullptr : address_writer.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| (*output)->address.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null address in AdapterInfo struct"); |
| decltype(Traits::name(input)) in_name = Traits::name(input); |
| typename decltype((*output)->name)::BaseType::BufferWriter |
| name_writer; |
| mojo::internal::Serialize<mojo::StringDataView>( |
| in_name, buffer, &name_writer, context); |
| (*output)->name.Set( |
| name_writer.is_null() ? nullptr : name_writer.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| (*output)->name.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null name in AdapterInfo struct"); |
| (*output)->initialized = Traits::initialized(input); |
| (*output)->present = Traits::present(input); |
| (*output)->powered = Traits::powered(input); |
| (*output)->discoverable = Traits::discoverable(input); |
| (*output)->discovering = Traits::discovering(input); |
| } |
| |
| static bool Deserialize(::bluetooth::mojom::internal::AdapterInfo_Data* input, |
| UserType* output, |
| SerializationContext* context) { |
| if (!input) |
| return CallSetToNullIfExists<Traits>(output); |
| |
| ::bluetooth::mojom::AdapterInfoDataView data_view(input, context); |
| return Traits::Read(data_view, output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| } // namespace mojo |
| |
| |
| namespace bluetooth { |
| namespace mojom { |
| |
| inline void AdapterInfoDataView::GetAddressDataView( |
| mojo::StringDataView* output) { |
| auto pointer = data_->address.Get(); |
| *output = mojo::StringDataView(pointer, context_); |
| } |
| inline void AdapterInfoDataView::GetNameDataView( |
| mojo::StringDataView* output) { |
| auto pointer = data_->name.Get(); |
| *output = mojo::StringDataView(pointer, context_); |
| } |
| |
| |
| |
| } // namespace mojom |
| } // namespace bluetooth |
| |
| #endif // DEVICE_BLUETOOTH_PUBLIC_MOJOM_ADAPTER_MOJOM_SHARED_H_
|
| /* Metadata comment
|
| eyJtZXRhIj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