zhaopuming / quickfast

Automatically exported from code.google.com/p/quickfast
Other
1 stars 0 forks source link

Function presenceMapBitCount doesn't return a correct value #42

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It happens because finalize functions of FieldInstructionGroup and
FieldInstructionSequence don't set presenceMapBitsUsed_, so if a template
has an optinal group it has to return 1 but it will return 0 instead.

To solve this, I propose this:

FieldInstructionGroup::finalize(...)
{
  segmentBody_->finalize(...);

  if (!isMandatory())
    presenceMapBitsUsed_ = 1;
}

FieldInstructionSequence::finalize(...)
{
  segmentBody_->finalize(...);

  const Codecs::FieldInstructionPtr& lengthInstruction =
segment_->getLengthInstruction();

  lengthInstruction->finalize(templateRegistry);
  presenceMapBitsUsed_ = lengthInstruction->getPresenceMapBitsUsed();
}

Original issue reported on code.google.com by carlo...@gmail.com on 12 Apr 2010 at 12:30

GoogleCodeExporter commented 9 years ago
I was able to reproduce the problem for groups, but not for sequences.  Still 
experimenting.

Original comment by dale.wil...@gmail.com on 13 Apr 2010 at 9:12

GoogleCodeExporter commented 9 years ago
Let me give you a clue:

<sequence name=NAME>
  <length name=LENGTH><copy/></length>
</sequence>

If you don't use an operator, quickfast will choose NOP operator, what it means 
it
won't need any bit in the PMAP.

Original comment by carlo...@gmail.com on 13 Apr 2010 at 9:52

GoogleCodeExporter commented 9 years ago
@carlos: But the code in getFieldOp that uses the length instruction's operator 
for 
the sequence makes it work correctly.

The problem did exist for groups, and I made a fix similar to what you 
suggested.

There is a new unit test in testXMLTemplateParser for this problem, it also 
tests 
sequences to verify that they behave correctly.

Change is in R391.

Original comment by dale.wil...@gmail.com on 14 Apr 2010 at 6:29

GoogleCodeExporter commented 9 years ago
Yeah!, you are right. It was my fault, I was not working with the last revision,
sometimes It's hard to me keep your pace

Original comment by carlo...@gmail.com on 14 Apr 2010 at 10:48