Skip to content

Commit

Permalink
added out param default to event source handlers (#884)
Browse files Browse the repository at this point in the history
* added out param default to event source handlers

* Update code_writers.h
  • Loading branch information
ujjwalchadha authored Jun 17, 2021
1 parent 84a3654 commit 3b640ea
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,17 @@ namespace cswinrt
w.write("default(%)", bind<write_projection_type>(semantics));
}

void write_event_out_defaults(writer& w, method_signature const& methodSig)
{
for (auto&& param : methodSig.params())
{
if (get_param_category(param) == param_category::out || get_param_category(param) == param_category::receive_array)
{
w.write("\n% = default(%);", bind<write_parameter_name>(param), bind<write_projection_type>(get_type_semantics(param.second->Type())));
}
}
}

void write_event_invoke_args(writer& w, method_signature const& methodSig)
{
w.write("%", bind_list<write_parameter_name_with_modifier>(", ", methodSig.params()));
Expand Down Expand Up @@ -6471,7 +6482,7 @@ handler = (%) =>
{
var localDel = _event;
if (localDel == null)
{
{%
return %;
}
%localDel.Invoke(%);
Expand All @@ -6488,6 +6499,7 @@ return handler;
eventTypeCode,
bind<write_event_source_type_name>(eventTypeSemantics),
bind<write_event_invoke_params>(invokeMethodSig),
bind<write_event_out_defaults>(invokeMethodSig),
bind<write_event_invoke_return_default>(invokeMethodSig),
bind<write_event_invoke_return>(invokeMethodSig),
bind<write_event_invoke_args>(invokeMethodSig));
Expand Down

0 comments on commit 3b640ea

Please sign in to comment.