mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
Merge branch 'topic/robin/extend-records' into topic/robin/logging-internals
Includes some fixes for using &log with record-extension.
This commit is contained in:
commit
1cbde793d8
8 changed files with 118 additions and 8 deletions
39
src/Type.cc
39
src/Type.cc
|
@ -900,6 +900,45 @@ void RecordType::Describe(ODesc* d) const
|
|||
}
|
||||
}
|
||||
|
||||
const char* RecordType::AddFields(type_decl_list* others, attr_list* attr)
|
||||
{
|
||||
assert(types);
|
||||
|
||||
bool log = false;
|
||||
|
||||
if ( attr )
|
||||
{
|
||||
loop_over_list(*attr, j)
|
||||
{
|
||||
if ( (*attr)[j]->Tag() == ATTR_LOG )
|
||||
log = true;
|
||||
}
|
||||
}
|
||||
|
||||
loop_over_list(*others, i)
|
||||
{
|
||||
TypeDecl* td = (*others)[i];
|
||||
|
||||
if ( ! td->FindAttr(ATTR_DEFAULT) && ! td->FindAttr(ATTR_OPTIONAL) )
|
||||
return "extension field must be &optional or have &default";
|
||||
|
||||
if ( log )
|
||||
{
|
||||
if ( ! td->attrs )
|
||||
td->attrs = new Attributes(new attr_list, td->type);
|
||||
|
||||
td->attrs->AddAttr(new Attr(ATTR_LOG));
|
||||
}
|
||||
|
||||
types->append(td);
|
||||
}
|
||||
|
||||
delete others;
|
||||
|
||||
num_fields = types->length();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RecordType::DescribeFields(ODesc* d) const
|
||||
{
|
||||
if ( d->IsReadable() )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue