mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +00:00
Use vector<IntrusivePtr<Val>> for Func::Call and Event queuing args
This change may break BIFs that use @ARGS@, @ARG@, or @ARGC@ since their types have changed.
This commit is contained in:
parent
94656c2308
commit
4e1ac4e124
29 changed files with 367 additions and 305 deletions
|
@ -60,7 +60,7 @@ void EventHandler::SetLocalHandler(Func* f)
|
|||
local = f;
|
||||
}
|
||||
|
||||
void EventHandler::Call(val_list* vl, bool no_remote)
|
||||
void EventHandler::Call(const zeek::Args& vl, bool no_remote)
|
||||
{
|
||||
#ifdef PROFILE_BRO_FUNCTIONS
|
||||
DEBUG_MSG("Event: %s\n", Name());
|
||||
|
@ -75,12 +75,12 @@ void EventHandler::Call(val_list* vl, bool no_remote)
|
|||
{
|
||||
// Send event in form [name, xs...] where xs represent the arguments.
|
||||
broker::vector xs;
|
||||
xs.reserve(vl->length());
|
||||
xs.reserve(vl.size());
|
||||
bool valid_args = true;
|
||||
|
||||
for ( auto i = 0; i < vl->length(); ++i )
|
||||
for ( auto i = 0u; i < vl.size(); ++i )
|
||||
{
|
||||
auto opt_data = bro_broker::val_to_data((*vl)[i]);
|
||||
auto opt_data = bro_broker::val_to_data(vl[i].get());
|
||||
|
||||
if ( opt_data )
|
||||
xs.emplace_back(move(*opt_data));
|
||||
|
@ -115,14 +115,9 @@ void EventHandler::Call(val_list* vl, bool no_remote)
|
|||
if ( local )
|
||||
// No try/catch here; we pass exceptions upstream.
|
||||
local->Call(vl);
|
||||
else
|
||||
{
|
||||
for ( auto v : *vl )
|
||||
Unref(v);
|
||||
}
|
||||
}
|
||||
|
||||
void EventHandler::NewEvent(val_list* vl)
|
||||
void EventHandler::NewEvent(const zeek::Args& vl)
|
||||
{
|
||||
if ( ! new_event )
|
||||
return;
|
||||
|
@ -132,7 +127,7 @@ void EventHandler::NewEvent(val_list* vl)
|
|||
return;
|
||||
|
||||
RecordType* args = FType()->Args();
|
||||
VectorVal* vargs = new VectorVal(call_argument_vector);
|
||||
auto vargs = make_intrusive<VectorVal>(call_argument_vector);
|
||||
|
||||
for ( int i = 0; i < args->NumFields(); i++ )
|
||||
{
|
||||
|
@ -151,19 +146,15 @@ void EventHandler::NewEvent(val_list* vl)
|
|||
if ( fdefault )
|
||||
rec->Assign(2, std::move(fdefault));
|
||||
|
||||
if ( i < vl->length() && (*vl)[i] )
|
||||
{
|
||||
Val* val = (*vl)[i];
|
||||
Ref(val);
|
||||
rec->Assign(3, val);
|
||||
}
|
||||
if ( i < static_cast<int>(vl.size()) && vl[i] )
|
||||
rec->Assign(3, vl[i]);
|
||||
|
||||
vargs->Assign(i, std::move(rec));
|
||||
}
|
||||
|
||||
Event* ev = new Event(new_event, {
|
||||
new StringVal(name),
|
||||
vargs,
|
||||
make_intrusive<StringVal>(name),
|
||||
std::move(vargs),
|
||||
});
|
||||
mgr.Dispatch(ev);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue