[protobuf] Re: Issue 416 in protobuf: HasField is throwing UnsupportedOperationException on repeated fields

2012-09-10 Thread protobuf
Updates: Status: WorkingAsIntended Comment #1 on issue 416 by jas...@google.com: HasField is throwing UnsupportedOperationException on repeated fields http://code.google.com/p/protobuf/issues/detail?id=416 Do you really get an UnsupportedOperationException? You should get

[protobuf] protobuf test generation

2012-09-10 Thread Sean Larsson
Is there a tool that can be used to generated test cases given a .proto file? I'm looking for something that will take a .proto file, and then generate source code that creates the different message structures and assigns random values to fields for testing purposes. I'm specifically

Re: [protobuf] Serializing List of Objects

2012-09-10 Thread Amina Khalique
Hi Marc, I had a similar question about the serialization of objects using protocol buffers. I prefer using a single .proto file for generation of C# and Java file, and would like to know if my understanding of how to implement a generic list of objects in the .proto file is right or not.

[protobuf] Message Migration Practice?

2012-09-10 Thread Minhyuk Kwon
Hello, I have plan for introducing protobuf to in our products for passing information of product's input project file structure. And this information may frequently upgrade near future(via product version upgrade). So, I have a question. If I remove old field from message and add new field,

[protobuf] how make an DynamicMessage to known message?

2012-09-10 Thread qtom zheng
i do like following, and id does success; ListFieldDescriptor fieldlist = dynamicmsg.getDescriptorForType().getFields(); Protocal.Builder buildermsg = Protocal.newBuilder(); for(FieldDescriptor fieldDp : fieldlist){ buildermsg.setField(fieldDp, dynamicmsg .getField(fieldDp));

[protobuf] how to createmessage by messagename

2012-09-10 Thread qtom zheng
public static Message createMessage(String messageName) { FileDescriptor dps = Addressbook.getDescriptor(); System.out.println(dps.getPackage()); Descriptor dp = dps.findMessageTypeByName(messageName); ... return null; } by the messageName I have got the Descriptor

Re: [protobuf] Creating Dummy Protos

2012-09-10 Thread Jason Hsueh
Are you using the getFooBuilder() methods? A common practice for tests is to use the TextFormat: you can write out the string representation of the pb you want, and then parse into a PB object. Or you could narrow the API of your methods under test to take only the submessages that they need.

Re: [protobuf] how to createmessage by messagename

2012-09-10 Thread Jason Hsueh
You would need to list out all the message types you want to use, and maintain a map from their Descriptor to their default instance (accessible with getDefaultInstance()). You can then call newBuilder or other construction methods. If you are ok with using a dynamic rather than generated message

Re: [protobuf] how make an DynamicMessage to known message?

2012-09-10 Thread Jason Hsueh
You can also copy via serialization: Protocal.parseFrom(dynamicmsg.toByteArray()); On Sun, Sep 2, 2012 at 8:32 PM, qtom zheng zhfnj...@gmail.com wrote: i do like following, and id does success; ListFieldDescriptor fieldlist = dynamicmsg.getDescriptorForType().getFields();

Re: [protobuf] Why not using deque instead of vector in function: ListFields to avoid frequently new/delete

2012-09-10 Thread Jason Hsueh
You can control whether the vector is empty or not: you can reserve memory for the vector based on the descriptor size, or reuse a vector previously passed to ListFields - calling vector::clear() does not delete the allocated memory. Admittedly, the reflection code is not heavily optimized. But

Re: [protobuf] Message Migration Practice?

2012-09-10 Thread Jason Hsueh
The general practices for changing messages are listed here: https://developers.google.com/protocol-buffers/docs/proto#updating. On Wed, Sep 5, 2012 at 7:04 PM, Minhyuk Kwon mug...@gmail.com wrote: Hello, I have plan for introducing protobuf to in our products for passing information of