mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 23:58:20 +00:00
Merge remote branch 'origin/topic/jsiwek/pybroccoli-fixes'
* origin/topic/jsiwek/pybroccoli-fixes: Move event arg. record coercion check; now only done for recv'd remote events Update istate.pybroccoli test.
This commit is contained in:
commit
8432258db0
2 changed files with 25 additions and 1 deletions
|
@ -2734,6 +2734,30 @@ void RemoteSerializer::GotEvent(const char* name, double time,
|
|||
e->handler = event;
|
||||
e->args = args;
|
||||
|
||||
// If needed, coerce received record arguments to the expected record type.
|
||||
if ( e->handler->FType() )
|
||||
{
|
||||
const type_list* arg_types = e->handler->FType()->ArgTypes()->Types();
|
||||
loop_over_list(*args, i)
|
||||
{
|
||||
Val* v = (*args)[i];
|
||||
BroType* v_t = v->Type();
|
||||
BroType* arg_t = (*arg_types)[i];
|
||||
if ( v_t->Tag() == TYPE_RECORD && arg_t->Tag() == TYPE_RECORD )
|
||||
{
|
||||
if ( ! same_type(v_t, arg_t) )
|
||||
{
|
||||
Val* nv = v->AsRecordVal()->CoerceTo(arg_t->AsRecordType());
|
||||
if ( nv )
|
||||
{
|
||||
args->replace(i, nv);
|
||||
Unref(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
events.append(e);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue