mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 20:18:20 +00:00
Coerce event handler record arguments to correct record type.
This lets events be sent to bro that contain record arguments that don't have to fill in all &optional record fields. This corresponds to broccoli-python tests that were updated in commit 8b87d8f61ef89162019cd4acc01be93700b0c588
This commit is contained in:
parent
4f6690776c
commit
303dba6372
2 changed files with 29 additions and 0 deletions
|
@ -69,7 +69,32 @@ void EventHandler::Call(val_list* vl, bool no_remote)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( local )
|
if ( local )
|
||||||
|
{
|
||||||
|
if ( FType() )
|
||||||
|
{
|
||||||
|
const type_list* arg_types = type->ArgTypes()->Types();
|
||||||
|
loop_over_list(*vl, i)
|
||||||
|
{
|
||||||
|
Val* v = (*vl)[i];
|
||||||
|
BroType* va_t = v->Type();
|
||||||
|
BroType* ar_t = (*arg_types)[i];
|
||||||
|
if ( va_t->Tag() == TYPE_RECORD && ar_t->Tag() == TYPE_RECORD )
|
||||||
|
{
|
||||||
|
if ( ! same_type(va_t, ar_t) )
|
||||||
|
{
|
||||||
|
Val* nv;
|
||||||
|
nv = v->AsRecordVal()->CoerceTo(ar_t->AsRecordType());
|
||||||
|
if ( nv )
|
||||||
|
{
|
||||||
|
vl->replace(i, nv);
|
||||||
|
Unref(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Unref(local->Call(vl));
|
Unref(local->Call(vl));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
loop_over_list(*vl, i)
|
loop_over_list(*vl, i)
|
||||||
|
|
|
@ -13,3 +13,7 @@ Servus
|
||||||
==== record
|
==== record
|
||||||
[a=42, b=6.6.7.7]
|
[a=42, b=6.6.7.7]
|
||||||
42, 6.6.7.7
|
42, 6.6.7.7
|
||||||
|
==== coerced record
|
||||||
|
[a=13, b=<uninitialized>, c=helloworld]
|
||||||
|
13
|
||||||
|
helloworld
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue