Skip to content

Commit

Permalink
Allow more than one &require attribute on a field.
Browse files Browse the repository at this point in the history
Patch by François Pennaneach <[email protected]>.

BIT-1753 #close
  • Loading branch information
0xxon committed Nov 30, 2016
1 parent 0965c04 commit a0990e6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

0.46-1 | 2016-11-30 10:18:23 -0800

* Allow more than one &require attribute on a field. (François Pennaneach)

0.46 | 2016-10-27 14:41:38 -0700

* Release 0.46.
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. -*- mode: rst-mode -*-
..
.. Version number is filled in automatically.
.. |version| replace:: 0.46
.. |version| replace:: 0.46-1

======
BinPAC
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.46
0.46-1
13 changes: 8 additions & 5 deletions src/pac_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Type::Type(TypeType tot)
attr_multiline_end_ = 0;
attr_oneline_ = false;
attr_refcount_ = false;
attr_requires_ = 0;
attr_requires_ = new ExprList();
attr_restofdata_ = false;
attr_restofflow_ = false;
attr_transient_ = false;
Expand All @@ -80,7 +80,7 @@ Type::~Type()
delete attr_if_expr_;
delete attr_length_expr_;
delete_list(ExprList, attr_checks_);
delete attr_requires_;
delete_list(ExprList, attr_requires_);
}

Type *Type::Clone() const
Expand Down Expand Up @@ -203,7 +203,7 @@ void Type::ProcessAttr(Attr* a)
break;

case ATTR_REQUIRES:
attr_requires_ = a->expr();
attr_requires_->push_back(a->expr());
break;

case ATTR_TRANSIENT:
Expand Down Expand Up @@ -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)
{
if ( attr_requires_ )
attr_requires_->EvalExpr(out_cc, env);
foreach(i, ExprList, attr_requires_)
{
Expr *req = *i;
req->EvalExpr(out_cc, env);
}

foreach(i, FieldList, fields_)
{
Expand Down
2 changes: 1 addition & 1 deletion src/pac_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class Type : public Object, public DataDepElement
Expr *attr_multiline_end_;
bool attr_oneline_;
bool attr_refcount_;
Expr *attr_requires_;
ExprList *attr_requires_;
bool attr_restofdata_;
bool attr_restofflow_;
bool attr_transient_;
Expand Down

0 comments on commit a0990e6

Please sign in to comment.