binpac: Allow more than one &require attribute on a field.

Patch by François Pennaneach <francois.pennaneach@free.fr>.

BIT-1753 #close
This commit is contained in:
Johanna Amann 2016-11-30 10:18:23 -08:00 committed by Tim Wojtulewicz
parent ffe92f487f
commit e4c168836e
2 changed files with 9 additions and 6 deletions

View file

@ -60,7 +60,7 @@ Type::Type(TypeType tot)
attr_multiline_end_ = 0; attr_multiline_end_ = 0;
attr_oneline_ = false; attr_oneline_ = false;
attr_refcount_ = false; attr_refcount_ = false;
attr_requires_ = 0; attr_requires_ = new ExprList();
attr_restofdata_ = false; attr_restofdata_ = false;
attr_restofflow_ = false; attr_restofflow_ = false;
attr_transient_ = false; attr_transient_ = false;
@ -80,7 +80,7 @@ Type::~Type()
delete attr_if_expr_; delete attr_if_expr_;
delete attr_length_expr_; delete attr_length_expr_;
delete_list(ExprList, attr_checks_); delete_list(ExprList, attr_checks_);
delete attr_requires_; delete_list(ExprList, attr_requires_);
} }
Type *Type::Clone() const Type *Type::Clone() const
@ -203,7 +203,7 @@ void Type::ProcessAttr(Attr* a)
break; break;
case ATTR_REQUIRES: case ATTR_REQUIRES:
attr_requires_ = a->expr(); attr_requires_->push_back(a->expr());
break; break;
case ATTR_TRANSIENT: case ATTR_TRANSIENT:
@ -723,8 +723,11 @@ void Type::GenParseCode2(Output* out_cc, Env* env,
void Type::GenParseCode3(Output* out_cc, Env* env, const DataPtr& data, int flags) void Type::GenParseCode3(Output* out_cc, Env* env, const DataPtr& data, int flags)
{ {
if ( attr_requires_ ) foreach(i, ExprList, attr_requires_)
attr_requires_->EvalExpr(out_cc, env); {
Expr *req = *i;
req->EvalExpr(out_cc, env);
}
foreach(i, FieldList, fields_) foreach(i, FieldList, fields_)
{ {

View file

@ -290,7 +290,7 @@ protected:
Expr *attr_multiline_end_; Expr *attr_multiline_end_;
bool attr_oneline_; bool attr_oneline_;
bool attr_refcount_; bool attr_refcount_;
Expr *attr_requires_; ExprList *attr_requires_;
bool attr_restofdata_; bool attr_restofdata_;
bool attr_restofflow_; bool attr_restofflow_;
bool attr_transient_; bool attr_transient_;