@@ -619,10 +619,15 @@ namespace cppwinrt
619619 }
620620 }
621621
622- static void write_abi_args (writer& w, method_signature const & method_signature)
622+ static void write_abi_args (writer& w, method_signature const & method_signature, bool start_comma )
623623 {
624624 separator s{ w };
625625
626+ if (start_comma)
627+ {
628+ s ();
629+ }
630+
626631 for (auto && [param, param_signature] : method_signature.params ())
627632 {
628633 s ();
@@ -1135,39 +1140,15 @@ namespace cppwinrt
11351140 // immediately while preserving the error code and local variables.
11361141 format = R"( template <typename D%> auto consume_%<D%>::%(%) const noexcept
11371142 {%
1138- if constexpr (!std::is_same_v<D, %>)
1139- {
1140- winrt::hresult _winrt_cast_result_code;
1141- auto const _winrt_casted_result = impl::try_as_with_reason<%, D const*>(static_cast<D const*>(this), _winrt_cast_result_code);
1142- check_hresult(_winrt_cast_result_code);
1143- auto const _winrt_abi_type = *(abi_t<%>**)&_winrt_casted_result;
1144- _winrt_abi_type->%(%);
1145- }
1146- else
1147- {
1148- auto const _winrt_abi_type = *(abi_t<%>**)this;
1149- _winrt_abi_type->%(%);
1150- }%
1143+ consume_noexcept_remove_overload<%, D>(static_cast<D const*>(this), &abi_t<%>::%%);%
11511144 }
11521145)" ;
11531146 }
11541147 else
11551148 {
11561149 format = R"( template <typename D%> auto consume_%<D%>::%(%) const noexcept
11571150 {%
1158- if constexpr (!std::is_same_v<D, %>)
1159- {
1160- winrt::hresult _winrt_cast_result_code;
1161- auto const _winrt_casted_result = impl::try_as_with_reason<%, D const*>(static_cast<D const*>(this), _winrt_cast_result_code);
1162- check_hresult(_winrt_cast_result_code);
1163- auto const _winrt_abi_type = *(abi_t<%>**)&_winrt_casted_result;
1164- WINRT_VERIFY_(0, _winrt_abi_type->%(%));
1165- }
1166- else
1167- {
1168- auto const _winrt_abi_type = *(abi_t<%>**)this;
1169- WINRT_VERIFY_(0, _winrt_abi_type->%(%));
1170- }%
1151+ consume_noexcept<%, D>(static_cast<D const*>(this), &abi_t<%>::%%);%
11711152 }
11721153)" ;
11731154 }
@@ -1176,19 +1157,7 @@ namespace cppwinrt
11761157 {
11771158 format = R"( template <typename D%> auto consume_%<D%>::%(%) const
11781159 {%
1179- if constexpr (!std::is_same_v<D, %>)
1180- {
1181- winrt::hresult _winrt_cast_result_code;
1182- auto const _winrt_casted_result = impl::try_as_with_reason<%, D const*>(static_cast<D const*>(this), _winrt_cast_result_code);
1183- check_hresult(_winrt_cast_result_code);
1184- auto const _winrt_abi_type = *(abi_t<%>**)&_winrt_casted_result;
1185- check_hresult(_winrt_abi_type->%(%));
1186- }
1187- else
1188- {
1189- auto const _winrt_abi_type = *(abi_t<%>**)this;
1190- check_hresult(_winrt_abi_type->%(%));
1191- }%
1160+ consume_general<%, D>(static_cast<D const*>(this), &abi_t<%>::%%);%
11921161 }
11931162)" ;
11941163 }
@@ -1202,12 +1171,8 @@ namespace cppwinrt
12021171 bind<write_consume_return_type>(signature, false ),
12031172 type,
12041173 type,
1205- type,
1206- get_abi_name (method),
1207- bind<write_abi_args>(signature),
1208- type,
12091174 get_abi_name (method),
1210- bind<write_abi_args>(signature),
1175+ bind<write_abi_args>(signature, true ),
12111176 bind<write_consume_return_statement>(signature));
12121177
12131178 if (is_add_overload (method))
@@ -2750,7 +2715,7 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable<T, D, %>
27502715 bind<write_consume_return_type>(signature, true ),
27512716 type_name,
27522717 bind_list (" , " , generics),
2753- bind<write_abi_args>(signature),
2718+ bind<write_abi_args>(signature, false ),
27542719 bind<write_consume_return_statement>(signature));
27552720 }
27562721 else
@@ -2822,7 +2787,7 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable<T, D, %>
28222787 bind<write_consume_params>(signature),
28232788 bind<write_consume_return_type>(signature, true ),
28242789 type_name,
2825- bind<write_abi_args>(signature),
2790+ bind<write_abi_args>(signature, false ),
28262791 bind<write_consume_return_statement>(signature));
28272792 }
28282793 }
0 commit comments