From 83f1a911d72676f3419c85753fdcf341a05e0bae Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Fri, 15 May 2020 19:15:24 -0700 Subject: [PATCH] Deprecate FuncType::ArgTypes(), replace with ParamList() --- NEWS | 2 ++ src/Attr.cc | 4 ++-- src/Type.cc | 2 +- src/Type.h | 4 ++++ src/Val.cc | 4 ++-- src/broker/Manager.cc | 4 ++-- src/input/Manager.cc | 6 +++--- src/logging/Manager.cc | 2 +- src/option.bif | 4 ++-- src/zeek.bif | 4 ++-- 10 files changed, 21 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index cae8a619d7..af3d71bdc2 100644 --- a/NEWS +++ b/NEWS @@ -189,6 +189,8 @@ Deprecated Functionality - ``FuncType::Args()`` is deprecated, use ``FuncType::Params()``. +- ``FuncType::ArgTypes()`` is deprecated, use ``FuncType::ParamList()``. + Zeek 3.1.0 ========== diff --git a/src/Attr.cc b/src/Attr.cc index d26fa443b5..251b1c595c 100644 --- a/src/Attr.cc +++ b/src/Attr.cc @@ -464,7 +464,7 @@ void Attributes::CheckAttr(Attr* a) if (the_table->IsUnspecifiedTable()) break; - const auto& func_index_types = e_ft->ArgTypes()->Types(); + const auto& func_index_types = e_ft->ParamList()->Types(); // Keep backwards compatibility with idx: any idiom. if ( func_index_types.size() == 2 ) { @@ -511,7 +511,7 @@ void Attributes::CheckAttr(Attr* a) if ( the_table->IsUnspecifiedTable() ) break; - const auto& args = c_ft->ArgTypes()->Types(); + const auto& args = c_ft->ParamList()->Types(); const auto& t_indexes = the_table->IndexTypes(); if ( args.size() != ( type->IsSet() ? 2 : 3 ) + t_indexes.size() ) { diff --git a/src/Type.cc b/src/Type.cc index 1fc09beb76..671a98d8e6 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -1513,7 +1513,7 @@ bool same_type(const BroType* t1, const BroType* t2, bool is_init, bool match_re return false; } - return ft1->CheckArgs(ft2->ArgTypes()->Types(), is_init); + return ft1->CheckArgs(ft2->ParamList()->Types(), is_init); } case TYPE_RECORD: diff --git a/src/Type.h b/src/Type.h index 9ecedc0471..1bb81822d5 100644 --- a/src/Type.h +++ b/src/Type.h @@ -495,8 +495,12 @@ public: bool CheckArgs(const std::vector>& args, bool is_init = false) const; + [[deprecated("Remove in v4.1. Use ParamList().")]] TypeList* ArgTypes() const { return arg_types.get(); } + const IntrusivePtr& ParamList() const + { return arg_types; } + void Describe(ODesc* d) const override; void DescribeReST(ODesc* d, bool roles_only = false) const override; diff --git a/src/Val.cc b/src/Val.cc index 4d4c6b8e51..a383086269 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -269,7 +269,7 @@ IntrusivePtr Val::SizeVal() const case TYPE_INTERNAL_OTHER: if ( type->Tag() == TYPE_FUNC ) - return val_mgr->Count(val.func_val->GetType()->ArgTypes()->Types().size()); + return val_mgr->Count(val.func_val->GetType()->ParamList()->Types().size()); if ( type->Tag() == TYPE_FILE ) return make_intrusive(val.file_val->Size(), TYPE_DOUBLE); @@ -2482,7 +2482,7 @@ double TableVal::CallExpireFunc(IntrusivePtr idx) const Func* f = vf->AsFunc(); zeek::Args vl; - const auto& func_args = f->GetType()->ArgTypes()->Types(); + const auto& func_args = f->GetType()->ParamList()->Types(); // backwards compatibility with idx: any idiom bool any_idiom = func_args.size() == 2 && func_args.back()->Tag() == TYPE_ANY; diff --git a/src/broker/Manager.cc b/src/broker/Manager.cc index c441f69900..fb83682e86 100644 --- a/src/broker/Manager.cc +++ b/src/broker/Manager.cc @@ -741,7 +741,7 @@ RecordVal* Manager::MakeEvent(val_list* args, Frame* frame) } const auto& got_type = (*args)[i]->GetType(); - const auto& expected_type = func->GetType()->ArgTypes()->Types()[i - 1]; + const auto& expected_type = func->GetType()->ParamList()->Types()[i - 1]; if ( ! same_type(got_type.get(), expected_type.get()) ) { @@ -977,7 +977,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev) return; } - const auto& arg_types = handler->GetType(false)->ArgTypes()->Types(); + const auto& arg_types = handler->GetType(false)->ParamList()->Types(); if ( arg_types.size() != args.size() ) { diff --git a/src/input/Manager.cc b/src/input/Manager.cc index be2832acc3..1e8c9eba06 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -336,7 +336,7 @@ bool Manager::CreateEventStream(RecordVal* fval) return false; } - const auto& args = etype->ArgTypes()->Types(); + const auto& args = etype->ParamList()->Types(); if ( args.size() < 2 ) { @@ -564,7 +564,7 @@ bool Manager::CreateTableStream(RecordVal* fval) return false; } - const auto& args = etype->ArgTypes()->Types(); + const auto& args = etype->ParamList()->Types(); if ( args.size() != 4 ) { @@ -711,7 +711,7 @@ bool Manager::CheckErrorEventTypes(const std::string& stream_name, const Func* e return false; } - const auto& args = etype->ArgTypes()->Types(); + const auto& args = etype->ParamList()->Types(); if ( args.size() != 3 ) { diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 7bb597309b..f1643eea8b 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -278,7 +278,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval) return false; } - const auto& args = etype->ArgTypes()->Types(); + const auto& args = etype->ParamList()->Types(); if ( args.size() != 1 ) { diff --git a/src/option.bif b/src/option.bif index de9d2894c7..84e3798744 100644 --- a/src/option.bif +++ b/src/option.bif @@ -15,7 +15,7 @@ static bool call_option_handlers_and_set_value(StringVal* name, const IntrusiveP { for ( auto handler_function : i->GetOptionHandlers() ) { - bool add_loc = handler_function->GetType()->ArgTypes()->Types().size() == 3; + bool add_loc = handler_function->GetType()->ParamList()->Types().size() == 3; zeek::Args vl; vl.reserve(2 + add_loc); vl.emplace_back(NewRef{}, name); @@ -170,7 +170,7 @@ function Option::set_change_handler%(ID: string, on_change: any, priority: int & return val_mgr->False(); } - const auto& args = on_change->GetType()->AsFuncType()->ArgTypes()->Types(); + const auto& args = on_change->GetType()->AsFuncType()->ParamList()->Types(); if ( args.size() < 2 || args.size() > 3 ) { builtin_error(fmt("Wrong number of arguments for passed function in Option::on_change for ID '%s'; expected 2 or 3, got %zu", diff --git a/src/zeek.bif b/src/zeek.bif index 0af1ef72f3..685e3e4fdf 100644 --- a/src/zeek.bif +++ b/src/zeek.bif @@ -1438,7 +1438,7 @@ function sort%(v: any, ...%) : any const auto& comp_type = comp->GetType(); if ( comp_type->Yield()->Tag() != TYPE_INT || - ! comp_type->ArgTypes()->AllMatch(elt_type, 0) ) + ! comp_type->ParamList()->AllMatch(elt_type, 0) ) { builtin_error("invalid comparison function in call to sort()"); return rval; @@ -1519,7 +1519,7 @@ function order%(v: any, ...%) : index_vec { const auto& comp_type = comp->GetType()->AsFuncType(); if ( comp_type->Yield()->Tag() != TYPE_INT || - ! comp_type->ArgTypes()->AllMatch(elt_type, 0) ) + ! comp_type->ParamList()->AllMatch(elt_type, 0) ) { builtin_error("invalid comparison function in call to order()"); return IntrusivePtr{NewRef{}, v};