isphinx / protobuf-actionscript3

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

repeatedを使ったclassでgetSerializedSizeをするとInvalidProtocolBufferExceptionになる。 #16

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. repeatedを使ったclassでgetSerializedSizeをすると
InvalidProtocolBufferExceptionになる。

原因:type分けしているif文でvalue is Arrayをしてない。

CodedInputStream.as

  public static function computeFieldSize(number:int, value:*):int {

    if (value is String)
        return computeStringSize(number, (value as String));
    else if (value is Boolean) 
        return computeBoolSize(number, (value as Boolean));
    else if (value is uint) 
        return computeUInt32Size(number, (value as uint));
    else if (value is int)
        return computeInt32Size(number, (value as int));
    else if (value is Number)
        return computeInt64Size(number, (value as BigInteger));
    else if ( value is Message )
        return value.getSerializedSize();

    //add Array Type
    else if ( value is Array )
    {
        var size:int = 0;
        for each ( var elem:* in value )
        {
            size += computeFieldSize( number, elem );
        }
        return size;
    }   
    //add End

    else
        throw  new InvalidProtocolBufferException( "Could not compute size 
of field, type was not valid");
  }

Original issue reported on code.google.com by piggest0...@gmail.com on 5 Jan 2010 at 5:06

GoogleCodeExporter commented 8 years ago
Could you clean up the chinese caracters (assuming they are chinese), and add a
description of the problem in english (or french, if you fancy). Otherwise, I'm
afraid I can't help.

Original comment by sorrydevil@gmail.com on 5 Jan 2010 at 7:06

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I'm sorry. 
I'm weak in English.
Therefore I was supported by web translation.

(By the way, I am a Japanese not a Chinese.)

When getSerializedSize is done by using "repeated", 
InvalidProtocolBufferException is 
thrown out. 

// proto file
    message TestMessage {
        enum En { GAME_TYPE = 9001; MSG_TYPE = 1001; }
        repeated string member = 1;
    }

//my test code
    var msg:TestMessage = new TestMessage();
    msg.member[0]   = "hoge1";
    msg.member[1]   = "hoge2";
    msg.member[2]   = "hoge3";

    msg.getSerializedSize(); //< Throw InvalidProtocolBufferException

It causes because of not corresponding to the case for the above-mentioned 
source to 
use "repeated". 

Source inside
//add Array Type
~
// Add End

 is a code that I wrote. 

Would it support "repeated"?

Original comment by piggest0...@gmail.com on 7 Jan 2010 at 4:05

GoogleCodeExporter commented 8 years ago
Hi I am also wondering what the status for repeated is. Thanks!

Original comment by eric.bichara@gmail.com on 31 Aug 2010 at 12:58