support for transmitting of capture-semantics closures via Broker, while keeping deprecated functionality

This commit is contained in:
Vern Paxson 2021-01-04 14:29:07 -08:00
parent e531b2a7ca
commit 80f7d36582
5 changed files with 166 additions and 35 deletions

View file

@ -395,7 +395,7 @@ struct val_converter {
if ( t->Tag() != TYPE_FUNC )
return nullptr;
if ( a.size() == 2 ) // We have a closure.
if ( a.size() == 2 ) // we have a closure/capture frame
{
auto frame = broker::get_if<broker::vector>(a[1]);
if ( ! frame )
@ -405,8 +405,20 @@ struct val_converter {
if ( ! b )
return nullptr;
if ( ! b->UpdateClosure(*frame) )
return nullptr;
auto copy_semantics =
b->GetType()->GetCaptures() != nullptr;
if ( copy_semantics )
{
if ( ! b->DeserializeCaptures(*frame) )
return nullptr;
}
else
{
// Support for deprecated serialization.
if ( ! b->UpdateClosure(*frame) )
return nullptr;
}
}
return rval;