// C++/WinRT v2.0.250303.1 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #ifndef WINRT_Windows_Devices_I2c_Provider_H #define WINRT_Windows_Devices_I2c_Provider_H #include "winrt/base.h" static_assert(winrt::check_version(CPPWINRT_VERSION, "2.0.250303.1"), "Mismatched C++/WinRT headers."); #define CPPWINRT_VERSION "2.0.250303.1" #include "winrt/Windows.Devices.I2c.h" #include "winrt/impl/Windows.Foundation.2.h" #include "winrt/impl/Windows.Foundation.Collections.2.h" #include "winrt/impl/Windows.Devices.I2c.Provider.2.h" namespace winrt::impl { template auto consume_Windows_Devices_I2c_Provider_II2cControllerProvider::GetDeviceProvider(winrt::Windows::Devices::I2c::Provider::ProviderI2cConnectionSettings const& settings) const { void* device{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->GetDeviceProvider(*(void**)(&settings), &device)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->GetDeviceProvider(*(void**)(&settings), &device)); } return winrt::Windows::Devices::I2c::Provider::II2cDeviceProvider{ device, take_ownership_from_abi }; } template auto consume_Windows_Devices_I2c_Provider_II2cDeviceProvider::DeviceId() const { void* value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_DeviceId(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_DeviceId(&value)); } return hstring{ value, take_ownership_from_abi }; } template auto consume_Windows_Devices_I2c_Provider_II2cDeviceProvider::Write(array_view buffer) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->Write(buffer.size(), get_abi(buffer))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->Write(buffer.size(), get_abi(buffer))); } } template auto consume_Windows_Devices_I2c_Provider_II2cDeviceProvider::WritePartial(array_view buffer) const { winrt::Windows::Devices::I2c::Provider::ProviderI2cTransferResult result{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->WritePartial(buffer.size(), get_abi(buffer), put_abi(result))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->WritePartial(buffer.size(), get_abi(buffer), put_abi(result))); } return result; } template auto consume_Windows_Devices_I2c_Provider_II2cDeviceProvider::Read(array_view buffer) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->Read(buffer.size(), put_abi(buffer))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->Read(buffer.size(), put_abi(buffer))); } } template auto consume_Windows_Devices_I2c_Provider_II2cDeviceProvider::ReadPartial(array_view buffer) const { winrt::Windows::Devices::I2c::Provider::ProviderI2cTransferResult result{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->ReadPartial(buffer.size(), put_abi(buffer), put_abi(result))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->ReadPartial(buffer.size(), put_abi(buffer), put_abi(result))); } return result; } template auto consume_Windows_Devices_I2c_Provider_II2cDeviceProvider::WriteRead(array_view writeBuffer, array_view readBuffer) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->WriteRead(writeBuffer.size(), get_abi(writeBuffer), readBuffer.size(), put_abi(readBuffer))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->WriteRead(writeBuffer.size(), get_abi(writeBuffer), readBuffer.size(), put_abi(readBuffer))); } } template auto consume_Windows_Devices_I2c_Provider_II2cDeviceProvider::WriteReadPartial(array_view writeBuffer, array_view readBuffer) const { winrt::Windows::Devices::I2c::Provider::ProviderI2cTransferResult result{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->WriteReadPartial(writeBuffer.size(), get_abi(writeBuffer), readBuffer.size(), put_abi(readBuffer), put_abi(result))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->WriteReadPartial(writeBuffer.size(), get_abi(writeBuffer), readBuffer.size(), put_abi(readBuffer), put_abi(result))); } return result; } template auto consume_Windows_Devices_I2c_Provider_II2cProvider::GetControllersAsync() const { void* operation{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->GetControllersAsync(&operation)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->GetControllersAsync(&operation)); } return winrt::Windows::Foundation::IAsyncOperation>{ operation, take_ownership_from_abi }; } template auto consume_Windows_Devices_I2c_Provider_IProviderI2cConnectionSettings::SlaveAddress() const { int32_t value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_SlaveAddress(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_SlaveAddress(&value)); } return value; } template auto consume_Windows_Devices_I2c_Provider_IProviderI2cConnectionSettings::SlaveAddress(int32_t value) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->put_SlaveAddress(value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->put_SlaveAddress(value)); } } template auto consume_Windows_Devices_I2c_Provider_IProviderI2cConnectionSettings::BusSpeed() const { winrt::Windows::Devices::I2c::Provider::ProviderI2cBusSpeed value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_BusSpeed(reinterpret_cast(&value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_BusSpeed(reinterpret_cast(&value))); } return value; } template auto consume_Windows_Devices_I2c_Provider_IProviderI2cConnectionSettings::BusSpeed(winrt::Windows::Devices::I2c::Provider::ProviderI2cBusSpeed const& value) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->put_BusSpeed(static_cast(value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->put_BusSpeed(static_cast(value))); } } template auto consume_Windows_Devices_I2c_Provider_IProviderI2cConnectionSettings::SharingMode() const { winrt::Windows::Devices::I2c::Provider::ProviderI2cSharingMode value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_SharingMode(reinterpret_cast(&value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_SharingMode(reinterpret_cast(&value))); } return value; } template auto consume_Windows_Devices_I2c_Provider_IProviderI2cConnectionSettings::SharingMode(winrt::Windows::Devices::I2c::Provider::ProviderI2cSharingMode const& value) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->put_SharingMode(static_cast(value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->put_SharingMode(static_cast(value))); } } template struct produce : produce_base { int32_t __stdcall GetDeviceProvider(void* settings, void** device) noexcept final try { clear_abi(device); typename D::abi_guard guard(this->shim()); *device = detach_from(this->shim().GetDeviceProvider(*reinterpret_cast(&settings))); return 0; } catch (...) { return to_hresult(); } }; template struct produce : produce_base { int32_t __stdcall get_DeviceId(void** value) noexcept final try { clear_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().DeviceId()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall Write(uint32_t __bufferSize, uint8_t* buffer) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().Write(array_view(reinterpret_cast(buffer), reinterpret_cast(buffer) + __bufferSize)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall WritePartial(uint32_t __bufferSize, uint8_t* buffer, struct struct_Windows_Devices_I2c_Provider_ProviderI2cTransferResult* result) noexcept final try { zero_abi(result); typename D::abi_guard guard(this->shim()); *result = detach_from(this->shim().WritePartial(array_view(reinterpret_cast(buffer), reinterpret_cast(buffer) + __bufferSize))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall Read(uint32_t __bufferSize, uint8_t* buffer) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().Read(array_view(reinterpret_cast(buffer), reinterpret_cast(buffer) + __bufferSize)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall ReadPartial(uint32_t __bufferSize, uint8_t* buffer, struct struct_Windows_Devices_I2c_Provider_ProviderI2cTransferResult* result) noexcept final try { zero_abi(result); typename D::abi_guard guard(this->shim()); *result = detach_from(this->shim().ReadPartial(array_view(reinterpret_cast(buffer), reinterpret_cast(buffer) + __bufferSize))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall WriteRead(uint32_t __writeBufferSize, uint8_t* writeBuffer, uint32_t __readBufferSize, uint8_t* readBuffer) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().WriteRead(array_view(reinterpret_cast(writeBuffer), reinterpret_cast(writeBuffer) + __writeBufferSize), array_view(reinterpret_cast(readBuffer), reinterpret_cast(readBuffer) + __readBufferSize)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall WriteReadPartial(uint32_t __writeBufferSize, uint8_t* writeBuffer, uint32_t __readBufferSize, uint8_t* readBuffer, struct struct_Windows_Devices_I2c_Provider_ProviderI2cTransferResult* result) noexcept final try { zero_abi(result); typename D::abi_guard guard(this->shim()); *result = detach_from(this->shim().WriteReadPartial(array_view(reinterpret_cast(writeBuffer), reinterpret_cast(writeBuffer) + __writeBufferSize), array_view(reinterpret_cast(readBuffer), reinterpret_cast(readBuffer) + __readBufferSize))); return 0; } catch (...) { return to_hresult(); } }; template struct produce : produce_base { int32_t __stdcall GetControllersAsync(void** operation) noexcept final try { clear_abi(operation); typename D::abi_guard guard(this->shim()); *operation = detach_from>>(this->shim().GetControllersAsync()); return 0; } catch (...) { return to_hresult(); } }; #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall get_SlaveAddress(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().SlaveAddress()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall put_SlaveAddress(int32_t value) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().SlaveAddress(value); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_BusSpeed(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().BusSpeed()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall put_BusSpeed(int32_t value) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().BusSpeed(*reinterpret_cast(&value)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_SharingMode(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().SharingMode()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall put_SharingMode(int32_t value) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().SharingMode(*reinterpret_cast(&value)); return 0; } catch (...) { return to_hresult(); } }; #endif } WINRT_EXPORT namespace winrt::Windows::Devices::I2c::Provider { } namespace std { #ifndef WINRT_LEAN_AND_MEAN template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; #endif #ifdef __cpp_lib_format #endif } #endif