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:
Robin Sommer 2011-03-28 18:56:19 -07:00
commit 1cbde793d8
8 changed files with 118 additions and 8 deletions

View file

@ -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() )