Skip to content

Commit 959ae02

Browse files
authored
Use auto trick to catch missing header files for auto_revoke (#1136)
1 parent c4a8e24 commit 959ae02

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

cppwinrt/code_writers.h

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ namespace cppwinrt
10011001
if (is_add_overload(method))
10021002
{
10031003
auto format = R"( using %_revoker = impl::event_revoker<%, &impl::abi_t<%>::remove_%>;
1004-
[[nodiscard]] %_revoker %(auto_revoke_t, %) const;
1004+
[[nodiscard]] auto %(auto_revoke_t, %) const;
10051005
)";
10061006

10071007
w.write(format,
@@ -1010,7 +1010,6 @@ namespace cppwinrt
10101010
type,
10111011
method_name,
10121012
method_name,
1013-
method_name,
10141013
bind<write_consume_params>(signature));
10151014
}
10161015
}
@@ -1170,7 +1169,7 @@ namespace cppwinrt
11701169

11711170
if (is_add_overload(method))
11721171
{
1173-
format = R"( template <typename D%> typename consume_%<D%>::%_revoker consume_%<D%>::%(auto_revoke_t, %) const
1172+
format = R"( template <typename D%> auto consume_%<D%>::%(auto_revoke_t, %) const
11741173
{
11751174
return impl::make_event_revoker<D, %_revoker>(this, %(%));
11761175
}
@@ -1181,9 +1180,6 @@ namespace cppwinrt
11811180
type_impl_name,
11821181
bind<write_comma_generic_types>(generics),
11831182
method_name,
1184-
type_impl_name,
1185-
bind<write_comma_generic_types>(generics),
1186-
method_name,
11871183
bind<write_consume_params>(signature),
11881184
method_name,
11891185
method_name,
@@ -1214,15 +1210,13 @@ namespace cppwinrt
12141210

12151211
if (is_add_overload(method))
12161212
{
1217-
format = R"( inline %::%_revoker %::%(auto_revoke_t, %) const
1213+
format = R"( inline auto %::%(auto_revoke_t, %) const
12181214
{
12191215
return impl::make_event_revoker<D, %_revoker>(this, %(%));
12201216
}
12211217
)";
12221218

12231219
w.write(format,
1224-
class_type.TypeName(),
1225-
method_name,
12261220
class_type.TypeName(),
12271221
method_name,
12281222
bind<write_consume_params>(signature),
@@ -3017,7 +3011,7 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable<T, D, %>
30173011
if (is_add_overload(method))
30183012
{
30193013
auto format = R"( using %_revoker = impl::factory_event_revoker<%, &impl::abi_t<%>::remove_%>;
3020-
[[nodiscard]] static %_revoker %(auto_revoke_t, %);
3014+
[[nodiscard]] static auto %(auto_revoke_t, %);
30213015
)";
30223016

30233017
w.write(format,
@@ -3026,7 +3020,6 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable<T, D, %>
30263020
factory.second.type,
30273021
method_name,
30283022
method_name,
3029-
method_name,
30303023
bind<write_consume_params>(signature));
30313024
}
30323025
}
@@ -3056,21 +3049,21 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable<T, D, %>
30563049

30573050
if (is_add_overload(method))
30583051
{
3059-
auto format = R"( inline %::%_revoker %::%(auto_revoke_t, %)
3052+
auto format = R"( inline auto %::%(auto_revoke_t, %)
30603053
{
30613054
auto f = get_activation_factory<%, %>();
3062-
return { f, f.%(%) };
3055+
return %::%_revoker{ f, f.%(%) };
30633056
}
30643057
)";
30653058

30663059
w.write(format,
3067-
type_name,
3068-
method_name,
30693060
type_name,
30703061
method_name,
30713062
bind<write_consume_params>(signature),
30723063
type_name,
30733064
factory,
3065+
type_name,
3066+
method_name,
30743067
method_name,
30753068
bind<write_consume_args>(signature));
30763069
}

cppwinrt/component_writers.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,22 +518,22 @@ catch (...) { return winrt::to_hresult(); }
518518

519519
if (is_add_overload(method))
520520
{
521-
auto format = R"( %::%_revoker %::%(auto_revoke_t, %)
521+
auto format = R"( auto %::%(auto_revoke_t, %)
522522
{
523523
auto f = make<winrt::@::factory_implementation::%>().as<%>();
524-
return { f, f.%(%) };
524+
return %::%_revoker{ f, f.%(%) };
525525
}
526526
)";
527527

528528
w.write(format,
529-
type_name,
530-
method_name,
531529
type_name,
532530
method_name,
533531
bind<write_consume_params>(signature),
534532
type_namespace,
535533
type_name,
536534
factory_name,
535+
type_name,
536+
method_name,
537537
method_name,
538538
bind<write_consume_args>(signature));
539539
}

0 commit comments

Comments
 (0)