Merge remote-tracking branch 'origin/topic/vern/cpp-new-func'

- Removed a couple of dead statements during merge

* origin/topic/vern/cpp-new-func:
  option for deterministic descriptions of sets & tables
  determinism for concurrent Zeek test suite invocations; split out deprecations
  disambiguate descriptions of enums; include attributes when describing records
  more liberal view of attribute equality; allow suppressing attr type-checking
  support for operations on sets that return new values
  low-level addition of enum values
  sundry accessors/cast-ers; RE_Matcher's track their construction values
  convenience functions for comparing IP addresses
This commit is contained in:
Jon Siwek 2021-03-23 19:05:10 -07:00
commit f46d3dec8f
38 changed files with 371 additions and 102 deletions

View file

@ -147,6 +147,18 @@ FuncType* Type::AsFuncType()
return (FuncType*) this;
}
const FileType* Type::AsFileType() const
{
CHECK_TYPE_TAG(TYPE_FILE, "Type::AsFileType");
return (const FileType*) this;
}
FileType* Type::AsFileType()
{
CHECK_TYPE_TAG(TYPE_FILE, "Type::AsFileType");
return (FileType*) this;
}
const EnumType* Type::AsEnumType() const
{
CHECK_TYPE_TAG(TYPE_ENUM, "Type::AsEnumType");
@ -1052,6 +1064,12 @@ void RecordType::DescribeFields(ODesc* d) const
else
td->type->Describe(d);
if ( td->attrs )
{
d->SP();
td->attrs->Describe(d);
}
d->Add(";");
}
}
@ -1355,6 +1373,14 @@ void EnumType::AddNameInternal(const string& module_name, const char* name,
names[fullname] = val;
}
void EnumType::AddNameInternal(const string& full_name, bro_int_t val)
{
names[full_name] = val;
if ( vals.find(val) == vals.end() )
vals[val] = make_intrusive<EnumVal>(IntrusivePtr{NewRef{}, this}, val);
}
bro_int_t EnumType::Lookup(const string& module_name, const char* name) const
{
NameMap::const_iterator pos =
@ -1399,6 +1425,27 @@ const EnumValPtr& EnumType::GetEnumVal(bro_int_t i)
return it->second;
}
void EnumType::Describe(ODesc* d) const
{
auto t = Tag();
if ( d->IsBinary() )
{
d->Add(int(t));
if ( ! d->IsShort() )
d->Add(GetName());
}
else
{
d->Add(type_name(t));
if ( ! d->IsShort() )
{
d->SP();
d->Add(GetName());
}
}
}
void EnumType::DescribeReST(ODesc* d, bool roles_only) const
{
d->Add(":zeek:type:`enum`");