Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 40 additions & 12 deletions cppwinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1135,21 +1135,37 @@ namespace cppwinrt
// immediately while preserving the error code and local variables.
format = R"( template <typename D%> auto consume_%<D%>::%(%) const noexcept
{%
auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
auto const abiType = *(abi_t<%>**)&castedResult;
check_cast_result(abiType);
abiType->%(%);%
if constexpr (!std::is_same_v<D, %>)
{
auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
auto const abiType = *(abi_t<%>**)&castedResult;
check_cast_result(abiType);
abiType->%(%);
}
else
{
auto const abiType = *(abi_t<%>**)this;
abiType->%(%);
}%
}
)";
}
else
{
format = R"( template <typename D%> auto consume_%<D%>::%(%) const noexcept
{%
auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
auto const abiType = *(abi_t<%>**)&castedResult;
check_cast_result(abiType);
WINRT_VERIFY_(0, abiType->%(%));%
if constexpr (!std::is_same_v<D, %>)
{
auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
auto const abiType = *(abi_t<%>**)&castedResult;
check_cast_result(abiType);
WINRT_VERIFY_(0, abiType->%(%));
}
else
{
auto const abiType = *(abi_t<%>**)this;
WINRT_VERIFY_(0, abiType->%(%));
}%
}
)";
}
Expand All @@ -1158,10 +1174,18 @@ namespace cppwinrt
{
format = R"( template <typename D%> auto consume_%<D%>::%(%) const
{%
auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
auto const abiType = *(abi_t<%>**)&castedResult;
check_cast_result(abiType);
check_hresult(abiType->%(%));%
if constexpr (!std::is_same_v<D, %>)
{
auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
auto const abiType = *(abi_t<%>**)&castedResult;
check_cast_result(abiType);
check_hresult(abiType->%(%));
}
else
{
auto const abiType = *(abi_t<%>**)this;
check_hresult(abiType->%(%));
}%
}
)";
}
Expand All @@ -1175,6 +1199,10 @@ namespace cppwinrt
bind<write_consume_return_type>(signature, false),
type,
type,
type,
get_abi_name(method),
bind<write_abi_args>(signature),
type,
get_abi_name(method),
bind<write_abi_args>(signature),
bind<write_consume_return_statement>(signature));
Expand Down
3 changes: 1 addition & 2 deletions strings/base_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,7 @@ namespace winrt::impl
return result;
}

template <typename T>
WINRT_IMPL_NOINLINE void check_cast_result(T* from, winrt::impl::slim_source_location const& sourceInformation = winrt::impl::slim_source_location::current())
inline WINRT_IMPL_NOINLINE void check_cast_result(void* from, winrt::impl::slim_source_location const& sourceInformation = winrt::impl::slim_source_location::current())
{
if (!from)
{
Expand Down
Loading