[protobuf] C++ JsonToBinaryStream losing large uint32 values

2016-02-11 Thread Ron
Hi,

I'm using the proto3 C++ library compiled in MSVC, and noticed some pretty 
strange behavior - using the JsonToBinaryString or JsonToBinaryStream 
functions, values in the upper half of the uint32 range get lost in the 
transition from JSON to binary.

After some investigation, it seems the issue's root cause is in the 
MathUtil::Sign function (called from NumberConvertAndCheck, which is called 
from DataPiece::GenericConvert, which gets called 
from DataPiece::ToUint32...)

When compiled in Release mode (with optimizations) it seems, the ternary 
condition operator in that function gets optimized incorrectly (the 
assembly code generated looks as if it's treated as int32 instead of 
uint32), causing the Sign function to return an incorrect result in the 
case of those larger uint32 values, which in turn causes a condition in 
some if statement in NumberConvertAndCheck to evaluate to false when it 
should be true, thus causing the value to be dropped.

Now obviously this is not really a protobuf issue, but more likely a 
compiler bug (opened an issue regarding this with Microsoft 
),
 
but since it's likely to be a while until the compiler issue is addressed 
(if at all) and since protobuf does support MSVC compilers, I would suggest 
that until then the issue should probably be handled with a workaround in 
the protobuf code in the meantime, for instance by changing that ternary 
condition operator to a simple if-else statement (seems to compile 
correctly, without this issue), or simply removing optimization flags when 
compiling with VS2010/VS2012/VS2013/VS2015, although this is probably a 
less desirable solution.

Thanks,
Ron

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Serializing mixed type array with protobuf

2016-02-11 Thread Flo Loferer
In my Objective-C code, I have an array of items of mixed types I'd like to 
serialize with protobuf.

Is this possible and if so, what would the message look like?

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Serializing mixed type arrays with protobuf

2016-02-11 Thread Flo Loferer
I have an array containing two different object types.

Is there a chance to serialize this array with protobuf?
What would the message definition look like?

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Using different versions of Protobuf

2016-02-11 Thread Andrea Ferretti
Hi, I am trying to understand how to manage the difference in runtime 
classes across protobuf versions.

Protobuf is designed so that people are able to evolve versions of their 
own schemas without breaking things. This has some limitations, but in some 
way works.

The real issue arises when having to do with multiple versions of protobuf 
itself. Let me take an example: on a new project (written in Scala, using 
protobuf for Java) we would like to try Protobuf 3. But we have to talk to 
HBase, and the client itself uses protobuf 2.5.0. We have tried using 
protobuf 3 and hoping for backward compatibility, but of course everything 
borke at runtime. So we settled for protobuf 2.5.0. But now we would also 
need to integrate some things with Apache Kudu. And of course, they use 
protobuf 2.6.1, and that exact version is required.

Since only one version of protobuf can be on the classpath at any time, 
this becomes more and more of a problem as the projects using protobuf for 
their own internal protocol increase.

Does anyone know a way to handle this problem effectively?

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Re: Unhelpful compiler warning when a file has no syntax declaration

2016-02-11 Thread 'Josh Haberman' via Protocol Buffers
Hi there -- sorry for the delay on your PR, a couple guys are OOTO right 
now so we're a bit backed up. I just merged it.

In general, we should be monitoring PR's and not letting them sit too long. 
A conversation first can be good if the change is involved, but for simple 
changes like this just submitting the PR should be enough.

Thanks,
Josh

On Wednesday, February 10, 2016 at 7:55:55 AM UTC-8, Josh Humphries wrote:
>
> The protoc compiler emits a warning message whenever it encounters a proto 
> file that has no syntax level declared. But the warning doesn't indicate 
> the filename. I'd like our builds to be warning-free. But with a make task 
> that builds *lots* of protos at once, it's a total nuisance to find the 
> offending file. The protoc compiler really should just indicate the name of 
> the file in the warning.
>
> I opened a pull request a few days ago to fix this:
> https://github.com/google/protobuf/pull/1217
> It hasn't gotten any attention.
>
> What's the best policy for trying to submit changes? Should I start a 
> discussion on this group first, to give visibility to it? Or is there some 
> time window I should allow (few days?) before expecting any 
> attention/comments on a pull request?
>
> Thanks in advance.
>
> 
> *Josh Humphries*
> Manager, Shared Systems  |  Platform Engineering
> Atlanta, GA  |  678-400-4867
> *Square* (www.squareup.com)
>

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.