diff options
-rw-r--r-- | conformance/conformance_test.cc | 1 | ||||
-rw-r--r-- | conformance/failure_list_ruby.txt | 1 | ||||
-rw-r--r-- | objectivec/GPBCodedOutputStream.h | 9 | ||||
-rw-r--r-- | objectivec/GPBCodedOutputStream.m | 9 | ||||
-rw-r--r-- | objectivec/GPBMessage.h | 9 | ||||
-rw-r--r-- | src/google/protobuf/stubs/strutil.cc | 2 |
6 files changed, 28 insertions, 3 deletions
diff --git a/conformance/conformance_test.cc b/conformance/conformance_test.cc index 0dd7787c..a899435d 100644 --- a/conformance/conformance_test.cc +++ b/conformance/conformance_test.cc @@ -759,6 +759,7 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, }); TestValidDataForType(FieldDescriptor::TYPE_FLOAT, { {flt(0.1), "0.1"}, + {flt(1.00000075e-36), "1.00000075e-36"}, {flt(3.402823e+38), "3.402823e+38"}, // 3.40282347e+38 {flt(1.17549435e-38f), "1.17549435e-38"} }); diff --git a/conformance/failure_list_ruby.txt b/conformance/failure_list_ruby.txt index 1de6c439..4bac533e 100644 --- a/conformance/failure_list_ruby.txt +++ b/conformance/failure_list_ruby.txt @@ -199,5 +199,6 @@ Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput +Required.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput Required.TimestampProtoInputTooLarge.JsonOutput Required.TimestampProtoInputTooSmall.JsonOutput diff --git a/objectivec/GPBCodedOutputStream.h b/objectivec/GPBCodedOutputStream.h index d6fff3db..23c404b8 100644 --- a/objectivec/GPBCodedOutputStream.h +++ b/objectivec/GPBCodedOutputStream.h @@ -47,11 +47,20 @@ NS_ASSUME_NONNULL_BEGIN /** + * @c GPBCodedOutputStream exception names. + **/ +extern NSString *const GPBCodedOutputStreamException_OutOfSpace; +extern NSString *const GPBCodedOutputStreamException_WriteFailed; + +/** * Writes out protocol message fields. * * The common uses of protocol buffers shouldn't need to use this class. * GPBMessage's provide a -data method that will serialize the message for you. * + * @note Any -write* api can raise the GPBCodedOutputStreamException_* + * exceptions. + * * @note Subclassing of GPBCodedOutputStream is NOT supported. **/ @interface GPBCodedOutputStream : NSObject diff --git a/objectivec/GPBCodedOutputStream.m b/objectivec/GPBCodedOutputStream.m index 7c3ab447..c299040f 100644 --- a/objectivec/GPBCodedOutputStream.m +++ b/objectivec/GPBCodedOutputStream.m @@ -36,6 +36,11 @@ #import "GPBUnknownFieldSet_PackagePrivate.h" #import "GPBUtilities_PackagePrivate.h" +// These values are the existing values so as not to break any code that might +// have already been inspecting them when they weren't documented/exposed. +NSString *const GPBCodedOutputStreamException_OutOfSpace = @"OutOfSpace"; +NSString *const GPBCodedOutputStreamException_WriteFailed = @"WriteFailed"; + // Structure for containing state of a GPBCodedInputStream. Brought out into // a struct so that we can inline several common functions instead of dealing // with overhead of ObjC dispatch. @@ -59,13 +64,13 @@ static const int32_t LITTLE_ENDIAN_64_SIZE = sizeof(uint64_t); static void GPBRefreshBuffer(GPBOutputBufferState *state) { if (state->output == nil) { // We're writing to a single buffer. - [NSException raise:@"OutOfSpace" format:@""]; + [NSException raise:GPBCodedOutputStreamException_OutOfSpace format:@""]; } if (state->position != 0) { NSInteger written = [state->output write:state->bytes maxLength:state->position]; if (written != (NSInteger)state->position) { - [NSException raise:@"WriteFailed" format:@""]; + [NSException raise:GPBCodedOutputStreamException_WriteFailed format:@""]; } state->position = 0; } diff --git a/objectivec/GPBMessage.h b/objectivec/GPBMessage.h index 2c325ba8..276740d2 100644 --- a/objectivec/GPBMessage.h +++ b/objectivec/GPBMessage.h @@ -292,6 +292,9 @@ CF_EXTERN_C_END * Writes out the message to the given coded output stream. * * @param output The coded output stream into which to write the message. + * + * @note This can raise the GPBCodedOutputStreamException_* exceptions. + * **/ - (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output; @@ -299,6 +302,8 @@ CF_EXTERN_C_END * Writes out the message to the given output stream. * * @param output The output stream into which to write the message. + * + * @note This can raise the GPBCodedOutputStreamException_* exceptions. **/ - (void)writeToOutputStream:(NSOutputStream *)output; @@ -307,6 +312,8 @@ CF_EXTERN_C_END * the given output stream. * * @param output The coded output stream into which to write the message. + * + * @note This can raise the GPBCodedOutputStreamException_* exceptions. **/ - (void)writeDelimitedToCodedOutputStream:(GPBCodedOutputStream *)output; @@ -315,6 +322,8 @@ CF_EXTERN_C_END * the given output stream. * * @param output The output stream into which to write the message. + * + * @note This can raise the GPBCodedOutputStreamException_* exceptions. **/ - (void)writeDelimitedToOutputStream:(NSOutputStream *)output; diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc index 336894b5..1a4d71c8 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc @@ -1401,7 +1401,7 @@ char* FloatToBuffer(float value, char* buffer) { float parsed_value; if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) { int snprintf_result = - snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG+2, value); + snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG+3, value); // Should never overflow; see above. GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); |