Skip to content

Commit d7292ac

Browse files
committed
Merge branch 'master' into user/dmachaj/no-loadlibrary
2 parents 8f5edf6 + d296af6 commit d7292ac

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

cppwinrt/code_writers.h

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,21 +1135,37 @@ namespace cppwinrt
11351135
// immediately while preserving the error code and local variables.
11361136
format = R"( template <typename D%> auto consume_%<D%>::%(%) const noexcept
11371137
{%
1138-
auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
1139-
auto const abiType = *(abi_t<%>**)&castedResult;
1140-
check_cast_result(abiType);
1141-
abiType->%(%);%
1138+
if constexpr (!std::is_same_v<D, %>)
1139+
{
1140+
auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
1141+
auto const abiType = *(abi_t<%>**)&castedResult;
1142+
check_cast_result(abiType);
1143+
abiType->%(%);
1144+
}
1145+
else
1146+
{
1147+
auto const abiType = *(abi_t<%>**)this;
1148+
abiType->%(%);
1149+
}%
11421150
}
11431151
)";
11441152
}
11451153
else
11461154
{
11471155
format = R"( template <typename D%> auto consume_%<D%>::%(%) const noexcept
11481156
{%
1149-
auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
1150-
auto const abiType = *(abi_t<%>**)&castedResult;
1151-
check_cast_result(abiType);
1152-
WINRT_VERIFY_(0, abiType->%(%));%
1157+
if constexpr (!std::is_same_v<D, %>)
1158+
{
1159+
auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
1160+
auto const abiType = *(abi_t<%>**)&castedResult;
1161+
check_cast_result(abiType);
1162+
WINRT_VERIFY_(0, abiType->%(%));
1163+
}
1164+
else
1165+
{
1166+
auto const abiType = *(abi_t<%>**)this;
1167+
WINRT_VERIFY_(0, abiType->%(%));
1168+
}%
11531169
}
11541170
)";
11551171
}
@@ -1158,10 +1174,18 @@ namespace cppwinrt
11581174
{
11591175
format = R"( template <typename D%> auto consume_%<D%>::%(%) const
11601176
{%
1161-
auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
1162-
auto const abiType = *(abi_t<%>**)&castedResult;
1163-
check_cast_result(abiType);
1164-
check_hresult(abiType->%(%));%
1177+
if constexpr (!std::is_same_v<D, %>)
1178+
{
1179+
auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
1180+
auto const abiType = *(abi_t<%>**)&castedResult;
1181+
check_cast_result(abiType);
1182+
check_hresult(abiType->%(%));
1183+
}
1184+
else
1185+
{
1186+
auto const abiType = *(abi_t<%>**)this;
1187+
check_hresult(abiType->%(%));
1188+
}%
11651189
}
11661190
)";
11671191
}
@@ -1175,6 +1199,10 @@ namespace cppwinrt
11751199
bind<write_consume_return_type>(signature, false),
11761200
type,
11771201
type,
1202+
type,
1203+
get_abi_name(method),
1204+
bind<write_abi_args>(signature),
1205+
type,
11781206
get_abi_name(method),
11791207
bind<write_abi_args>(signature),
11801208
bind<write_consume_return_statement>(signature));

strings/base_error.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,7 @@ namespace winrt::impl
539539
return result;
540540
}
541541

542-
template <typename T>
543-
WINRT_IMPL_NOINLINE void check_cast_result(T* from, winrt::impl::slim_source_location const& sourceInformation = winrt::impl::slim_source_location::current())
542+
inline WINRT_IMPL_NOINLINE void check_cast_result(void* from, winrt::impl::slim_source_location const& sourceInformation = winrt::impl::slim_source_location::current())
544543
{
545544
if (!from)
546545
{

0 commit comments

Comments
 (0)