diff --git a/objectivec/GPBAny.pbobjc.m b/objectivec/GPBAny.pbobjc.m index ada41e569d3d..9b7939d52b34 100644 --- a/objectivec/GPBAny.pbobjc.m +++ b/objectivec/GPBAny.pbobjc.m @@ -91,9 +91,9 @@ + (GPBDescriptor *)descriptor { "\001\001\004\241!!\000"; [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; #endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; diff --git a/objectivec/GPBApi.pbobjc.m b/objectivec/GPBApi.pbobjc.m index a6283a84f176..b416445c0f04 100644 --- a/objectivec/GPBApi.pbobjc.m +++ b/objectivec/GPBApi.pbobjc.m @@ -145,9 +145,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBApi__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -272,9 +272,9 @@ + (GPBDescriptor *)descriptor { "\002\002\007\244\241!!\000\004\010\244\241!!\000"; [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; #endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -341,9 +341,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBMixin__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; diff --git a/objectivec/GPBDuration.pbobjc.m b/objectivec/GPBDuration.pbobjc.m index 1a54a76b306c..a618e9cd57b5 100644 --- a/objectivec/GPBDuration.pbobjc.m +++ b/objectivec/GPBDuration.pbobjc.m @@ -86,9 +86,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBDuration__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; diff --git a/objectivec/GPBEmpty.pbobjc.m b/objectivec/GPBEmpty.pbobjc.m index b69738c5934f..c33be8bb963a 100644 --- a/objectivec/GPBEmpty.pbobjc.m +++ b/objectivec/GPBEmpty.pbobjc.m @@ -62,9 +62,9 @@ + (GPBDescriptor *)descriptor { fieldCount:0 storageSize:sizeof(GPBEmpty__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; diff --git a/objectivec/GPBFieldMask.pbobjc.m b/objectivec/GPBFieldMask.pbobjc.m index 8de5ad42ffb0..347bcbef0e92 100644 --- a/objectivec/GPBFieldMask.pbobjc.m +++ b/objectivec/GPBFieldMask.pbobjc.m @@ -75,9 +75,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBFieldMask__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; diff --git a/objectivec/GPBSourceContext.pbobjc.m b/objectivec/GPBSourceContext.pbobjc.m index 7ae605b32a81..cea417de1be8 100644 --- a/objectivec/GPBSourceContext.pbobjc.m +++ b/objectivec/GPBSourceContext.pbobjc.m @@ -75,9 +75,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBSourceContext__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; diff --git a/objectivec/GPBStruct.pbobjc.m b/objectivec/GPBStruct.pbobjc.m index eabd761866e0..600b49574f51 100644 --- a/objectivec/GPBStruct.pbobjc.m +++ b/objectivec/GPBStruct.pbobjc.m @@ -115,9 +115,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBStruct__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -222,9 +222,9 @@ + (GPBDescriptor *)descriptor { [localDescriptor setupOneofs:oneofs count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) firstHasIndex:-1]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -285,9 +285,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBListValue__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; diff --git a/objectivec/GPBTimestamp.pbobjc.m b/objectivec/GPBTimestamp.pbobjc.m index edd73498a21f..dc6baebf2c95 100644 --- a/objectivec/GPBTimestamp.pbobjc.m +++ b/objectivec/GPBTimestamp.pbobjc.m @@ -86,9 +86,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBTimestamp__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; diff --git a/objectivec/GPBType.pbobjc.m b/objectivec/GPBType.pbobjc.m index db7a41f7e515..7b44e3995170 100644 --- a/objectivec/GPBType.pbobjc.m +++ b/objectivec/GPBType.pbobjc.m @@ -307,9 +307,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBType__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -468,9 +468,9 @@ + (GPBDescriptor *)descriptor { "\001\006\004\241!!\000"; [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; #endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -593,9 +593,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBEnum__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -673,9 +673,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBEnumValue__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -730,9 +730,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBOption__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; diff --git a/objectivec/GPBWrappers.pbobjc.m b/objectivec/GPBWrappers.pbobjc.m index 07be68bacee4..30461e3f6fe9 100644 --- a/objectivec/GPBWrappers.pbobjc.m +++ b/objectivec/GPBWrappers.pbobjc.m @@ -83,9 +83,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBDoubleValue__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -129,9 +129,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBFloatValue__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -175,9 +175,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBInt64Value__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -221,9 +221,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBUInt64Value__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -267,9 +267,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBInt32Value__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -313,9 +313,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBUInt32Value__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -358,9 +358,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBBoolValue__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -404,9 +404,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBStringValue__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; @@ -450,9 +450,9 @@ + (GPBDescriptor *)descriptor { fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) storageSize:sizeof(GPBBytesValue__storage_) flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG +#if defined(DEBUG) && DEBUG NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG +#endif // DEBUG descriptor = localDescriptor; } return descriptor; diff --git a/ruby/src/main/java/com/google/protobuf/jruby/Utils.java b/ruby/src/main/java/com/google/protobuf/jruby/Utils.java index 16136cb9b70e..78aa57f1ef7c 100644 --- a/ruby/src/main/java/com/google/protobuf/jruby/Utils.java +++ b/ruby/src/main/java/com/google/protobuf/jruby/Utils.java @@ -36,7 +36,9 @@ import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; import com.google.protobuf.Descriptors.FieldDescriptor; import java.math.BigInteger; +import org.jcodings.Encoding; import org.jcodings.specific.ASCIIEncoding; +import org.jcodings.specific.UTF8Encoding; import org.jruby.*; import org.jruby.exceptions.RaiseException; import org.jruby.ext.bigdecimal.RubyBigDecimal; @@ -141,12 +143,12 @@ public static IRubyObject checkType( throw createInvalidTypeError(context, "boolean", fieldName, value); break; case BYTES: - value = validateAndEncodeString(context, "bytes", fieldName, value, "Encoding::ASCII_8BIT"); + value = validateAndEncodeString(context, "bytes", fieldName, value, ASCIIEncoding.INSTANCE); break; case STRING: value = validateAndEncodeString( - context, "string", fieldName, symToString(value), "Encoding::UTF_8"); + context, "string", fieldName, symToString(value), UTF8Encoding.INSTANCE); break; case MESSAGE: if (value.getMetaClass() != typeClass) { @@ -383,11 +385,15 @@ private static IRubyObject validateAndEncodeString( String fieldType, String fieldName, IRubyObject value, - String encoding) { + Encoding encoding) { if (!(value instanceof RubyString)) throw createInvalidTypeError(context, fieldType, fieldName, value); - value = ((RubyString) value).encode(context, context.runtime.evalScriptlet(encoding)); + value = + ((RubyString) value) + .encode( + context, + context.runtime.getEncodingService().convertEncodingToRubyEncoding(encoding)); value.setFrozen(true); return value; }