Closed GoogleCodeExporter closed 8 years ago
Could you express your point clearly? I don't know what you are talking about.
Original comment by pop.atry@gmail.com
on 8 Nov 2011 at 12:55
Thank you for your reply.
My writing was too brief.
1. dynamic class
Generate from the following messages.
//----- message
message KeyValue {
optional string Key = 1;
optional string Value = 2;
extensions 1000 to max;
}
The following classes are generated.
//----- generated class
public dynamic final class KeyValue extends Array implements
flash.utils.IExternalizable, com.netease.protobuf.IMessage {
^^^^^^^ <- dynamic class
}
Since dynamic class is an obstacle of debugging, I do not want to use.
2. unknown field
An addition is needed for a message.
//----- message
message KeyValue {
optional string Key = 1;
optional string Value = 2;
optional string Description = 3; // ADD
extensions 1000 to max;
}
Description is the unknown field for the class generated before.
Version 0.9.1, This field value lost by the writeExternal method.
Version 1.0.0-rc6, When data with this field was received, the exception
occurred by the readFromSlice method.
Original comment by mk.trans...@gmail.com
on 9 Nov 2011 at 1:30
It had forgotten to write an important thing.
I have deleted dynamic declaration.
Original comment by mk.trans...@gmail.com
on 9 Nov 2011 at 1:38
1. v0.9.x will use dynamic class if the message has extensions. v1.0.x will
always use dynamic class to hold unknown fields and extensions.
2. v1.0.x will store unknown fields. I tested your message and I didn't see
exception occurred.
Original comment by pop.atry@gmail.com
on 9 Nov 2011 at 6:41
v1.0.0-rc6
If there is dynamic declaration, Don't see exception.
I have deleted dynamic declaration, I receive the following error.
ReferenceError: Error #1069: KeyValue にプロパティ 26
が見つからず、デフォルト値もありません。
at com.netease.protobuf::Message/readUnknown()[C:\cygwin\home\Atry\Desktop\protoc-gen-as3\as3\com\netease\protobuf\Message.as:156]
at com.netease.protobuf::Message/readExtensionOrUnknown()[C:\cygwin\home\Atry\Desktop\protoc-gen-as3\as3\com\netease\protobuf\Message.as:174]
at KeyValue/readFromSlice()[C:\FlashDevelop\ProtoBuf\KeyValue.as:97]
at ProtoBuf()[C:\FlashDevelop\ProtoBuf\ProtoBuf.as:31]
//--- sample
package {
import com.netease.protobuf.*;
import flash.display.Sprite;
import flash.utils.ByteArray;
import flash.utils.IDataInput;
import com.hurlant.util.Base64;
public class ProtoBuf extends Sprite
{
public function ProtoBuf()
{
/*
var kv:KeyValue = new KeyValue(); // This is new "KeyValue", Include "Description".
kv.key = "Key";
kv.value = "Value";
kv.description = "Description";
var data:ByteArray = new ByteArray();
kv.writeTo(data);
trace(Base64.encodeByteArray(data)); // CgNLZXkSBVZhbHVlGgtEZXNjcmlwdGlvbg==
*/
var dataString:String = "CgNLZXkSBVZhbHVlGgtEZXNjcmlwdGlvbg==";
var data:ByteArray = Base64.decodeToByteArray(dataString);
var kv:KeyValue = new KeyValue(); // This is old "KeyValue", Unknowing "Description" and remove dynamic.
kv.readFromSlice(data, 0); // ReferenceError
}
}
}
It is not a defect that an error occurs.
I wish to support Unknown and Extension without making a dynamic declaration.
Original comment by mk.trans...@gmail.com
on 9 Nov 2011 at 10:55
I would also like the dynamic word to be removed. I don't like it because it
prevents getting compiler errors if you use wrong attributes.
Original comment by TiRSO.00
on 9 Nov 2011 at 5:05
This project is aim to implement protobuf in a NATIVE way with minimum API.
`dynamic` is the native way for extensions and unknown fields. Other solutions,
such as wrap extensions and unknown fields in another Array/Object will create
more object, and these solutions all introduce more API other than
ActionScript's native way.
Original comment by pop.atry@gmail.com
on 10 Nov 2011 at 1:05
During development, I delete dynamic declaration.
When deployment, I give it.
Thank you.
Original comment by mk.trans...@gmail.com
on 10 Nov 2011 at 1:51
Original comment by pop.atry@gmail.com
on 10 Nov 2011 at 6:45
Issue 43 has been merged into this issue.
Original comment by pop.atry@gmail.com
on 11 May 2013 at 4:32
Original issue reported on code.google.com by
mk.trans...@gmail.com
on 7 Nov 2011 at 8:19