Merge branch 'topic/jsiwek/template-containers-merge'

* topic/jsiwek/template-containers-merge:
  Fix a potential usage of List::remove_nth(-1)
  Change List::remote(const T&) to return a bool
  Fix debug build due to old int_list usage within assert
  Convert uses of loop_over_list to ranged-for loops
  Remove loop_over_queue (as an example for later removing loop_over_list)
  Change int_list in CCL.h to be a vector, fix uses of int_list to match
  Remove List<> usage from strings.bif
  Replace uses of the old Queue/PQueue generation code with new template versions
  Convert BaseQueue/Queue/PQueue into templates, including iterator support
  Replace uses of the old Dict generation code with new template versions
  Convert PDict into template
  Replace uses of the old List generation code with new template versions
  Convert BaseList/List/PList into templates, including iterator support

* Generally squashed fixups from topic/timw/template-containers

* Add missing include file in List.h: <cassert>
This commit is contained in:
Jon Siwek 2019-07-15 19:46:04 -07:00
commit 8c45937798
68 changed files with 1111 additions and 1249 deletions

View file

@ -207,16 +207,16 @@ unsigned int BroType::MemoryAllocation() const
TypeList::~TypeList()
{
loop_over_list(types, i)
Unref(types[i]);
for ( const auto& type : types )
Unref(type);
Unref(pure_type);
}
int TypeList::AllMatch(const BroType* t, int is_init) const
{
loop_over_list(types, i)
if ( ! same_type(types[i], t, is_init) )
for ( const auto& type : types )
if ( ! same_type(type, t, is_init) )
return 0;
return 1;
}
@ -381,9 +381,8 @@ TableType::TableType(TypeList* ind, BroType* yield)
type_list* tl = indices->Types();
loop_over_list(*tl, i)
for ( const auto& tli : *tl )
{
BroType* tli = (*tl)[i];
InternalTypeTag t = tli->InternalType();
if ( t == TYPE_INTERNAL_ERROR )
@ -704,8 +703,8 @@ RecordType::RecordType(type_decl_list* arg_types) : BroType(TYPE_RECORD)
RecordType* RecordType::ShallowClone()
{
auto pass = new type_decl_list();
loop_over_list(*types, i)
pass->append(new TypeDecl(*(*types)[i]));
for ( const auto& type : *types )
pass->append(new TypeDecl(*type));
return new RecordType(pass);
}
@ -713,8 +712,8 @@ RecordType::~RecordType()
{
if ( types )
{
loop_over_list(*types, i)
delete (*types)[i];
for ( auto type : *types )
delete type;
delete types;
}
@ -823,17 +822,15 @@ const char* RecordType::AddFields(type_decl_list* others, attr_list* attr)
if ( attr )
{
loop_over_list(*attr, j)
for ( const auto& at : *attr )
{
if ( (*attr)[j]->Tag() == ATTR_LOG )
if ( at->Tag() == ATTR_LOG )
log = true;
}
}
loop_over_list(*others, i)
for ( const auto& td : *others )
{
TypeDecl* td = (*others)[i];
if ( ! td->FindAttr(ATTR_DEFAULT) &&
! td->FindAttr(ATTR_OPTIONAL) )
return "extension field must be &optional or have &default";
@ -883,11 +880,11 @@ void RecordType::DescribeFields(ODesc* d) const
{
d->AddCount(0);
d->AddCount(types->length());
loop_over_list(*types, i)
for ( const auto& type : *types )
{
(*types)[i]->type->Describe(d);
type->type->Describe(d);
d->SP();
d->Add((*types)[i]->id);
d->Add(type->id);
d->SP();
}
}