Re: [protobuf] oneof and extended messages

2014-11-18 Thread 'Feng Xiao' via Protocol Buffers
On Tue, Nov 18, 2014 at 12:22 AM, Himanshu Agarwal <
agarwal.himanshu...@gmail.com> wrote:

>
> Hello
>
> I was trying to compile following scenerio using protoc:
>
> message SampleMessage {
>  repeated fixed32 i = 1;
>  extensions 100 to 199;
> }
> extend SampleMessage {
>   oneof test_oneof {
>   string name = 126;
>   fixed32 sub_message = 127;
>  }
> }
>
>
> But getting following errors.
>
> SampleMessage.proto:6:3: Expected "required", "optional", or "repeated".
> SampleMessage.proto:6:20: Missing field number.
>

This is not supported. An extension cannot be an oneof.

>
> *Any clue if oneof is supported in extended messages?*
> *Also is there a way to extend oneof field?*
>
> Thank you
>
> Himanshu Agarwal
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at http://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] oneof and extended messages

2014-11-18 Thread Himanshu Agarwal

Hello

I was trying to compile following scenerio using protoc:

message SampleMessage { 
 repeated fixed32 i = 1; 
 extensions 100 to 199;
} 
extend SampleMessage {
  oneof test_oneof { 
  string name = 126; 
  fixed32 sub_message = 127;   
 } 
} 


But getting following errors.

SampleMessage.proto:6:3: Expected "required", "optional", or "repeated".
SampleMessage.proto:6:20: Missing field number.

*Any clue if oneof is supported in extended messages?*
*Also is there a way to extend oneof field?*

Thank you

Himanshu Agarwal

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] "list values" and string values

2014-11-18 Thread Himanshu Agarwal

Hello

I was trying to populate and deserialize following message to string:

message SampleSubMessage{
 repeated string str = 1;
 repeated fixed32 val = 2;
}


message SampleMessage { 
 repeated SampleSubMessage sub = 1; 
} 


I had already set the SetUseShortRepeatedPrimitives to true before 
deserializing the message to string.
However in the output string only integer values were printed in "list 
values" format.

sub {
  str: ""
  str: "4"
  val: [34, 45]
}
sub {
  str: "2"
  str: "7"
  val: [67]
}
sub {
  str: "3"
}


On further investigation i found that follwing code explicitely excludes 
strings and message fields for converting to string.

google\protobuf\text_format.cc:1449


void TextFormat::Printer::PrintField(const Message& message,
 const Reflection* reflection,
 const FieldDescriptor* field,
 TextGenerator& generator) const {
  if (use_short_repeated_primitives_ &&
  field->is_repeated() &&
*  field*
*->cpp_type() != FieldDescriptor::CPPTYPE_STRING &&  field->cpp_type() 
!= FieldDescriptor::CPPTYPE_MESSAGE*) {
PrintShortRepeatedField(message, reflection, field, generator);
return;
  }


Could someone please help me understand the reason for this exclusion.

Thank you

Himanshu Agarwal

.


-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Re: Issue 464 in protobuf: Inefficient Java handling of repeated list of primitive types

2014-11-18 Thread protobuf


Comment #5 on issue 464 by ryan.fog...@gmail.com: Inefficient Java handling  
of repeated list of primitive types

https://code.google.com/p/protobuf/issues/detail?id=464

In case anyone is wondering. I just diffed GPB versions 1.6.0 and 1.6.1 and  
there is no significant changes that would trip up the patch file. I.e. the  
patch derived from TwoSigma's solution and posted Sep14 should work just  
fine for 2.6.1.




--
You received this message because this project is configured to send all  
issue notifications to this address.

You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Re: Issue 515 in protobuf: More intelligent enums

2014-11-18 Thread protobuf


Comment #9 on issue 515 by peterhan...@yahoo.com: More intelligent enums
https://code.google.com/p/protobuf/issues/detail?id=515

Wrapping enum with another message looks ugly to me, and only simple way  
for this so far would be adding prefix for it, like



enum CURRENCY {
   UNKNOWN = 0;
   NONE = 1;
   USD = 2;
  // etc...
}



Don't you mean that a workaround would be to add prefix like this:

enum CURRENCY {
  CURRENCY_UNKNOWN = 0;
  CURRENCY_NONE = 1;
  CURRENCY_USD = 2;
  // etc...
}

?


--
You received this message because this project is configured to send all  
issue notifications to this address.

You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.