Deprecate FuncType::ArgTypes(), replace with ParamList()

This commit is contained in:
Jon Siwek 2020-05-15 19:15:24 -07:00
parent 40153cc5cb
commit 83f1a911d7
10 changed files with 21 additions and 15 deletions

2
NEWS
View file

@ -189,6 +189,8 @@ Deprecated Functionality
- ``FuncType::Args()`` is deprecated, use ``FuncType::Params()``.
- ``FuncType::ArgTypes()`` is deprecated, use ``FuncType::ParamList()``.
Zeek 3.1.0
==========

View file

@ -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() )
{

View file

@ -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:

View file

@ -495,8 +495,12 @@ public:
bool CheckArgs(const std::vector<IntrusivePtr<BroType>>& args,
bool is_init = false) const;
[[deprecated("Remove in v4.1. Use ParamList().")]]
TypeList* ArgTypes() const { return arg_types.get(); }
const IntrusivePtr<TypeList>& ParamList() const
{ return arg_types; }
void Describe(ODesc* d) const override;
void DescribeReST(ODesc* d, bool roles_only = false) const override;

View file

@ -269,7 +269,7 @@ IntrusivePtr<Val> 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>(val.file_val->Size(), TYPE_DOUBLE);
@ -2482,7 +2482,7 @@ double TableVal::CallExpireFunc(IntrusivePtr<ListVal> 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;

View file

@ -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() )
{

View file

@ -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 )
{

View file

@ -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 )
{

View file

@ -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",

View file

@ -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<Val>{NewRef{}, v};