mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
Merge remote-tracking branch 'origin/master' into topic/johanna/remove-serializer
This commit is contained in:
commit
4792c94212
13 changed files with 262 additions and 25 deletions
37
src/Val.cc
37
src/Val.cc
|
@ -2704,6 +2704,43 @@ bool VectorVal::AssignRepeat(unsigned int index, unsigned int how_many,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool VectorVal::Insert(unsigned int index, Val* element)
|
||||
{
|
||||
if ( element &&
|
||||
! same_type(element->Type(), vector_type->YieldType(), 0) )
|
||||
{
|
||||
Unref(element);
|
||||
return false;
|
||||
}
|
||||
|
||||
vector<Val*>::iterator it;
|
||||
|
||||
if ( index < val.vector_val->size() )
|
||||
it = std::next(val.vector_val->begin(), index);
|
||||
else
|
||||
it = val.vector_val->end();
|
||||
|
||||
// Note: we do *not* Ref() the element, if any, at this point.
|
||||
// AssignExpr::Eval() already does this; other callers must remember
|
||||
// to do it similarly.
|
||||
val.vector_val->insert(it, element);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VectorVal::Remove(unsigned int index)
|
||||
{
|
||||
if ( index >= val.vector_val->size() )
|
||||
return false;
|
||||
|
||||
Val* val_at_index = (*val.vector_val)[index];
|
||||
auto it = std::next(val.vector_val->begin(), index);
|
||||
val.vector_val->erase(it);
|
||||
Unref(val_at_index);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int VectorVal::AddTo(Val* val, int /* is_first_init */) const
|
||||
{
|
||||
if ( val->Type()->Tag() != TYPE_VECTOR )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue