mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Switch Func::Call(val_list*) back to returning Val*
And renamed the method returning IntrusivePtr to operator(). This corrects the deprecation process for Func::Call(val_list*).
This commit is contained in:
parent
85a0ddd62d
commit
087a0f3636
15 changed files with 43 additions and 44 deletions
8
NEWS
8
NEWS
|
@ -104,10 +104,10 @@ Removed Functionality
|
|||
Deprecated Functionality
|
||||
------------------------
|
||||
|
||||
- The ``Func::Call(val_list*, ...)`` method is now deprecated. The alternate
|
||||
overload taking a ``zeek::Args`` (``std::vector<IntrusivePtr<Val>>``) should
|
||||
be used instead. There's also now a variadic template that forwards all
|
||||
arguments.
|
||||
- The ``Func::Call(val_list*, ...)`` method is now deprecated. Use operator()
|
||||
instead which takes a ``zeek::Args`` (``std::vector<IntrusivePtr<Val>>``).
|
||||
There's also a variadic template for operator() that forwards all arguments
|
||||
into a ``zeek::Args`` for you.
|
||||
|
||||
- The ``EventMgr::QueueEvent()`` and EventMgr::QueueEventFast()`` methods
|
||||
are now deprecated, use ``EventMgr::Enqueue()`` instead.
|
||||
|
|
|
@ -43,7 +43,7 @@ bool Discarder::NextPacket(const IP_Hdr* ip, int len, int caplen)
|
|||
|
||||
try
|
||||
{
|
||||
discard_packet = check_ip->Call(args)->AsBool();
|
||||
discard_packet = check_ip->operator()(args)->AsBool();
|
||||
}
|
||||
|
||||
catch ( InterpreterException& e )
|
||||
|
@ -98,7 +98,7 @@ bool Discarder::NextPacket(const IP_Hdr* ip, int len, int caplen)
|
|||
|
||||
try
|
||||
{
|
||||
discard_packet = check_tcp->Call(args)->AsBool();
|
||||
discard_packet = check_tcp->operator()(args)->AsBool();
|
||||
}
|
||||
|
||||
catch ( InterpreterException& e )
|
||||
|
@ -122,7 +122,7 @@ bool Discarder::NextPacket(const IP_Hdr* ip, int len, int caplen)
|
|||
|
||||
try
|
||||
{
|
||||
discard_packet = check_udp->Call(args)->AsBool();
|
||||
discard_packet = check_udp->operator()(args)->AsBool();
|
||||
}
|
||||
|
||||
catch ( InterpreterException& e )
|
||||
|
@ -142,7 +142,7 @@ bool Discarder::NextPacket(const IP_Hdr* ip, int len, int caplen)
|
|||
|
||||
try
|
||||
{
|
||||
discard_packet = check_icmp->Call(args)->AsBool();
|
||||
discard_packet = check_icmp->operator()(args)->AsBool();
|
||||
}
|
||||
|
||||
catch ( InterpreterException& e )
|
||||
|
|
|
@ -115,7 +115,7 @@ void EventHandler::Call(const zeek::Args& vl, bool no_remote)
|
|||
|
||||
if ( local )
|
||||
// No try/catch here; we pass exceptions upstream.
|
||||
local->Call(vl);
|
||||
local->operator()(vl);
|
||||
}
|
||||
|
||||
void EventHandler::NewEvent(const zeek::Args& vl)
|
||||
|
|
|
@ -4144,7 +4144,7 @@ IntrusivePtr<Val> CallExpr::Eval(Frame* f) const
|
|||
if ( f )
|
||||
f->SetCall(this);
|
||||
|
||||
ret = funcv->Call(*v, f);
|
||||
ret = funcv->operator()(*v, f);
|
||||
|
||||
if ( f )
|
||||
f->SetCall(current_call);
|
||||
|
|
10
src/Func.cc
10
src/Func.cc
|
@ -294,12 +294,10 @@ bool BroFunc::IsPure() const
|
|||
[](const Body& b) { return b.stmts->IsPure(); });
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> Func::Call(val_list* args, Frame* parent) const
|
||||
{
|
||||
return Call(zeek::val_list_to_args(*args), parent);
|
||||
}
|
||||
Val* Func::Call(val_list* args, Frame* parent) const
|
||||
{ return operator()(zeek::val_list_to_args(*args), parent).release(); };
|
||||
|
||||
IntrusivePtr<Val> BroFunc::Call(const zeek::Args& args, Frame* parent) const
|
||||
IntrusivePtr<Val> BroFunc::operator()(const zeek::Args& args, Frame* parent) const
|
||||
{
|
||||
#ifdef PROFILE_BRO_FUNCTIONS
|
||||
DEBUG_MSG("Function: %s\n", Name());
|
||||
|
@ -605,7 +603,7 @@ bool BuiltinFunc::IsPure() const
|
|||
return is_pure;
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> BuiltinFunc::Call(const zeek::Args& args, Frame* parent) const
|
||||
IntrusivePtr<Val> BuiltinFunc::operator()(const zeek::Args& args, Frame* parent) const
|
||||
{
|
||||
#ifdef PROFILE_BRO_FUNCTIONS
|
||||
DEBUG_MSG("Function: %s\n", Name());
|
||||
|
|
17
src/Func.h
17
src/Func.h
|
@ -49,8 +49,8 @@ public:
|
|||
const std::vector<Body>& GetBodies() const { return bodies; }
|
||||
bool HasBodies() const { return bodies.size(); }
|
||||
|
||||
[[deprecated("Remove in v4.1. Use zeek::Args overload instead.")]]
|
||||
virtual IntrusivePtr<Val> Call(val_list* args, Frame* parent = nullptr) const;
|
||||
[[deprecated("Remove in v4.1. Use operator() instead.")]]
|
||||
Val* Call(val_list* args, Frame* parent = nullptr) const;
|
||||
|
||||
/**
|
||||
* Calls a Zeek function.
|
||||
|
@ -58,18 +58,19 @@ public:
|
|||
* @param parent the frame from which the function is being called.
|
||||
* @return the return value of the function call.
|
||||
*/
|
||||
virtual IntrusivePtr<Val> Call(const zeek::Args& args, Frame* parent = nullptr) const = 0;
|
||||
virtual IntrusivePtr<Val> operator()(const zeek::Args& args,
|
||||
Frame* parent = nullptr) const = 0;
|
||||
|
||||
/**
|
||||
* A version of Call() taking a variable number of individual arguments.
|
||||
* A version of operator() taking a variable number of individual arguments.
|
||||
*/
|
||||
template <class... Args>
|
||||
std::enable_if_t<
|
||||
std::is_convertible_v<std::tuple_element_t<0, std::tuple<Args...>>,
|
||||
IntrusivePtr<Val>>,
|
||||
IntrusivePtr<Val>>
|
||||
Call(Args&&... args) const
|
||||
{ return Call(zeek::Args{std::forward<Args>(args)...}); }
|
||||
operator()(Args&&... args) const
|
||||
{ return operator()(zeek::Args{std::forward<Args>(args)...}); }
|
||||
|
||||
// Add a new event handler to an existing function (event).
|
||||
virtual void AddBody(IntrusivePtr<Stmt> new_body, id_list* new_inits,
|
||||
|
@ -128,7 +129,7 @@ public:
|
|||
~BroFunc() override;
|
||||
|
||||
bool IsPure() const override;
|
||||
IntrusivePtr<Val> Call(const zeek::Args& args, Frame* parent) const override;
|
||||
IntrusivePtr<Val> operator()(const zeek::Args& args, Frame* parent) const override;
|
||||
|
||||
/**
|
||||
* Adds adds a closure to the function. Closures are cloned and
|
||||
|
@ -224,7 +225,7 @@ public:
|
|||
~BuiltinFunc() override;
|
||||
|
||||
bool IsPure() const override;
|
||||
IntrusivePtr<Val> Call(const zeek::Args& args, Frame* parent) const override;
|
||||
IntrusivePtr<Val> operator()(const zeek::Args& args, Frame* parent) const override;
|
||||
built_in_func TheFunc() const { return func; }
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
|
|
|
@ -181,7 +181,7 @@ bool RuleConditionEval::DoMatch(Rule* rule, RuleEndpointState* state,
|
|||
|
||||
try
|
||||
{
|
||||
auto val = id->GetVal()->AsFunc()->Call(args);
|
||||
auto val = id->GetVal()->AsFunc()->operator()(args);
|
||||
result = val && val->AsBool();
|
||||
}
|
||||
|
||||
|
|
|
@ -1869,7 +1869,7 @@ IntrusivePtr<Val> TableVal::Default(const IntrusivePtr<Val>& index)
|
|||
|
||||
try
|
||||
{
|
||||
result = f->Call(vl);
|
||||
result = f->operator()(vl);
|
||||
}
|
||||
|
||||
catch ( InterpreterException& e )
|
||||
|
@ -2080,7 +2080,7 @@ void TableVal::CallChangeFunc(const Val* index, Val* old_value, OnChangeType tpe
|
|||
vl.emplace_back(NewRef{}, old_value);
|
||||
|
||||
in_change_func = true;
|
||||
f->Call(vl);
|
||||
f->operator()(vl);
|
||||
}
|
||||
catch ( InterpreterException& e )
|
||||
{
|
||||
|
@ -2538,7 +2538,7 @@ double TableVal::CallExpireFunc(IntrusivePtr<ListVal> idx)
|
|||
vl.emplace_back(std::move(idx));
|
||||
}
|
||||
|
||||
auto result = f->Call(vl);
|
||||
auto result = f->operator()(vl);
|
||||
|
||||
if ( result )
|
||||
secs = result->AsInterval();
|
||||
|
|
|
@ -552,7 +552,7 @@ bool Manager::PublishLogWrite(EnumVal* stream, EnumVal* writer, string path, int
|
|||
std::string serial_data(data, len);
|
||||
free(data);
|
||||
|
||||
auto v = log_topic_func->Call(IntrusivePtr{NewRef{}, stream},
|
||||
auto v = log_topic_func->operator()(IntrusivePtr{NewRef{}, stream},
|
||||
make_intrusive<StringVal>(path));
|
||||
|
||||
if ( ! v )
|
||||
|
|
|
@ -188,7 +188,7 @@ function Cluster::publish_rr%(pool: Pool, key: string, ...%): bool
|
|||
topic_func = global_scope()->Find("Cluster::rr_topic")->GetVal()->AsFunc();
|
||||
|
||||
zeek::Args vl{{NewRef{}, pool}, {NewRef{}, key}};
|
||||
auto topic = topic_func->Call(vl);
|
||||
auto topic = topic_func->operator()(vl);
|
||||
|
||||
if ( ! topic->AsString()->Len() )
|
||||
return val_mgr->False();
|
||||
|
@ -225,7 +225,7 @@ function Cluster::publish_hrw%(pool: Pool, key: any, ...%): bool
|
|||
topic_func = global_scope()->Find("Cluster::hrw_topic")->GetVal()->AsFunc();
|
||||
|
||||
zeek::Args vl{{NewRef{}, pool}, {NewRef{}, key}};
|
||||
auto topic = topic_func->Call(vl);
|
||||
auto topic = topic_func->operator()(vl);
|
||||
|
||||
if ( ! topic->AsString()->Len() )
|
||||
return val_mgr->False();
|
||||
|
|
|
@ -61,7 +61,7 @@ bool file_analysis::X509::EndOfFile()
|
|||
return false;
|
||||
// yup, let's call the callback.
|
||||
|
||||
cache_hit_callback->Call(IntrusivePtr{NewRef{}, GetFile()->GetVal()},
|
||||
cache_hit_callback->operator()(IntrusivePtr{NewRef{}, GetFile()->GetVal()},
|
||||
entry, make_intrusive<StringVal>(cert_sha256));
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1778,7 +1778,7 @@ bool Manager::CallPred(Func* pred_func, const int numvals, ...) const
|
|||
|
||||
va_end(lP);
|
||||
|
||||
auto v = pred_func->Call(vl);
|
||||
auto v = pred_func->operator()(vl);
|
||||
|
||||
if ( v )
|
||||
result = v->AsBool();
|
||||
|
|
|
@ -721,7 +721,7 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
|
|||
// See whether the predicates indicates that we want
|
||||
// to log this record.
|
||||
int result = 1;
|
||||
auto v = filter->pred->Call(columns);
|
||||
auto v = filter->pred->operator()(columns);
|
||||
|
||||
if ( v )
|
||||
result = v->AsBool();
|
||||
|
@ -748,7 +748,7 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
|
|||
// Can be TYPE_ANY here.
|
||||
rec_arg = columns;
|
||||
|
||||
auto v = filter->path_func->Call(IntrusivePtr{NewRef{}, id},
|
||||
auto v = filter->path_func->operator()(IntrusivePtr{NewRef{}, id},
|
||||
std::move(path_arg),
|
||||
std::move(rec_arg));
|
||||
|
||||
|
@ -1054,7 +1054,7 @@ threading::Value** Manager::RecordToFilterVals(Stream* stream, Filter* filter,
|
|||
|
||||
if ( filter->num_ext_fields > 0 )
|
||||
{
|
||||
auto res = filter->ext_func->Call(IntrusivePtr{NewRef{}, filter->path_val});
|
||||
auto res = filter->ext_func->operator()(IntrusivePtr{NewRef{}, filter->path_val});
|
||||
|
||||
if ( res )
|
||||
ext_rec = {AdoptRef{}, res.release()->AsRecordVal()};
|
||||
|
@ -1531,7 +1531,7 @@ bool Manager::FinishedRotation(WriterFrontend* writer, const char* new_name, con
|
|||
// Call the postprocessor function.
|
||||
int result = 0;
|
||||
|
||||
auto v = func->Call(std::move(info));
|
||||
auto v = func->operator()(std::move(info));
|
||||
if ( v )
|
||||
result = v->AsBool();
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ static bool call_option_handlers_and_set_value(StringVal* name, const IntrusiveP
|
|||
if ( add_loc )
|
||||
vl.emplace_back(NewRef{}, location);
|
||||
|
||||
val = handler_function->Call(vl); // consumed by next call.
|
||||
val = handler_function->operator()(vl); // consumed by next call.
|
||||
|
||||
if ( ! val )
|
||||
{
|
||||
|
|
|
@ -1338,7 +1338,7 @@ bool sort_function(Val* a, Val* b)
|
|||
if ( ! b )
|
||||
return 1;
|
||||
|
||||
auto result = sort_function_comp->Call(IntrusivePtr{NewRef{}, a},
|
||||
auto result = sort_function_comp->operator()(IntrusivePtr{NewRef{}, a},
|
||||
IntrusivePtr{NewRef{}, b});
|
||||
int int_result = result->CoerceToInt();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue