isphinx / protobuf-actionscript3

Automatically exported from code.google.com/p/protobuf-actionscript3
0 stars 0 forks source link

CodedOutputStream.writeMessage(fieldNumber:int, value:Message):void doesn't support 3 or more levels of message nesting #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by b...@philippe.pascalonline.org on 18 Mar 2009 at 7:42

GoogleCodeExporter commented 8 years ago
Oups, pressed enter too fast. Description:

if message A contains message B, which contains message C

then message A will have the wrong size for message B, because the calculation 
of the
size of message B will forget the byte for the tag and the byte for size of 
message C.

Need to be solved by first writing B to a tempStream, then measuring its real 
size.

Original comment by b...@philippe.pascalonline.org on 18 Mar 2009 at 7:45

GoogleCodeExporter commented 8 years ago
The change is:

public function writeMessage(fieldNumber:int, value:Message):void {
        writeTag(fieldNumber, WireFormat.WIRETYPE_LENGTH_DELIMITED);
        var tempStream:ByteArray = new ByteArray();
        value.writeToDataOutput(tempStream);
        tempStream.position = 0;
        writeRawVarint32(tempStream.length);
        output.writeBytes(tempStream,0,tempStream.length);
      }

instead of

public function writeMessage(fieldNumber:int, value:Message):void {
        writeTag(fieldNumber, WireFormat.WIRETYPE_LENGTH_DELIMITED);
        writeRawVarint32(value.getSerializedSize());
        value.writeToCodedStream(this);
      }

Original comment by b...@philippe.pascalonline.org on 18 Mar 2009 at 7:46

GoogleCodeExporter commented 8 years ago
fix in trunk@10 , released in v1.0.3

Original comment by sorrydevil@gmail.com on 18 Mar 2009 at 7:53