binpac: Add scoping to usages of binpac::Exception classes in generated code.

This allows analyzers to define their own types of the same name
without mistakingly overshadowing the usages of binpac::Exception
and its derived types in the generated parser code.
This commit is contained in:
Jon Siwek 2012-11-12 11:44:14 -06:00 committed by Tim Wojtulewicz
parent 6c70f7851b
commit 14e3d5a1a3
6 changed files with 13 additions and 11 deletions

View file

@ -168,7 +168,7 @@ void CaseType::DoGenParseCode(Output* out_cc, Env* env,
{
out_cc->println("default:");
out_cc->inc_indent();
out_cc->println("throw ExceptionInvalidCaseIndex(\"%s\", %s);",
out_cc->println("throw binpac::ExceptionInvalidCaseIndex(\"%s\", %s);",
decl_id()->Name(), env->RValue(index_var_));
out_cc->println("break;");
out_cc->dec_indent();
@ -302,7 +302,8 @@ void CaseField::GenPubDecls(Output* out_h, Env* env)
out_h->println("default:");
out_h->inc_indent();
out_h->println("throw ExceptionInvalidCase(\"%s\", %s, \"%s\");",
out_h->println(
"throw binpac::ExceptionInvalidCase(\"%s\", %s, \"%s\");",
id_->LocName(),
env->RValue(index_var_),
OrigExprList(index_).c_str());

View file

@ -52,7 +52,7 @@ void DataPtr::GenBoundaryCheck(Output* out_cc, Env* env,
char* data_offset = AbsOffsetExpr(env, begin_of_data);
out_cc->println("// Handle out-of-bound condition");
out_cc->println("throw ExceptionOutOfBound(\"%s\",", data_name);
out_cc->println("throw binpac::ExceptionOutOfBound(\"%s\",", data_name);
out_cc->println(" (%s) + (%s), ",
data_offset, data_size);
out_cc->println(" (%s) - (%s));",

View file

@ -295,7 +295,7 @@ void Expr::GenCaseEval(Output *out_cc, Env *env)
}
else
{
out_cc->println("throw ExceptionInvalidCaseIndex(\"%s\", %s);",
out_cc->println("throw binpac::ExceptionInvalidCaseIndex(\"%s\", %s);",
Location(), operand_[0]->EvalExpr(out_cc, env));
}
out_cc->println("break;");

View file

@ -226,7 +226,7 @@ void FlowDecl::GenProcessFunc(Output *out_h, Output *out_cc)
out_cc->println("}");
out_cc->dec_indent();
out_cc->println("catch ( Exception const &e )");
out_cc->println("catch ( binpac::Exception const &e )");
out_cc->inc_indent();
out_cc->println("{");
GenCleanUpCode(out_cc);

View file

@ -617,7 +617,7 @@ void RecordPaddingField::GenFieldEnd(Output* out_cc, Env* env, const DataPtr& fi
field_begin.ptr_expr());
out_cc->inc_indent();
out_cc->println("{");
out_cc->println("// throw ExceptionInvalidOffset(\"%s\", %s - %s, %s);",
out_cc->println("// throw binpac::ExceptionInvalidOffset(\"%s\", %s - %s, %s);",
id_->LocName(),
field_begin.ptr_expr(),
env->RValue(begin_of_data),

View file

@ -283,7 +283,8 @@ void StringType::DoGenParseCode(Output* out_cc, Env* env,
out_cc->println("// check for negative sizes");
out_cc->println("if ( %s < 0 )",
str_size.c_str());
out_cc->println("throw ExceptionInvalidStringLength(\"%s\", %s);",
out_cc->println(
"throw binpac::ExceptionInvalidStringLength(\"%s\", %s);",
Location(), str_size.c_str());
out_cc->println("%s.init(%s, %s);",
env->LValue(value_var()),
@ -301,7 +302,7 @@ void StringType::DoGenParseCode(Output* out_cc, Env* env,
void StringType::GenStringMismatch(Output* out_cc, Env* env,
const DataPtr& data, const char *pattern)
{
out_cc->println("throw ExceptionStringMismatch(\"%s\", %s, %s);",
out_cc->println("throw binpac::ExceptionStringMismatch(\"%s\", %s, %s);",
Location(),
pattern,
fmt("string((const char *) (%s), (const char *) %s).c_str()",