mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Deprecate RecordVal::LookupWithDefault() replace with GetFieldOrDefault()
(The former was previously changed during this release cycle to return Intrusive pointer, but this just changes it back to return Val* and deprecates it).
This commit is contained in:
parent
f729247778
commit
2b4d80c849
7 changed files with 26 additions and 11 deletions
3
NEWS
3
NEWS
|
@ -199,6 +199,9 @@ Deprecated Functionality
|
|||
|
||||
- ``RecordVal::Lookup(int)`` is deprecated, use ``RecordVal::GetField(int)``.
|
||||
|
||||
- ``RecordVal::LookupWithDefault(int)`` is deprecated, use
|
||||
``RecordVal::GetFieldOrDefault(int)``.
|
||||
|
||||
Zeek 3.1.0
|
||||
==========
|
||||
|
||||
|
|
|
@ -580,7 +580,7 @@ static void BuildJSON(threading::formatter::JSON::NullDoubleWriter& writer, Val*
|
|||
|
||||
for ( auto i = 0; i < rt->NumFields(); ++i )
|
||||
{
|
||||
auto value = rval->LookupWithDefault(i);
|
||||
auto value = rval->GetFieldOrDefault(i);
|
||||
|
||||
if ( value && ( ! only_loggable || rt->FieldHasAttr(i, ATTR_LOG) ) )
|
||||
{
|
||||
|
@ -2741,7 +2741,7 @@ void RecordVal::Assign(int field, Val* new_val)
|
|||
Assign(field, {AdoptRef{}, new_val});
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> RecordVal::LookupWithDefault(int field) const
|
||||
IntrusivePtr<Val> RecordVal::GetFieldOrDefault(int field) const
|
||||
{
|
||||
const auto& val = (*AsRecord())[field];
|
||||
|
||||
|
@ -2788,7 +2788,7 @@ IntrusivePtr<Val> RecordVal::Lookup(const char* field, bool with_default) const
|
|||
if ( idx < 0 )
|
||||
reporter->InternalError("missing record field: %s", field);
|
||||
|
||||
return with_default ? LookupWithDefault(idx) : GetField(idx);
|
||||
return with_default ? GetFieldOrDefault(idx) : GetField(idx);
|
||||
}
|
||||
|
||||
IntrusivePtr<RecordVal> RecordVal::CoerceTo(IntrusivePtr<RecordType> t,
|
||||
|
|
14
src/Val.h
14
src/Val.h
|
@ -986,7 +986,19 @@ public:
|
|||
IntrusivePtr<T> GetField(int field) const
|
||||
{ return cast_intrusive<T>(GetField(field)); }
|
||||
|
||||
IntrusivePtr<Val> LookupWithDefault(int field) const;
|
||||
/**
|
||||
* Returns the value of a given field index if it's previously been
|
||||
* assigned, * or else returns the value created from evaluating the
|
||||
* record field's &default expression.
|
||||
* @param field The field index to retrieve.
|
||||
* @return The value at the given field index or the default value if
|
||||
* the field hasn't been assigned yet.
|
||||
*/
|
||||
IntrusivePtr<Val> GetFieldOrDefault(int field) const;
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetFieldOrDefault().")]]
|
||||
Val* LookupWithDefault(int field) const
|
||||
{ return GetFieldOrDefault(field).release(); }
|
||||
|
||||
/**
|
||||
* Looks up the value of a field by field name. If the field doesn't
|
||||
|
|
|
@ -971,7 +971,7 @@ broker::expected<broker::data> bro_broker::val_to_data(const Val* v)
|
|||
|
||||
for ( auto i = 0u; i < num_fields; ++i )
|
||||
{
|
||||
auto item_val = rec->LookupWithDefault(i);
|
||||
auto item_val = rec->GetFieldOrDefault(i);
|
||||
|
||||
if ( ! item_val )
|
||||
{
|
||||
|
|
|
@ -161,13 +161,13 @@ void File::RaiseFileOverNewConnection(Connection* conn, bool is_orig)
|
|||
|
||||
uint64_t File::LookupFieldDefaultCount(int idx) const
|
||||
{
|
||||
auto v = val->LookupWithDefault(idx);
|
||||
auto v = val->GetFieldOrDefault(idx);
|
||||
return v->AsCount();
|
||||
}
|
||||
|
||||
double File::LookupFieldDefaultInterval(int idx) const
|
||||
{
|
||||
auto v = val->LookupWithDefault(idx);
|
||||
auto v = val->GetFieldOrDefault(idx);
|
||||
return v->AsInterval();
|
||||
}
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ protected:
|
|||
void IncrementByteCount(uint64_t size, int field_idx);
|
||||
|
||||
/**
|
||||
* Wrapper to RecordVal::LookupWithDefault for the field in #val at index
|
||||
* Wrapper to RecordVal::GetFieldOrDefault for the field in #val at index
|
||||
* \a idx which automatically unrefs the Val and returns a converted value.
|
||||
* @param idx the index of a field of type "count" in \c fa_file.
|
||||
* @return the value of the field, which may be it &default.
|
||||
|
@ -267,7 +267,7 @@ protected:
|
|||
uint64_t LookupFieldDefaultCount(int idx) const;
|
||||
|
||||
/**
|
||||
* Wrapper to RecordVal::LookupWithDefault for the field in #val at index
|
||||
* Wrapper to RecordVal::GetFieldOrDefault for the field in #val at index
|
||||
* \a idx which automatically unrefs the Val and returns a converted value.
|
||||
* @param idx the index of a field of type "interval" in \c fa_file.
|
||||
* @return the value of the field, which may be it &default.
|
||||
|
|
|
@ -1005,13 +1005,13 @@ Val* Manager::RecordValToIndexVal(RecordVal *r) const
|
|||
int num_fields = type->NumFields();
|
||||
|
||||
if ( num_fields == 1 && type->FieldDecl(0)->type->Tag() != TYPE_RECORD )
|
||||
idxval = r->LookupWithDefault(0);
|
||||
idxval = r->GetFieldOrDefault(0);
|
||||
|
||||
else
|
||||
{
|
||||
auto l = make_intrusive<ListVal>(TYPE_ANY);
|
||||
for ( int j = 0 ; j < num_fields; j++ )
|
||||
l->Append(r->LookupWithDefault(j));
|
||||
l->Append(r->GetFieldOrDefault(j));
|
||||
|
||||
idxval = std::move(l);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue