support for subclassing ScriptFunc's, esp. for alternate lambda closures

This commit is contained in:
Vern Paxson 2021-03-18 10:10:44 -07:00
parent 91c2e05099
commit 78f18b4fa6
3 changed files with 26 additions and 6 deletions

View file

@ -392,6 +392,17 @@ struct val_converter {
if ( a.size() == 2 ) // we have a closure/capture frame
{
// Note, seems if we already have a separate
// instance of the same lambda, then unless
// we use a cloned value, we'll step on that
// one's captures, too. This is because
// the capture mapping lives with the Func
// object rather than the FuncVal. However,
// we can't readily Clone() here because
// rval is const (and, grrr, Clone() is not).
// -VP
// rval = rval->Clone();
auto frame = broker::get_if<broker::vector>(a[1]);
if ( ! frame )
return nullptr;
@ -400,9 +411,7 @@ struct val_converter {
if ( ! b )
return nullptr;
auto copy_semantics = b->GetType()->GetCaptures().has_value();
if ( copy_semantics )
if ( b->CopySemantics() )
{
if ( ! b->DeserializeCaptures(*frame) )
return nullptr;