From ecc0f5412702e7f69b4578c92a120c56bdd79287 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Tue, 6 Jun 2017 10:14:41 -0400 Subject: Properly error on a tag with field number zero. --- conformance/failure_list_objc.txt | 4 ---- 1 file changed, 4 deletions(-) (limited to 'conformance') diff --git a/conformance/failure_list_objc.txt b/conformance/failure_list_objc.txt index 6e0da6cf..e34501ea 100644 --- a/conformance/failure_list_objc.txt +++ b/conformance/failure_list_objc.txt @@ -1,6 +1,2 @@ # JSON input or output tests are skipped (in conformance_objc.m) as mobile # platforms don't support JSON wire format to avoid code bloat. -Required.ProtobufInput.IllegalZeroFieldNum_Case_0 -Required.ProtobufInput.IllegalZeroFieldNum_Case_1 -Required.ProtobufInput.IllegalZeroFieldNum_Case_2 -Required.ProtobufInput.IllegalZeroFieldNum_Case_3 -- cgit v1.2.3 From dd19b876d4c9a604946f6c4e39cc4eac5f12cfb9 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Fri, 16 Jun 2017 12:30:08 -0400 Subject: Raise the number of digits used for floats. About 1.5% of all IEEE754 single-precision numbers require nine decimal digits to represent accurately. --- conformance/conformance_test.cc | 1 + conformance/failure_list_ruby.txt | 1 + src/google/protobuf/stubs/strutil.cc | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) (limited to 'conformance') 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/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); -- cgit v1.2.3 From 13255889820dbd56f1574d9730465ca834c22bd2 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 19 Jun 2017 15:13:24 -0700 Subject: Updated upb to fix JSON conformance issues. (#3206) * Fixed a bunch of Ruby conformance errors. * Fixed some more Ruby conformance errors in JSON. --- conformance/conformance_test.cc | 2 +- conformance/failure_list_ruby.txt | 77 +--- ruby/ext/google/protobuf_c/upb.c | 945 ++++++++++++++++++-------------------- ruby/ext/google/protobuf_c/upb.h | 47 +- ruby/tests/basic.rb | 2 + 5 files changed, 493 insertions(+), 580 deletions(-) (limited to 'conformance') diff --git a/conformance/conformance_test.cc b/conformance/conformance_test.cc index a899435d..67c90397 100644 --- a/conformance/conformance_test.cc +++ b/conformance/conformance_test.cc @@ -1233,7 +1233,7 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, "Int32FieldNegativeWithLeadingZero", REQUIRED, R"({"optionalInt32": -01})"); // String values must follow the same syntax rule. Specifically leading - // or traling spaces are not allowed. + // or trailing spaces are not allowed. ExpectParseFailureForJson( "Int32FieldLeadingSpace", REQUIRED, R"({"optionalInt32": " 1"})"); diff --git a/conformance/failure_list_ruby.txt b/conformance/failure_list_ruby.txt index 4bac533e..d899ee40 100644 --- a/conformance/failure_list_ruby.txt +++ b/conformance/failure_list_ruby.txt @@ -1,21 +1,14 @@ Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput Recommended.FieldMaskPathsDontRoundTrip.JsonOutput Recommended.FieldMaskTooManyUnderscore.JsonOutput -Recommended.JsonInput.BoolFieldIntegerOne -Recommended.JsonInput.BoolFieldIntegerZero Recommended.JsonInput.DurationHas3FractionalDigits.Validator Recommended.JsonInput.DurationHas6FractionalDigits.Validator Recommended.JsonInput.DurationHas9FractionalDigits.Validator Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator Recommended.JsonInput.Int64FieldBeString.Validator -Recommended.JsonInput.OneofZeroDouble.JsonOutput -Recommended.JsonInput.OneofZeroDouble.ProtobufOutput -Recommended.JsonInput.OneofZeroFloat.JsonOutput -Recommended.JsonInput.OneofZeroFloat.ProtobufOutput -Recommended.JsonInput.OneofZeroUint32.JsonOutput -Recommended.JsonInput.OneofZeroUint32.ProtobufOutput -Recommended.JsonInput.OneofZeroUint64.JsonOutput -Recommended.JsonInput.OneofZeroUint64.ProtobufOutput +Recommended.JsonInput.MapFieldValueIsNull +Recommended.JsonInput.RepeatedFieldMessageElementIsNull +Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull Recommended.JsonInput.StringEndsWithEscapeChar Recommended.JsonInput.StringFieldSurrogateInWrongOrder Recommended.JsonInput.StringFieldUnpairedHighSurrogate @@ -48,75 +41,25 @@ Required.JsonInput.AnyWithValueForInteger.JsonOutput Required.JsonInput.AnyWithValueForInteger.ProtobufOutput Required.JsonInput.AnyWithValueForJsonObject.JsonOutput Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput -Required.JsonInput.DoubleFieldInfinity.JsonOutput -Required.JsonInput.DoubleFieldInfinity.ProtobufOutput Required.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput Required.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput -Required.JsonInput.DoubleFieldMaxPositiveValue.JsonOutput -Required.JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput -Required.JsonInput.DoubleFieldMinNegativeValue.JsonOutput -Required.JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput Required.JsonInput.DoubleFieldMinPositiveValue.JsonOutput Required.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput Required.JsonInput.DoubleFieldNan.JsonOutput -Required.JsonInput.DoubleFieldNan.ProtobufOutput -Required.JsonInput.DoubleFieldNegativeInfinity.JsonOutput -Required.JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput -Required.JsonInput.DoubleFieldQuotedValue.JsonOutput -Required.JsonInput.DoubleFieldQuotedValue.ProtobufOutput Required.JsonInput.DurationMaxValue.JsonOutput Required.JsonInput.DurationMaxValue.ProtobufOutput Required.JsonInput.DurationMinValue.JsonOutput Required.JsonInput.DurationMinValue.ProtobufOutput Required.JsonInput.DurationRepeatedValue.JsonOutput Required.JsonInput.DurationRepeatedValue.ProtobufOutput -Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput -Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput -Required.JsonInput.EnumFieldNumericValueZero.JsonOutput -Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput -Required.JsonInput.EnumFieldUnknownValue.Validator Required.JsonInput.FieldMask.JsonOutput Required.JsonInput.FieldMask.ProtobufOutput Required.JsonInput.FloatFieldInfinity.JsonOutput -Required.JsonInput.FloatFieldInfinity.ProtobufOutput Required.JsonInput.FloatFieldNan.JsonOutput -Required.JsonInput.FloatFieldNan.ProtobufOutput Required.JsonInput.FloatFieldNegativeInfinity.JsonOutput -Required.JsonInput.FloatFieldNegativeInfinity.ProtobufOutput -Required.JsonInput.FloatFieldQuotedValue.JsonOutput -Required.JsonInput.FloatFieldQuotedValue.ProtobufOutput Required.JsonInput.FloatFieldTooLarge Required.JsonInput.FloatFieldTooSmall -Required.JsonInput.Int32FieldExponentialFormat.JsonOutput -Required.JsonInput.Int32FieldExponentialFormat.ProtobufOutput -Required.JsonInput.Int32FieldFloatTrailingZero.JsonOutput -Required.JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput -Required.JsonInput.Int32FieldMaxFloatValue.JsonOutput -Required.JsonInput.Int32FieldMaxFloatValue.ProtobufOutput -Required.JsonInput.Int32FieldMinFloatValue.JsonOutput -Required.JsonInput.Int32FieldMinFloatValue.ProtobufOutput -Required.JsonInput.Int32FieldStringValue.JsonOutput -Required.JsonInput.Int32FieldStringValue.ProtobufOutput -Required.JsonInput.Int32FieldStringValueEscaped.JsonOutput -Required.JsonInput.Int32FieldStringValueEscaped.ProtobufOutput -Required.JsonInput.Int32MapEscapedKey.JsonOutput -Required.JsonInput.Int32MapEscapedKey.ProtobufOutput -Required.JsonInput.Int32MapField.JsonOutput -Required.JsonInput.Int32MapField.ProtobufOutput -Required.JsonInput.Int64FieldMaxValue.JsonOutput -Required.JsonInput.Int64FieldMaxValue.ProtobufOutput -Required.JsonInput.Int64FieldMinValue.JsonOutput -Required.JsonInput.Int64FieldMinValue.ProtobufOutput -Required.JsonInput.Int64MapEscapedKey.JsonOutput -Required.JsonInput.Int64MapEscapedKey.ProtobufOutput -Required.JsonInput.Int64MapField.JsonOutput -Required.JsonInput.Int64MapField.ProtobufOutput -Required.JsonInput.MessageField.JsonOutput -Required.JsonInput.MessageField.ProtobufOutput -Required.JsonInput.MessageMapField.JsonOutput -Required.JsonInput.MessageMapField.ProtobufOutput -Required.JsonInput.MessageRepeatedField.JsonOutput -Required.JsonInput.MessageRepeatedField.ProtobufOutput +Required.JsonInput.OneofFieldDuplicate Required.JsonInput.OptionalBoolWrapper.JsonOutput Required.JsonInput.OptionalBoolWrapper.ProtobufOutput Required.JsonInput.OptionalBytesWrapper.JsonOutput @@ -137,15 +80,12 @@ Required.JsonInput.OptionalUint64Wrapper.JsonOutput Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput -Required.JsonInput.PrimitiveRepeatedField.JsonOutput -Required.JsonInput.PrimitiveRepeatedField.ProtobufOutput Required.JsonInput.RepeatedBoolWrapper.JsonOutput Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput Required.JsonInput.RepeatedBytesWrapper.JsonOutput Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput Required.JsonInput.RepeatedDoubleWrapper.JsonOutput Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt Required.JsonInput.RepeatedFloatWrapper.JsonOutput Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput Required.JsonInput.RepeatedInt32Wrapper.JsonOutput @@ -158,7 +98,6 @@ Required.JsonInput.RepeatedUint32Wrapper.JsonOutput Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput Required.JsonInput.RepeatedUint64Wrapper.JsonOutput Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput -Required.JsonInput.StringFieldNotAString Required.JsonInput.StringFieldSurrogatePair.JsonOutput Required.JsonInput.StringFieldSurrogatePair.ProtobufOutput Required.JsonInput.Struct.JsonOutput @@ -173,14 +112,6 @@ Required.JsonInput.TimestampWithNegativeOffset.JsonOutput Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput Required.JsonInput.TimestampWithPositiveOffset.JsonOutput Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput -Required.JsonInput.Uint32FieldMaxFloatValue.JsonOutput -Required.JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput -Required.JsonInput.Uint32MapField.JsonOutput -Required.JsonInput.Uint32MapField.ProtobufOutput -Required.JsonInput.Uint64FieldMaxValue.JsonOutput -Required.JsonInput.Uint64FieldMaxValue.ProtobufOutput -Required.JsonInput.Uint64MapField.JsonOutput -Required.JsonInput.Uint64MapField.ProtobufOutput Required.JsonInput.ValueAcceptBool.JsonOutput Required.JsonInput.ValueAcceptBool.ProtobufOutput Required.JsonInput.ValueAcceptFloat.JsonOutput diff --git a/ruby/ext/google/protobuf_c/upb.c b/ruby/ext/google/protobuf_c/upb.c index e0c56f8e..90d1f0cd 100644 --- a/ruby/ext/google/protobuf_c/upb.c +++ b/ruby/ext/google/protobuf_c/upb.c @@ -377,13 +377,14 @@ bool _upb_def_validate(upb_def *const*defs, size_t n, upb_status *s) { } else if (def->type == UPB_DEF_FIELD) { upb_status_seterrmsg(s, "standalone fielddefs can not be frozen"); goto err; - } else if (def->type == UPB_DEF_ENUM) { - if (!upb_validate_enumdef(upb_dyncast_enumdef(def), s)) { - goto err; - } } else { /* Set now to detect transitive closure in the second pass. */ def->came_from_user = true; + + if (def->type == UPB_DEF_ENUM && + !upb_validate_enumdef(upb_dyncast_enumdef(def), s)) { + goto err; + } } } @@ -710,43 +711,6 @@ upb_fielddef *upb_fielddef_new(const void *o) { return f; } -static upb_fielddef *upb_fielddef_dup(const upb_fielddef *f, - const void *owner) { - const char *srcname; - upb_fielddef *newf = upb_fielddef_new(owner); - if (!newf) return NULL; - upb_fielddef_settype(newf, upb_fielddef_type(f)); - upb_fielddef_setlabel(newf, upb_fielddef_label(f)); - upb_fielddef_setnumber(newf, upb_fielddef_number(f), NULL); - upb_fielddef_setname(newf, upb_fielddef_name(f), NULL); - if (f->default_is_string && f->defaultval.bytes) { - str_t *s = f->defaultval.bytes; - upb_fielddef_setdefaultstr(newf, s->str, s->len, NULL); - } else { - newf->default_is_string = f->default_is_string; - newf->defaultval = f->defaultval; - } - - if (f->subdef_is_symbolic) { - srcname = f->sub.name; /* Might be NULL. */ - } else { - srcname = f->sub.def ? upb_def_fullname(f->sub.def) : NULL; - } - if (srcname) { - char *newname = upb_gmalloc(strlen(f->sub.def->fullname) + 2); - if (!newname) { - upb_fielddef_unref(newf, owner); - return NULL; - } - strcpy(newname, "."); - strcat(newname, f->sub.def->fullname); - upb_fielddef_setsubdefname(newf, newname, NULL); - upb_gfree(newname); - } - - return newf; -} - bool upb_fielddef_typeisset(const upb_fielddef *f) { return f->type_is_set_; } @@ -1426,44 +1390,6 @@ err2: return NULL; } -static upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner); - -static upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner) { - bool ok; - upb_msg_field_iter i; - upb_msg_oneof_iter o; - - upb_msgdef *newm = upb_msgdef_new(owner); - if (!newm) return NULL; - ok = upb_def_setfullname(upb_msgdef_upcast_mutable(newm), - upb_def_fullname(upb_msgdef_upcast(m)), - NULL); - newm->map_entry = m->map_entry; - newm->syntax = m->syntax; - UPB_ASSERT(ok); - for(upb_msg_field_begin(&i, m); - !upb_msg_field_done(&i); - upb_msg_field_next(&i)) { - upb_fielddef *f = upb_fielddef_dup(upb_msg_iter_field(&i), &f); - /* Fields in oneofs are dup'd below. */ - if (upb_fielddef_containingoneof(f)) continue; - if (!f || !upb_msgdef_addfield(newm, f, &f, NULL)) { - upb_msgdef_unref(newm, owner); - return NULL; - } - } - for(upb_msg_oneof_begin(&o, m); - !upb_msg_oneof_done(&o); - upb_msg_oneof_next(&o)) { - upb_oneofdef *f = upb_oneofdef_dup(upb_msg_iter_oneof(&o), &f); - if (!f || !upb_msgdef_addoneof(newm, f, &f, NULL)) { - upb_msgdef_unref(newm, owner); - return NULL; - } - } - return newm; -} - bool upb_msgdef_freeze(upb_msgdef *m, upb_status *status) { upb_def *d = upb_msgdef_upcast_mutable(m); return upb_def_freeze(&d, 1, status); @@ -1764,24 +1690,6 @@ err2: return NULL; } -static upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, - const void *owner) { - bool ok; - upb_oneof_iter i; - upb_oneofdef *newo = upb_oneofdef_new(owner); - if (!newo) return NULL; - ok = upb_oneofdef_setname(newo, upb_oneofdef_name(o), NULL); - UPB_ASSERT(ok); - for (upb_oneof_begin(&i, o); !upb_oneof_done(&i); upb_oneof_next(&i)) { - upb_fielddef *f = upb_fielddef_dup(upb_oneof_iter_field(&i), &f); - if (!f || !upb_oneofdef_addfield(newo, f, &f, NULL)) { - upb_oneofdef_unref(newo, owner); - return NULL; - } - } - return newo; -} - const char *upb_oneofdef_name(const upb_oneofdef *o) { return o->name; } bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s) { @@ -1950,6 +1858,8 @@ static void freefiledef(upb_refcounted *r) { upb_inttable_uninit(&f->deps); upb_gfree((void*)f->name); upb_gfree((void*)f->package); + upb_gfree((void*)f->phpprefix); + upb_gfree((void*)f->phpnamespace); upb_gfree(f); } @@ -1964,6 +1874,8 @@ upb_filedef *upb_filedef_new(const void *owner) { f->package = NULL; f->name = NULL; + f->phpprefix = NULL; + f->phpnamespace = NULL; f->syntax = UPB_SYNTAX_PROTO2; if (!upb_refcounted_init(upb_filedef_upcast_mutable(f), &upb_filedef_vtbl, @@ -1998,6 +1910,14 @@ const char *upb_filedef_package(const upb_filedef *f) { return f->package; } +const char *upb_filedef_phpprefix(const upb_filedef *f) { + return f->phpprefix; +} + +const char *upb_filedef_phpnamespace(const upb_filedef *f) { + return f->phpnamespace; +} + upb_syntax_t upb_filedef_syntax(const upb_filedef *f) { return f->syntax; } @@ -2054,6 +1974,30 @@ bool upb_filedef_setpackage(upb_filedef *f, const char *package, return true; } +bool upb_filedef_setphpprefix(upb_filedef *f, const char *phpprefix, + upb_status *s) { + phpprefix = upb_gstrdup(phpprefix); + if (!phpprefix) { + upb_upberr_setoom(s); + return false; + } + upb_gfree((void*)f->phpprefix); + f->phpprefix = phpprefix; + return true; +} + +bool upb_filedef_setphpnamespace(upb_filedef *f, const char *phpnamespace, + upb_status *s) { + phpnamespace = upb_gstrdup(phpnamespace); + if (!phpnamespace) { + upb_upberr_setoom(s); + return false; + } + upb_gfree((void*)f->phpnamespace); + f->phpnamespace = phpnamespace; + return true; +} + bool upb_filedef_setsyntax(upb_filedef *f, upb_syntax_t syntax, upb_status *s) { UPB_UNUSED(s); @@ -2240,57 +2184,14 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, fullname); goto err; } - upb_def_donateref(def, ref_donor, s); if (!upb_strtable_insert(&addtab, fullname, upb_value_ptr(def))) goto oom_err; - def->came_from_user = true; - } - } - - /* Add standalone fielddefs (ie. extensions) to the appropriate messages. - * If the appropriate message only exists in the existing symtab, duplicate - * it so we have a mutable copy we can add the fields to. */ - for (i = 0; i < n; i++) { - upb_def *def = defs[i]; - upb_fielddef *f = upb_dyncast_fielddef_mutable(def); - const char *msgname; - upb_value v; - upb_msgdef *m; - - if (!f) continue; - msgname = upb_fielddef_containingtypename(f); - /* We validated this earlier in this function. */ - UPB_ASSERT(msgname); - - /* If the extendee name is absolutely qualified, move past the initial ".". - * TODO(haberman): it is not obvious what it would mean if this was not - * absolutely qualified. */ - if (msgname[0] == '.') { - msgname++; - } - - if (upb_strtable_lookup(&addtab, msgname, &v)) { - /* Extendee is in the set of defs the user asked us to add. */ - m = upb_value_getptr(v); - } else { - /* Need to find and dup the extendee from the existing symtab. */ - const upb_msgdef *frozen_m = upb_symtab_lookupmsg(s, msgname); - if (!frozen_m) { - upb_status_seterrf(status, - "Tried to extend message %s that does not exist " - "in this SymbolTable.", - msgname); - goto err; - } - m = upb_msgdef_dup(frozen_m, s); - if (!m) goto oom_err; - if (!upb_strtable_insert(&addtab, msgname, upb_value_ptr(m))) { - upb_msgdef_unref(m, s); - goto oom_err; - } + upb_def_donateref(def, ref_donor, s); } - if (!upb_msgdef_addfield(m, f, ref_donor, status)) { + if (upb_dyncast_fielddef_mutable(def)) { + /* TODO(haberman): allow adding extensions attached to files. */ + upb_status_seterrf(status, "Can't add extensions to symtab.\n"); goto err; } } @@ -2372,15 +2273,9 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, for (i = 0; i < add_n; i++) { upb_def *def = (upb_def*)add_objs[i]; const char *name = upb_def_fullname(def); - upb_value v; bool success; - - if (upb_strtable_remove(&s->symtab, name, &v)) { - const upb_def *def = upb_value_getptr(v); - upb_def_unref(def, s); - } success = upb_strtable_insert(&s->symtab, name, upb_value_ptr(def)); - UPB_ASSERT(success == true); + UPB_ASSERT(success); } upb_gfree(add_defs); return true; @@ -3737,8 +3632,7 @@ static bool upb_visitor_visitmsg2(const upb_msg *msg, CHECK_TRUE(upb_sink_putfloat(sink, sel, upb_msgval_getfloat(val))); break; case UPB_TYPE_DOUBLE: - CHECK_TRUE( - upb_sink_putdouble(sink, sel, upb_msgval_getdouble(val))); + CHECK_TRUE(upb_sink_putdouble(sink, sel, upb_msgval_getdouble(val))); break; case UPB_TYPE_BOOL: CHECK_TRUE(upb_sink_putbool(sink, sel, upb_msgval_getbool(val))); @@ -3748,15 +3642,13 @@ static bool upb_visitor_visitmsg2(const upb_msg *msg, CHECK_TRUE(upb_sink_putint32(sink, sel, upb_msgval_getint32(val))); break; case UPB_TYPE_UINT32: - CHECK_TRUE( - upb_sink_putuint32(sink, sel, upb_msgval_getuint32(val))); + CHECK_TRUE(upb_sink_putuint32(sink, sel, upb_msgval_getuint32(val))); break; case UPB_TYPE_INT64: CHECK_TRUE(upb_sink_putint64(sink, sel, upb_msgval_getint64(val))); break; case UPB_TYPE_UINT64: - CHECK_TRUE( - upb_sink_putuint64(sink, sel, upb_msgval_getuint64(val))); + CHECK_TRUE(upb_sink_putuint64(sink, sel, upb_msgval_getuint64(val))); break; case UPB_TYPE_STRING: case UPB_TYPE_BYTES: @@ -6545,14 +6437,14 @@ size_t upb_env_bytesallocated(const upb_env *e) { static const upb_msgdef msgs[22]; -static const upb_fielddef fields[105]; +static const upb_fielddef fields[107]; static const upb_enumdef enums[5]; static const upb_tabent strentries[236]; static const upb_tabent intentries[18]; -static const upb_tabval arrays[184]; +static const upb_tabval arrays[187]; #ifdef UPB_DEBUG_REFS -static upb_inttable reftables[264]; +static upb_inttable reftables[268]; #endif static const upb_msgdef msgs[22] = { @@ -6567,20 +6459,20 @@ static const upb_msgdef msgs[22] = { UPB_MSGDEF_INIT("google.protobuf.FieldOptions", 12, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[4], &arrays[42], 11, 6), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[56]), false, UPB_SYNTAX_PROTO2, &reftables[16], &reftables[17]), UPB_MSGDEF_INIT("google.protobuf.FileDescriptorProto", 42, 6, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[53], 13, 12), UPB_STRTABLE_INIT(12, 15, UPB_CTYPE_PTR, 4, &strentries[72]), false, UPB_SYNTAX_PROTO2, &reftables[18], &reftables[19]), UPB_MSGDEF_INIT("google.protobuf.FileDescriptorSet", 6, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[66], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[88]), false, UPB_SYNTAX_PROTO2, &reftables[20], &reftables[21]), - UPB_MSGDEF_INIT("google.protobuf.FileOptions", 31, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[6], &arrays[68], 39, 15), UPB_STRTABLE_INIT(16, 31, UPB_CTYPE_PTR, 5, &strentries[92]), false, UPB_SYNTAX_PROTO2, &reftables[22], &reftables[23]), - UPB_MSGDEF_INIT("google.protobuf.MessageOptions", 10, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[8], &arrays[107], 8, 4), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[124]), false, UPB_SYNTAX_PROTO2, &reftables[24], &reftables[25]), - UPB_MSGDEF_INIT("google.protobuf.MethodDescriptorProto", 15, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[115], 7, 6), UPB_STRTABLE_INIT(6, 7, UPB_CTYPE_PTR, 3, &strentries[132]), false, UPB_SYNTAX_PROTO2, &reftables[26], &reftables[27]), - UPB_MSGDEF_INIT("google.protobuf.MethodOptions", 7, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[10], &arrays[122], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[140]), false, UPB_SYNTAX_PROTO2, &reftables[28], &reftables[29]), - UPB_MSGDEF_INIT("google.protobuf.OneofDescriptorProto", 5, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[123], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[144]), false, UPB_SYNTAX_PROTO2, &reftables[30], &reftables[31]), - UPB_MSGDEF_INIT("google.protobuf.ServiceDescriptorProto", 11, 2, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[125], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[148]), false, UPB_SYNTAX_PROTO2, &reftables[32], &reftables[33]), - UPB_MSGDEF_INIT("google.protobuf.ServiceOptions", 7, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[14], &arrays[129], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[152]), false, UPB_SYNTAX_PROTO2, &reftables[34], &reftables[35]), - UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo", 6, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[130], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[156]), false, UPB_SYNTAX_PROTO2, &reftables[36], &reftables[37]), - UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo.Location", 19, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[132], 7, 5), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[160]), false, UPB_SYNTAX_PROTO2, &reftables[38], &reftables[39]), - UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption", 18, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[139], 9, 7), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[168]), false, UPB_SYNTAX_PROTO2, &reftables[40], &reftables[41]), - UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption.NamePart", 6, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[148], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[184]), false, UPB_SYNTAX_PROTO2, &reftables[42], &reftables[43]), + UPB_MSGDEF_INIT("google.protobuf.FileOptions", 37, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[6], &arrays[68], 42, 17), UPB_STRTABLE_INIT(18, 31, UPB_CTYPE_PTR, 5, &strentries[92]), false, UPB_SYNTAX_PROTO2, &reftables[22], &reftables[23]), + UPB_MSGDEF_INIT("google.protobuf.MessageOptions", 10, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[8], &arrays[110], 8, 4), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[124]), false, UPB_SYNTAX_PROTO2, &reftables[24], &reftables[25]), + UPB_MSGDEF_INIT("google.protobuf.MethodDescriptorProto", 15, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[118], 7, 6), UPB_STRTABLE_INIT(6, 7, UPB_CTYPE_PTR, 3, &strentries[132]), false, UPB_SYNTAX_PROTO2, &reftables[26], &reftables[27]), + UPB_MSGDEF_INIT("google.protobuf.MethodOptions", 7, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[10], &arrays[125], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[140]), false, UPB_SYNTAX_PROTO2, &reftables[28], &reftables[29]), + UPB_MSGDEF_INIT("google.protobuf.OneofDescriptorProto", 5, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[126], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[144]), false, UPB_SYNTAX_PROTO2, &reftables[30], &reftables[31]), + UPB_MSGDEF_INIT("google.protobuf.ServiceDescriptorProto", 11, 2, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[128], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[148]), false, UPB_SYNTAX_PROTO2, &reftables[32], &reftables[33]), + UPB_MSGDEF_INIT("google.protobuf.ServiceOptions", 7, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[14], &arrays[132], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[152]), false, UPB_SYNTAX_PROTO2, &reftables[34], &reftables[35]), + UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo", 6, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[133], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[156]), false, UPB_SYNTAX_PROTO2, &reftables[36], &reftables[37]), + UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo.Location", 19, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[135], 7, 5), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[160]), false, UPB_SYNTAX_PROTO2, &reftables[38], &reftables[39]), + UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption", 18, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[142], 9, 7), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[168]), false, UPB_SYNTAX_PROTO2, &reftables[40], &reftables[41]), + UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption.NamePart", 6, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[151], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[184]), false, UPB_SYNTAX_PROTO2, &reftables[42], &reftables[43]), }; -static const upb_fielddef fields[105] = { +static const upb_fielddef fields[107] = { UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "aggregate_value", 8, &msgs[20], NULL, 15, 6, {0},&reftables[44], &reftables[45]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "allow_alias", 2, &msgs[4], NULL, 6, 1, {0},&reftables[46], &reftables[47]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "cc_enable_arenas", 31, &msgs[11], NULL, 23, 12, {0},&reftables[48], &reftables[49]), @@ -6590,18 +6482,18 @@ static const upb_fielddef fields[105] = { UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "ctype", 1, &msgs[8], (const upb_def*)(&enums[2]), 6, 1, {0},&reftables[56], &reftables[57]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "default_value", 7, &msgs[7], NULL, 16, 7, {0},&reftables[58], &reftables[59]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "dependency", 3, &msgs[9], NULL, 30, 8, {0},&reftables[60], &reftables[61]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[12], NULL, 8, 3, {0},&reftables[62], &reftables[63]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[8], NULL, 8, 3, {0},&reftables[64], &reftables[65]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[14], NULL, 6, 1, {0},&reftables[66], &reftables[67]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[8], NULL, 8, 3, {0},&reftables[62], &reftables[63]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[14], NULL, 6, 1, {0},&reftables[64], &reftables[65]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[12], NULL, 8, 3, {0},&reftables[66], &reftables[67]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 23, &msgs[11], NULL, 21, 10, {0},&reftables[68], &reftables[69]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[4], NULL, 7, 2, {0},&reftables[70], &reftables[71]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[17], NULL, 6, 1, {0},&reftables[72], &reftables[73]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 1, &msgs[6], NULL, 6, 1, {0},&reftables[74], &reftables[75]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 1, &msgs[6], NULL, 6, 1, {0},&reftables[70], &reftables[71]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[4], NULL, 7, 2, {0},&reftables[72], &reftables[73]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[17], NULL, 6, 1, {0},&reftables[74], &reftables[75]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_DOUBLE, 0, false, false, false, false, "double_value", 6, &msgs[20], NULL, 11, 4, {0},&reftables[76], &reftables[77]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "end", 2, &msgs[2], NULL, 3, 1, {0},&reftables[78], &reftables[79]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "end", 2, &msgs[1], NULL, 3, 1, {0},&reftables[80], &reftables[81]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 4, &msgs[0], (const upb_def*)(&msgs[3]), 18, 2, {0},&reftables[82], &reftables[83]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 5, &msgs[9], (const upb_def*)(&msgs[3]), 13, 1, {0},&reftables[84], &reftables[85]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 5, &msgs[9], (const upb_def*)(&msgs[3]), 13, 1, {0},&reftables[82], &reftables[83]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 4, &msgs[0], (const upb_def*)(&msgs[3]), 18, 2, {0},&reftables[84], &reftables[85]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "extendee", 2, &msgs[7], NULL, 7, 2, {0},&reftables[86], &reftables[87]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension", 6, &msgs[0], (const upb_def*)(&msgs[7]), 24, 4, {0},&reftables[88], &reftables[89]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension", 7, &msgs[9], (const upb_def*)(&msgs[7]), 19, 3, {0},&reftables[90], &reftables[91]), @@ -6630,77 +6522,79 @@ static const upb_fielddef fields[105] = { UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "message_set_wire_format", 1, &msgs[12], NULL, 6, 1, {0},&reftables[136], &reftables[137]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "message_type", 4, &msgs[9], (const upb_def*)(&msgs[0]), 10, 0, {0},&reftables[138], &reftables[139]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "method", 2, &msgs[16], (const upb_def*)(&msgs[13]), 6, 0, {0},&reftables[140], &reftables[141]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[3], NULL, 8, 2, {0},&reftables[142], &reftables[143]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[15], NULL, 2, 0, {0},&reftables[144], &reftables[145]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "name", 2, &msgs[20], (const upb_def*)(&msgs[21]), 5, 0, {0},&reftables[146], &reftables[147]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[0], NULL, 32, 8, {0},&reftables[148], &reftables[149]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[5], NULL, 4, 1, {0},&reftables[150], &reftables[151]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[9], NULL, 22, 6, {0},&reftables[152], &reftables[153]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[7], NULL, 4, 1, {0},&reftables[154], &reftables[155]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[13], NULL, 4, 1, {0},&reftables[156], &reftables[157]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[16], NULL, 8, 2, {0},&reftables[158], &reftables[159]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "name", 2, &msgs[20], (const upb_def*)(&msgs[21]), 5, 0, {0},&reftables[142], &reftables[143]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[5], NULL, 4, 1, {0},&reftables[144], &reftables[145]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[9], NULL, 22, 6, {0},&reftables[146], &reftables[147]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[3], NULL, 8, 2, {0},&reftables[148], &reftables[149]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[16], NULL, 8, 2, {0},&reftables[150], &reftables[151]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[15], NULL, 2, 0, {0},&reftables[152], &reftables[153]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[13], NULL, 4, 1, {0},&reftables[154], &reftables[155]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[7], NULL, 4, 1, {0},&reftables[156], &reftables[157]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[0], NULL, 32, 8, {0},&reftables[158], &reftables[159]), UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_STRING, 0, false, false, false, false, "name_part", 1, &msgs[21], NULL, 2, 0, {0},&reftables[160], &reftables[161]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT64, UPB_INTFMT_VARIABLE, false, false, false, false, "negative_int_value", 5, &msgs[20], NULL, 10, 3, {0},&reftables[162], &reftables[163]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "nested_type", 3, &msgs[0], (const upb_def*)(&msgs[0]), 15, 1, {0},&reftables[164], &reftables[165]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "no_standard_descriptor_accessor", 2, &msgs[12], NULL, 7, 2, {0},&reftables[166], &reftables[167]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 2, &msgs[5], NULL, 7, 2, {0},&reftables[168], &reftables[169]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 3, &msgs[7], NULL, 10, 3, {0},&reftables[170], &reftables[171]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 3, &msgs[7], NULL, 10, 3, {0},&reftables[168], &reftables[169]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 2, &msgs[5], NULL, 7, 2, {0},&reftables[170], &reftables[171]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "objc_class_prefix", 36, &msgs[11], NULL, 24, 13, {0},&reftables[172], &reftables[173]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "oneof_decl", 8, &msgs[0], (const upb_def*)(&msgs[15]), 28, 6, {0},&reftables[174], &reftables[175]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "oneof_index", 9, &msgs[7], NULL, 19, 8, {0},&reftables[176], &reftables[177]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "optimize_for", 9, &msgs[11], (const upb_def*)(&enums[4]), 12, 3, {0},&reftables[178], &reftables[179]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 7, &msgs[0], (const upb_def*)(&msgs[12]), 25, 5, {0},&reftables[180], &reftables[181]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[9], (const upb_def*)(&msgs[11]), 20, 4, {0},&reftables[182], &reftables[183]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 4, &msgs[13], (const upb_def*)(&msgs[14]), 3, 0, {0},&reftables[184], &reftables[185]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[7], (const upb_def*)(&msgs[8]), 3, 0, {0},&reftables[186], &reftables[187]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[7], (const upb_def*)(&msgs[8]), 3, 0, {0},&reftables[184], &reftables[185]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 4, &msgs[13], (const upb_def*)(&msgs[14]), 3, 0, {0},&reftables[186], &reftables[187]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[16], (const upb_def*)(&msgs[17]), 7, 1, {0},&reftables[188], &reftables[189]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[5], (const upb_def*)(&msgs[6]), 3, 0, {0},&reftables[190], &reftables[191]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[3], (const upb_def*)(&msgs[4]), 7, 1, {0},&reftables[192], &reftables[193]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[3], (const upb_def*)(&msgs[4]), 7, 1, {0},&reftables[190], &reftables[191]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[5], (const upb_def*)(&msgs[6]), 3, 0, {0},&reftables[192], &reftables[193]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "output_type", 3, &msgs[13], NULL, 10, 3, {0},&reftables[194], &reftables[195]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "package", 2, &msgs[9], NULL, 25, 7, {0},&reftables[196], &reftables[197]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "packed", 2, &msgs[8], NULL, 7, 2, {0},&reftables[198], &reftables[199]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "path", 1, &msgs[19], NULL, 4, 0, {0},&reftables[200], &reftables[201]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_UINT64, UPB_INTFMT_VARIABLE, false, false, false, false, "positive_int_value", 4, &msgs[20], NULL, 9, 2, {0},&reftables[202], &reftables[203]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "public_dependency", 10, &msgs[9], NULL, 35, 9, {0},&reftables[204], &reftables[205]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "py_generic_services", 18, &msgs[11], NULL, 19, 8, {0},&reftables[206], &reftables[207]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "reserved_name", 10, &msgs[0], NULL, 37, 9, {0},&reftables[208], &reftables[209]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "reserved_range", 9, &msgs[0], (const upb_def*)(&msgs[2]), 31, 7, {0},&reftables[210], &reftables[211]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "server_streaming", 6, &msgs[13], NULL, 14, 5, {0},&reftables[212], &reftables[213]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "service", 6, &msgs[9], (const upb_def*)(&msgs[16]), 16, 2, {0},&reftables[214], &reftables[215]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "source_code_info", 9, &msgs[9], (const upb_def*)(&msgs[18]), 21, 5, {0},&reftables[216], &reftables[217]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "span", 2, &msgs[19], NULL, 7, 1, {0},&reftables[218], &reftables[219]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[2], NULL, 2, 0, {0},&reftables[220], &reftables[221]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[1], NULL, 2, 0, {0},&reftables[222], &reftables[223]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BYTES, 0, false, false, false, false, "string_value", 7, &msgs[20], NULL, 12, 5, {0},&reftables[224], &reftables[225]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "syntax", 12, &msgs[9], NULL, 39, 11, {0},&reftables[226], &reftables[227]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "trailing_comments", 4, &msgs[19], NULL, 11, 3, {0},&reftables[228], &reftables[229]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "type", 5, &msgs[7], (const upb_def*)(&enums[1]), 12, 5, {0},&reftables[230], &reftables[231]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "type_name", 6, &msgs[7], NULL, 13, 6, {0},&reftables[232], &reftables[233]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[11], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[234], &reftables[235]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[12], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[236], &reftables[237]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[6], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[238], &reftables[239]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[4], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[240], &reftables[241]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[8], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[242], &reftables[243]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "php_class_prefix", 40, &msgs[11], NULL, 31, 16, {0},&reftables[202], &reftables[203]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "php_namespace", 41, &msgs[11], NULL, 34, 17, {0},&reftables[204], &reftables[205]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_UINT64, UPB_INTFMT_VARIABLE, false, false, false, false, "positive_int_value", 4, &msgs[20], NULL, 9, 2, {0},&reftables[206], &reftables[207]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "public_dependency", 10, &msgs[9], NULL, 35, 9, {0},&reftables[208], &reftables[209]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "py_generic_services", 18, &msgs[11], NULL, 19, 8, {0},&reftables[210], &reftables[211]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "reserved_name", 10, &msgs[0], NULL, 37, 9, {0},&reftables[212], &reftables[213]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "reserved_range", 9, &msgs[0], (const upb_def*)(&msgs[2]), 31, 7, {0},&reftables[214], &reftables[215]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "server_streaming", 6, &msgs[13], NULL, 14, 5, {0},&reftables[216], &reftables[217]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "service", 6, &msgs[9], (const upb_def*)(&msgs[16]), 16, 2, {0},&reftables[218], &reftables[219]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "source_code_info", 9, &msgs[9], (const upb_def*)(&msgs[18]), 21, 5, {0},&reftables[220], &reftables[221]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "span", 2, &msgs[19], NULL, 7, 1, {0},&reftables[222], &reftables[223]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[2], NULL, 2, 0, {0},&reftables[224], &reftables[225]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[1], NULL, 2, 0, {0},&reftables[226], &reftables[227]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BYTES, 0, false, false, false, false, "string_value", 7, &msgs[20], NULL, 12, 5, {0},&reftables[228], &reftables[229]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "syntax", 12, &msgs[9], NULL, 39, 11, {0},&reftables[230], &reftables[231]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "trailing_comments", 4, &msgs[19], NULL, 11, 3, {0},&reftables[232], &reftables[233]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "type", 5, &msgs[7], (const upb_def*)(&enums[1]), 12, 5, {0},&reftables[234], &reftables[235]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "type_name", 6, &msgs[7], NULL, 13, 6, {0},&reftables[236], &reftables[237]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[12], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[238], &reftables[239]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[17], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[240], &reftables[241]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[11], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[242], &reftables[243]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[14], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[244], &reftables[245]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[17], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[246], &reftables[247]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "value", 2, &msgs[3], (const upb_def*)(&msgs[5]), 6, 0, {0},&reftables[248], &reftables[249]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "weak", 10, &msgs[8], NULL, 11, 6, {0},&reftables[250], &reftables[251]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "weak_dependency", 11, &msgs[9], NULL, 38, 10, {0},&reftables[252], &reftables[253]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[8], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[246], &reftables[247]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[6], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[248], &reftables[249]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[4], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[250], &reftables[251]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "value", 2, &msgs[3], (const upb_def*)(&msgs[5]), 6, 0, {0},&reftables[252], &reftables[253]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "weak", 10, &msgs[8], NULL, 11, 6, {0},&reftables[254], &reftables[255]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "weak_dependency", 11, &msgs[9], NULL, 38, 10, {0},&reftables[256], &reftables[257]), }; static const upb_enumdef enums[5] = { - UPB_ENUMDEF_INIT("google.protobuf.FieldDescriptorProto.Label", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[188]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[151], 4, 3), 0, &reftables[254], &reftables[255]), - UPB_ENUMDEF_INIT("google.protobuf.FieldDescriptorProto.Type", UPB_STRTABLE_INIT(18, 31, UPB_CTYPE_INT32, 5, &strentries[192]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[155], 19, 18), 0, &reftables[256], &reftables[257]), - UPB_ENUMDEF_INIT("google.protobuf.FieldOptions.CType", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[224]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[174], 3, 3), 0, &reftables[258], &reftables[259]), - UPB_ENUMDEF_INIT("google.protobuf.FieldOptions.JSType", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[228]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[177], 3, 3), 0, &reftables[260], &reftables[261]), - UPB_ENUMDEF_INIT("google.protobuf.FileOptions.OptimizeMode", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[232]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[180], 4, 3), 0, &reftables[262], &reftables[263]), + UPB_ENUMDEF_INIT("google.protobuf.FieldDescriptorProto.Label", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[188]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[154], 4, 3), 0, &reftables[258], &reftables[259]), + UPB_ENUMDEF_INIT("google.protobuf.FieldDescriptorProto.Type", UPB_STRTABLE_INIT(18, 31, UPB_CTYPE_INT32, 5, &strentries[192]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[158], 19, 18), 0, &reftables[260], &reftables[261]), + UPB_ENUMDEF_INIT("google.protobuf.FieldOptions.CType", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[224]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[177], 3, 3), 0, &reftables[262], &reftables[263]), + UPB_ENUMDEF_INIT("google.protobuf.FieldOptions.JSType", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[228]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[180], 3, 3), 0, &reftables[264], &reftables[265]), + UPB_ENUMDEF_INIT("google.protobuf.FileOptions.OptimizeMode", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[232]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[183], 4, 3), 0, &reftables[266], &reftables[267]), }; static const upb_tabent strentries[236] = { {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "extension"), UPB_TABVALUE_PTR_INIT(&fields[22]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "reserved_name"), UPB_TABVALUE_PTR_INIT(&fields[82]), NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[52]), NULL}, + {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "reserved_name"), UPB_TABVALUE_PTR_INIT(&fields[84]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[57]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, @@ -6709,53 +6603,53 @@ static const upb_tabent strentries[236] = { {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "nested_type"), UPB_TABVALUE_PTR_INIT(&fields[60]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\016", "\000", "\000", "\000", "reserved_range"), UPB_TABVALUE_PTR_INIT(&fields[83]), NULL}, + {UPB_TABKEY_STR("\016", "\000", "\000", "\000", "reserved_range"), UPB_TABVALUE_PTR_INIT(&fields[85]), NULL}, {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[68]), NULL}, {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "oneof_decl"), UPB_TABVALUE_PTR_INIT(&fields[65]), NULL}, - {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[19]), &strentries[13]}, - {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[89]), NULL}, + {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[20]), &strentries[13]}, + {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[91]), NULL}, {UPB_TABKEY_STR("\003", "\000", "\000", "\000", "end"), UPB_TABVALUE_PTR_INIT(&fields[18]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[88]), NULL}, + {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[90]), NULL}, {UPB_TABKEY_STR("\003", "\000", "\000", "\000", "end"), UPB_TABVALUE_PTR_INIT(&fields[17]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "value"), UPB_TABVALUE_PTR_INIT(&fields[102]), NULL}, - {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[74]), NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[49]), &strentries[26]}, - {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[98]), NULL}, - {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[13]), NULL}, + {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "value"), UPB_TABVALUE_PTR_INIT(&fields[104]), NULL}, + {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[73]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[52]), &strentries[26]}, + {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[103]), NULL}, + {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[14]), NULL}, {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "allow_alias"), UPB_TABVALUE_PTR_INIT(&fields[1]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[62]), NULL}, + {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[63]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[73]), NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[53]), &strentries[34]}, - {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[97]), NULL}, - {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[15]), NULL}, + {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[74]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[50]), &strentries[34]}, + {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[102]), NULL}, + {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[13]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "oneof_index"), UPB_TABVALUE_PTR_INIT(&fields[66]), NULL}, {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "label"), UPB_TABVALUE_PTR_INIT(&fields[40]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[55]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[56]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[63]), &strentries[53]}, + {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[62]), &strentries[53]}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\010", "\000", "\000", "\000", "extendee"), UPB_TABVALUE_PTR_INIT(&fields[21]), NULL}, - {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "type_name"), UPB_TABVALUE_PTR_INIT(&fields[94]), NULL}, + {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "type_name"), UPB_TABVALUE_PTR_INIT(&fields[96]), NULL}, {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "json_name"), UPB_TABVALUE_PTR_INIT(&fields[38]), NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "type"), UPB_TABVALUE_PTR_INIT(&fields[93]), &strentries[50]}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "type"), UPB_TABVALUE_PTR_INIT(&fields[95]), &strentries[50]}, {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "default_value"), UPB_TABVALUE_PTR_INIT(&fields[7]), NULL}, - {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[71]), NULL}, - {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[99]), NULL}, + {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[70]), NULL}, + {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[101]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "weak"), UPB_TABVALUE_PTR_INIT(&fields[103]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "weak"), UPB_TABVALUE_PTR_INIT(&fields[105]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, @@ -6766,25 +6660,25 @@ static const upb_tabent strentries[236] = { {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "ctype"), UPB_TABVALUE_PTR_INIT(&fields[6]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "jstype"), UPB_TABVALUE_PTR_INIT(&fields[39]), NULL}, - {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[10]), NULL}, + {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[9]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "extension"), UPB_TABVALUE_PTR_INIT(&fields[23]), NULL}, - {UPB_TABKEY_STR("\017", "\000", "\000", "\000", "weak_dependency"), UPB_TABVALUE_PTR_INIT(&fields[104]), NULL}, + {UPB_TABKEY_STR("\017", "\000", "\000", "\000", "weak_dependency"), UPB_TABVALUE_PTR_INIT(&fields[106]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[54]), NULL}, - {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "service"), UPB_TABVALUE_PTR_INIT(&fields[85]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[51]), NULL}, + {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "service"), UPB_TABVALUE_PTR_INIT(&fields[87]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "source_code_info"), UPB_TABVALUE_PTR_INIT(&fields[86]), NULL}, + {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "source_code_info"), UPB_TABVALUE_PTR_INIT(&fields[88]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "syntax"), UPB_TABVALUE_PTR_INIT(&fields[91]), NULL}, + {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "syntax"), UPB_TABVALUE_PTR_INIT(&fields[93]), NULL}, {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "dependency"), UPB_TABVALUE_PTR_INIT(&fields[8]), NULL}, {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "message_type"), UPB_TABVALUE_PTR_INIT(&fields[47]), NULL}, {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "package"), UPB_TABVALUE_PTR_INIT(&fields[76]), NULL}, {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[69]), &strentries[86]}, - {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[20]), NULL}, - {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "public_dependency"), UPB_TABVALUE_PTR_INIT(&fields[80]), &strentries[85]}, + {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[19]), NULL}, + {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "public_dependency"), UPB_TABVALUE_PTR_INIT(&fields[82]), &strentries[85]}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "file"), UPB_TABVALUE_PTR_INIT(&fields[26]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, @@ -6792,7 +6686,7 @@ static const upb_tabent strentries[236] = { {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "cc_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[3]), NULL}, - {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "csharp_namespace"), UPB_TABVALUE_PTR_INIT(&fields[5]), NULL}, + {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "csharp_namespace"), UPB_TABVALUE_PTR_INIT(&fields[5]), &strentries[116]}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, @@ -6805,17 +6699,17 @@ static const upb_tabent strentries[236] = { {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "java_outer_classname"), UPB_TABVALUE_PTR_INIT(&fields[34]), NULL}, - {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[95]), NULL}, + {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "php_namespace"), UPB_TABVALUE_PTR_INIT(&fields[80]), &strentries[113]}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "java_multiple_files"), UPB_TABVALUE_PTR_INIT(&fields[33]), &strentries[117]}, - {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, + {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[99]), NULL}, {UPB_TABKEY_STR("\025", "\000", "\000", "\000", "java_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[32]), &strentries[118]}, {UPB_TABKEY_STR("\035", "\000", "\000", "\000", "java_generate_equals_and_hash"), UPB_TABVALUE_PTR_INIT(&fields[31]), NULL}, - {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, + {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "php_class_prefix"), UPB_TABVALUE_PTR_INIT(&fields[79]), NULL}, {UPB_TABKEY_STR("\037", "\000", "\000", "\000", "javanano_use_deprecated_package"), UPB_TABVALUE_PTR_INIT(&fields[37]), &strentries[123]}, - {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "py_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[81]), NULL}, + {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "py_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[83]), NULL}, {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "optimize_for"), UPB_TABVALUE_PTR_INIT(&fields[67]), NULL}, {UPB_TABKEY_STR("\026", "\000", "\000", "\000", "java_string_check_utf8"), UPB_TABVALUE_PTR_INIT(&fields[36]), NULL}, {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[12]), &strentries[119]}, @@ -6825,32 +6719,32 @@ static const upb_tabent strentries[236] = { {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[96]), NULL}, - {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[9]), NULL}, + {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[97]), NULL}, + {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[11]), NULL}, {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "map_entry"), UPB_TABVALUE_PTR_INIT(&fields[45]), NULL}, {UPB_TABKEY_STR("\037", "\000", "\000", "\000", "no_standard_descriptor_accessor"), UPB_TABVALUE_PTR_INIT(&fields[61]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "client_streaming"), UPB_TABVALUE_PTR_INIT(&fields[4]), NULL}, - {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "server_streaming"), UPB_TABVALUE_PTR_INIT(&fields[84]), NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[56]), NULL}, + {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "server_streaming"), UPB_TABVALUE_PTR_INIT(&fields[86]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[55]), NULL}, {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "input_type"), UPB_TABVALUE_PTR_INIT(&fields[29]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "output_type"), UPB_TABVALUE_PTR_INIT(&fields[75]), NULL}, - {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[70]), NULL}, + {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[71]), NULL}, {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[100]), NULL}, - {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[11]), NULL}, + {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[10]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[50]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[54]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[72]), &strentries[150]}, {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "method"), UPB_TABVALUE_PTR_INIT(&fields[48]), NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[57]), &strentries[149]}, - {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[101]), NULL}, - {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[14]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[53]), &strentries[149]}, + {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[98]), NULL}, + {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[15]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, @@ -6860,15 +6754,15 @@ static const upb_tabent strentries[236] = { {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "span"), UPB_TABVALUE_PTR_INIT(&fields[87]), &strentries[167]}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "span"), UPB_TABVALUE_PTR_INIT(&fields[89]), &strentries[167]}, {UPB_TABKEY_STR("\031", "\000", "\000", "\000", "leading_detached_comments"), UPB_TABVALUE_PTR_INIT(&fields[43]), &strentries[165]}, - {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "trailing_comments"), UPB_TABVALUE_PTR_INIT(&fields[92]), NULL}, + {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "trailing_comments"), UPB_TABVALUE_PTR_INIT(&fields[94]), NULL}, {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "leading_comments"), UPB_TABVALUE_PTR_INIT(&fields[42]), &strentries[164]}, {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "path"), UPB_TABVALUE_PTR_INIT(&fields[78]), NULL}, {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "double_value"), UPB_TABVALUE_PTR_INIT(&fields[16]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[51]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[49]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, @@ -6878,9 +6772,9 @@ static const upb_tabent strentries[236] = { {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\022", "\000", "\000", "\000", "positive_int_value"), UPB_TABVALUE_PTR_INIT(&fields[79]), NULL}, + {UPB_TABKEY_STR("\022", "\000", "\000", "\000", "positive_int_value"), UPB_TABVALUE_PTR_INIT(&fields[81]), NULL}, {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "identifier_value"), UPB_TABVALUE_PTR_INIT(&fields[28]), NULL}, - {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "string_value"), UPB_TABVALUE_PTR_INIT(&fields[90]), &strentries[182]}, + {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "string_value"), UPB_TABVALUE_PTR_INIT(&fields[92]), &strentries[182]}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "is_extension"), UPB_TABVALUE_PTR_INIT(&fields[30]), NULL}, @@ -6937,92 +6831,92 @@ static const upb_tabent strentries[236] = { static const upb_tabent intentries[18] = { {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[98]), NULL}, + {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[103]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[97]), NULL}, + {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[102]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[99]), NULL}, + {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[101]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[95]), NULL}, + {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[99]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[96]), NULL}, + {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[97]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_NUM(33), UPB_TABVALUE_PTR_INIT(&fields[11]), NULL}, + {UPB_TABKEY_NUM(33), UPB_TABVALUE_PTR_INIT(&fields[10]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[100]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_NUM(33), UPB_TABVALUE_PTR_INIT(&fields[14]), NULL}, + {UPB_TABKEY_NUM(33), UPB_TABVALUE_PTR_INIT(&fields[15]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[101]), NULL}, + {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[98]), NULL}, }; -static const upb_tabval arrays[184] = { +static const upb_tabval arrays[187] = { UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[52]), + UPB_TABVALUE_PTR_INIT(&fields[57]), UPB_TABVALUE_PTR_INIT(&fields[25]), UPB_TABVALUE_PTR_INIT(&fields[60]), - UPB_TABVALUE_PTR_INIT(&fields[19]), + UPB_TABVALUE_PTR_INIT(&fields[20]), UPB_TABVALUE_PTR_INIT(&fields[24]), UPB_TABVALUE_PTR_INIT(&fields[22]), UPB_TABVALUE_PTR_INIT(&fields[68]), UPB_TABVALUE_PTR_INIT(&fields[65]), - UPB_TABVALUE_PTR_INIT(&fields[83]), - UPB_TABVALUE_PTR_INIT(&fields[82]), + UPB_TABVALUE_PTR_INIT(&fields[85]), + UPB_TABVALUE_PTR_INIT(&fields[84]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[89]), + UPB_TABVALUE_PTR_INIT(&fields[91]), UPB_TABVALUE_PTR_INIT(&fields[18]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[88]), + UPB_TABVALUE_PTR_INIT(&fields[90]), UPB_TABVALUE_PTR_INIT(&fields[17]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[49]), - UPB_TABVALUE_PTR_INIT(&fields[102]), - UPB_TABVALUE_PTR_INIT(&fields[74]), + UPB_TABVALUE_PTR_INIT(&fields[52]), + UPB_TABVALUE_PTR_INIT(&fields[104]), + UPB_TABVALUE_PTR_INIT(&fields[73]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[1]), - UPB_TABVALUE_PTR_INIT(&fields[13]), + UPB_TABVALUE_PTR_INIT(&fields[14]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[53]), - UPB_TABVALUE_PTR_INIT(&fields[62]), - UPB_TABVALUE_PTR_INIT(&fields[73]), + UPB_TABVALUE_PTR_INIT(&fields[50]), + UPB_TABVALUE_PTR_INIT(&fields[63]), + UPB_TABVALUE_PTR_INIT(&fields[74]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[15]), + UPB_TABVALUE_PTR_INIT(&fields[13]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[55]), + UPB_TABVALUE_PTR_INIT(&fields[56]), UPB_TABVALUE_PTR_INIT(&fields[21]), - UPB_TABVALUE_PTR_INIT(&fields[63]), + UPB_TABVALUE_PTR_INIT(&fields[62]), UPB_TABVALUE_PTR_INIT(&fields[40]), - UPB_TABVALUE_PTR_INIT(&fields[93]), - UPB_TABVALUE_PTR_INIT(&fields[94]), + UPB_TABVALUE_PTR_INIT(&fields[95]), + UPB_TABVALUE_PTR_INIT(&fields[96]), UPB_TABVALUE_PTR_INIT(&fields[7]), - UPB_TABVALUE_PTR_INIT(&fields[71]), + UPB_TABVALUE_PTR_INIT(&fields[70]), UPB_TABVALUE_PTR_INIT(&fields[66]), UPB_TABVALUE_PTR_INIT(&fields[38]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[6]), UPB_TABVALUE_PTR_INIT(&fields[77]), - UPB_TABVALUE_PTR_INIT(&fields[10]), + UPB_TABVALUE_PTR_INIT(&fields[9]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[41]), UPB_TABVALUE_PTR_INIT(&fields[39]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[103]), + UPB_TABVALUE_PTR_INIT(&fields[105]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[54]), + UPB_TABVALUE_PTR_INIT(&fields[51]), UPB_TABVALUE_PTR_INIT(&fields[76]), UPB_TABVALUE_PTR_INIT(&fields[8]), UPB_TABVALUE_PTR_INIT(&fields[47]), - UPB_TABVALUE_PTR_INIT(&fields[20]), - UPB_TABVALUE_PTR_INIT(&fields[85]), + UPB_TABVALUE_PTR_INIT(&fields[19]), + UPB_TABVALUE_PTR_INIT(&fields[87]), UPB_TABVALUE_PTR_INIT(&fields[23]), UPB_TABVALUE_PTR_INIT(&fields[69]), - UPB_TABVALUE_PTR_INIT(&fields[86]), - UPB_TABVALUE_PTR_INIT(&fields[80]), - UPB_TABVALUE_PTR_INIT(&fields[104]), - UPB_TABVALUE_PTR_INIT(&fields[91]), + UPB_TABVALUE_PTR_INIT(&fields[88]), + UPB_TABVALUE_PTR_INIT(&fields[82]), + UPB_TABVALUE_PTR_INIT(&fields[106]), + UPB_TABVALUE_PTR_INIT(&fields[93]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[26]), UPB_TABVALUE_EMPTY_INIT, @@ -7043,7 +6937,7 @@ static const upb_tabval arrays[184] = { UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[3]), UPB_TABVALUE_PTR_INIT(&fields[32]), - UPB_TABVALUE_PTR_INIT(&fields[81]), + UPB_TABVALUE_PTR_INIT(&fields[83]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[31]), UPB_TABVALUE_EMPTY_INIT, @@ -7065,25 +6959,28 @@ static const upb_tabval arrays[184] = { UPB_TABVALUE_PTR_INIT(&fields[5]), UPB_TABVALUE_PTR_INIT(&fields[37]), UPB_TABVALUE_EMPTY_INIT, + UPB_TABVALUE_PTR_INIT(&fields[79]), + UPB_TABVALUE_PTR_INIT(&fields[80]), + UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[46]), UPB_TABVALUE_PTR_INIT(&fields[61]), - UPB_TABVALUE_PTR_INIT(&fields[9]), + UPB_TABVALUE_PTR_INIT(&fields[11]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[45]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[56]), + UPB_TABVALUE_PTR_INIT(&fields[55]), UPB_TABVALUE_PTR_INIT(&fields[29]), UPB_TABVALUE_PTR_INIT(&fields[75]), - UPB_TABVALUE_PTR_INIT(&fields[70]), + UPB_TABVALUE_PTR_INIT(&fields[71]), UPB_TABVALUE_PTR_INIT(&fields[4]), - UPB_TABVALUE_PTR_INIT(&fields[84]), + UPB_TABVALUE_PTR_INIT(&fields[86]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[50]), + UPB_TABVALUE_PTR_INIT(&fields[54]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[57]), + UPB_TABVALUE_PTR_INIT(&fields[53]), UPB_TABVALUE_PTR_INIT(&fields[48]), UPB_TABVALUE_PTR_INIT(&fields[72]), UPB_TABVALUE_EMPTY_INIT, @@ -7091,19 +6988,19 @@ static const upb_tabval arrays[184] = { UPB_TABVALUE_PTR_INIT(&fields[44]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[78]), - UPB_TABVALUE_PTR_INIT(&fields[87]), + UPB_TABVALUE_PTR_INIT(&fields[89]), UPB_TABVALUE_PTR_INIT(&fields[42]), - UPB_TABVALUE_PTR_INIT(&fields[92]), + UPB_TABVALUE_PTR_INIT(&fields[94]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[43]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[51]), + UPB_TABVALUE_PTR_INIT(&fields[49]), UPB_TABVALUE_PTR_INIT(&fields[28]), - UPB_TABVALUE_PTR_INIT(&fields[79]), + UPB_TABVALUE_PTR_INIT(&fields[81]), UPB_TABVALUE_PTR_INIT(&fields[59]), UPB_TABVALUE_PTR_INIT(&fields[16]), - UPB_TABVALUE_PTR_INIT(&fields[90]), + UPB_TABVALUE_PTR_INIT(&fields[92]), UPB_TABVALUE_PTR_INIT(&fields[0]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[58]), @@ -7144,7 +7041,11 @@ static const upb_tabval arrays[184] = { }; #ifdef UPB_DEBUG_REFS -static upb_inttable reftables[264] = { +static upb_inttable reftables[268] = { + UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), + UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), + UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), + UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), @@ -7686,6 +7587,37 @@ static size_t file_onpackage(void *closure, const void *hd, const char *buf, return n; } +static size_t file_onphpnamespace(void *closure, const void *hd, + const char *buf, size_t n, + const upb_bufhandle *handle) { + upb_descreader *r = closure; + char *php_namespace; + bool ok; + UPB_UNUSED(hd); + UPB_UNUSED(handle); + + php_namespace = upb_gstrndup(buf, n); + ok = upb_filedef_setphpnamespace(r->file, php_namespace, NULL); + upb_gfree(php_namespace); + UPB_ASSERT(ok); + return n; +} + +static size_t file_onphpprefix(void *closure, const void *hd, const char *buf, + size_t n, const upb_bufhandle *handle) { + upb_descreader *r = closure; + char *prefix; + bool ok; + UPB_UNUSED(hd); + UPB_UNUSED(handle); + + prefix = upb_gstrndup(buf, n); + ok = upb_filedef_setphpprefix(r->file, prefix, NULL); + upb_gfree(prefix); + UPB_ASSERT(ok); + return n; +} + static size_t file_onsyntax(void *closure, const void *hd, const char *buf, size_t n, const upb_bufhandle *handle) { upb_descreader *r = closure; @@ -8212,6 +8144,11 @@ static void reghandlers(const void *closure, upb_handlers *h) { upb_handlers_setbool(h, F(FieldOptions, packed), &field_onpacked, NULL); } else if (upbdefs_google_protobuf_MessageOptions_is(m)) { upb_handlers_setbool(h, F(MessageOptions, map_entry), &msg_onmapentry, NULL); + } else if (upbdefs_google_protobuf_FileOptions_is(m)) { + upb_handlers_setstring(h, F(FileOptions, php_class_prefix), + &file_onphpprefix, NULL); + upb_handlers_setstring(h, F(FileOptions, php_namespace), + &file_onphpnamespace, NULL); } UPB_ASSERT(upb_ok(upb_handlers_status(h))); @@ -10759,7 +10696,7 @@ static size_t encode_strbuf(void *c, const void *hd, const char *buf, T(double, double, dbl2uint64, encode_fixed64) T(float, float, flt2uint32, encode_fixed32) T(int64, int64_t, uint64_t, encode_varint) -T(int32, int32_t, uint32_t, encode_varint) +T(int32, int32_t, int64_t, encode_varint) T(fixed64, uint64_t, uint64_t, encode_fixed64) T(fixed32, uint32_t, uint32_t, encode_fixed32) T(bool, bool, bool, encode_varint) @@ -11374,57 +11311,6 @@ done: return r; } -/* Given an encoded varint v, returns an integer with a single bit set that - * indicates the end of the varint. Subtracting one from this value will - * yield a mask that leaves only bits that are part of the varint. Returns - * 0 if the varint is unterminated. */ -static uint64_t upb_get_vstopbit(uint64_t v) { - uint64_t cbits = v | 0x7f7f7f7f7f7f7f7fULL; - return ~cbits & (cbits+1); -} - -/* A branchless decoder. Credit to Pascal Massimino for the bit-twiddling. */ -upb_decoderet upb_vdecode_max8_massimino(upb_decoderet r) { - uint64_t b; - uint64_t stop_bit; - upb_decoderet my_r; - memcpy(&b, r.p, sizeof(b)); - stop_bit = upb_get_vstopbit(b); - b = (b & 0x7f7f7f7f7f7f7f7fULL) & (stop_bit - 1); - b += b & 0x007f007f007f007fULL; - b += 3 * (b & 0x0000ffff0000ffffULL); - b += 15 * (b & 0x00000000ffffffffULL); - if (stop_bit == 0) { - /* Error: unterminated varint. */ - upb_decoderet err_r = {(void*)0, 0}; - return err_r; - } - my_r = upb_decoderet_make(r.p + ((__builtin_ctzll(stop_bit) + 1) / 8), - r.val | (b << 7)); - return my_r; -} - -/* A branchless decoder. Credit to Daniel Wright for the bit-twiddling. */ -upb_decoderet upb_vdecode_max8_wright(upb_decoderet r) { - uint64_t b; - uint64_t stop_bit; - upb_decoderet my_r; - memcpy(&b, r.p, sizeof(b)); - stop_bit = upb_get_vstopbit(b); - b &= (stop_bit - 1); - b = ((b & 0x7f007f007f007f00ULL) >> 1) | (b & 0x007f007f007f007fULL); - b = ((b & 0xffff0000ffff0000ULL) >> 2) | (b & 0x0000ffff0000ffffULL); - b = ((b & 0xffffffff00000000ULL) >> 4) | (b & 0x00000000ffffffffULL); - if (stop_bit == 0) { - /* Error: unterminated varint. */ - upb_decoderet err_r = {(void*)0, 0}; - return err_r; - } - my_r = upb_decoderet_make(r.p + ((__builtin_ctzll(stop_bit) + 1) / 8), - r.val | (b << 14)); - return my_r; -} - #line 1 "upb/json/parser.rl" /* ** upb::json::Parser (upb_json_parser) @@ -11447,8 +11333,9 @@ upb_decoderet upb_vdecode_max8_wright(upb_decoderet r) { ** - handling of keys/escape-sequences/etc that span input buffers. */ -#include #include +#include +#include #include #include #include @@ -12033,103 +11920,156 @@ static void start_number(upb_json_parser *p, const char *ptr) { capture_begin(p, ptr); } -static bool parse_number(upb_json_parser *p); +static bool parse_number(upb_json_parser *p, bool is_quoted); static bool end_number(upb_json_parser *p, const char *ptr) { if (!capture_end(p, ptr)) { return false; } - return parse_number(p); + return parse_number(p, false); } -static bool parse_number(upb_json_parser *p) { - size_t len; - const char *buf; - const char *myend; +static bool parse_number_from_buffer(upb_json_parser *p, const char *buf, + const char *bufend, bool is_quoted) { + size_t len = bufend - buf; char *end; + upb_fieldtype_t type = upb_fielddef_type(p->top->f); + double val; + double dummy; - /* strtol() and friends unfortunately do not support specifying the length of - * the input string, so we need to force a copy into a NULL-terminated buffer. */ - if (!multipart_text(p, "\0", 1, false)) { + if (buf[0] == ' ') { return false; } - buf = accumulate_getptr(p, &len); - myend = buf + len - 1; /* One for NULL. */ - - /* XXX: We are using strtol to parse integers, but this is wrong as even - * integers can be represented as 1e6 (for example), which strtol can't - * handle correctly. - * - * XXX: Also, we can't handle large integers properly because strto[u]ll - * isn't in C89. - * - * XXX: Also, we don't properly check floats for overflow, since strtof - * isn't in C89. */ - switch (upb_fielddef_type(p->top->f)) { + /* For integer types, first try parsing with integer-specific routines. + * If these succeed, they will be more accurate for int64/uint64 than + * strtod(). + */ + switch (type) { case UPB_TYPE_ENUM: case UPB_TYPE_INT32: { - long val = strtol(p->accumulated, &end, 0); - if (val > INT32_MAX || val < INT32_MIN || errno == ERANGE || end != myend) - goto err; - else + long val = strtol(buf, &end, 0); + if (errno == ERANGE || end != bufend) { + break; + } else if (val > INT32_MAX || val < INT32_MIN) { + return false; + } else { upb_sink_putint32(&p->top->sink, parser_getsel(p), val); - break; - } - case UPB_TYPE_INT64: { - long long val = strtol(p->accumulated, &end, 0); - if (val > INT64_MAX || val < INT64_MIN || errno == ERANGE || end != myend) - goto err; - else - upb_sink_putint64(&p->top->sink, parser_getsel(p), val); - break; + return true; + } } case UPB_TYPE_UINT32: { - unsigned long val = strtoul(p->accumulated, &end, 0); - if (val > UINT32_MAX || errno == ERANGE || end != myend) - goto err; - else + unsigned long val = strtoul(buf, &end, 0); + if (end != bufend) { + break; + } else if (val > UINT32_MAX || errno == ERANGE) { + return false; + } else { upb_sink_putuint32(&p->top->sink, parser_getsel(p), val); - break; + return true; + } + } + /* XXX: We can't handle [u]int64 properly on 32-bit machines because + * strto[u]ll isn't in C89. */ + case UPB_TYPE_INT64: { + long val = strtol(buf, &end, 0); + if (errno == ERANGE || end != bufend) { + break; + } else { + upb_sink_putint64(&p->top->sink, parser_getsel(p), val); + return true; + } } case UPB_TYPE_UINT64: { - unsigned long long val = strtoul(p->accumulated, &end, 0); - if (val > UINT64_MAX || errno == ERANGE || end != myend) - goto err; - else + unsigned long val = strtoul(p->accumulated, &end, 0); + if (end != bufend) { + break; + } else if (errno == ERANGE) { + return false; + } else { upb_sink_putuint64(&p->top->sink, parser_getsel(p), val); - break; + return true; + } } - case UPB_TYPE_DOUBLE: { - double val = strtod(p->accumulated, &end); - if (errno == ERANGE || end != myend) - goto err; - else - upb_sink_putdouble(&p->top->sink, parser_getsel(p), val); + default: break; + } + + if (type != UPB_TYPE_DOUBLE && type != UPB_TYPE_FLOAT && is_quoted) { + /* Quoted numbers shouldn't support double forms for integer types. */ + return false; + } + + if (len == strlen("Infinity") && strcmp(buf, "Infinity") == 0) { + /* C89 does not have an INFINITY macro. */ + val = 1.0 / 0.0; + } else if (len == strlen("-Infinity") && strcmp(buf, "-Infinity") == 0) { + val = -1.0 / 0.0; + } else { + val = strtod(buf, &end); + if (errno == ERANGE || end != bufend) { + return false; } - case UPB_TYPE_FLOAT: { - float val = strtod(p->accumulated, &end); - if (errno == ERANGE || end != myend) - goto err; - else - upb_sink_putfloat(&p->top->sink, parser_getsel(p), val); - break; + } + + switch (type) { +#define CASE(capitaltype, smalltype, min, max) \ + case UPB_TYPE_ ## capitaltype: { \ + if (modf(val, &dummy) != 0 || val > max || val < min) { \ + return false; \ + } else { \ + upb_sink_put ## smalltype(&p->top->sink, parser_getsel(p), val); \ + return true; \ + } \ + break; \ } + case UPB_TYPE_ENUM: + CASE(INT32, int32, INT32_MIN, INT32_MAX); + CASE(INT64, int64, INT64_MIN, INT64_MAX); + CASE(UINT32, uint32, 0, UINT32_MAX); + CASE(UINT64, uint64, 0, UINT64_MAX); +#undef CASE + + case UPB_TYPE_DOUBLE: + upb_sink_putdouble(&p->top->sink, parser_getsel(p), val); + return true; + case UPB_TYPE_FLOAT: + if (false /*val > FLT_MAX || val < -FLT_MAX*/) { + return false; + } else { + upb_sink_putfloat(&p->top->sink, parser_getsel(p), val); + return true; + } default: - UPB_ASSERT(false); + return false; } +} - multipart_end(p); +static bool parse_number(upb_json_parser *p, bool is_quoted) { + size_t len; + const char *buf; + const char *bufend; - return true; + /* strtol() and friends unfortunately do not support specifying the length of + * the input string, so we need to force a copy into a NULL-terminated buffer. */ + if (!multipart_text(p, "\0", 1, false)) { + return false; + } -err: - upb_status_seterrf(&p->status, "error parsing number: %s", buf); - upb_env_reporterror(p->env, &p->status); - multipart_end(p); - return false; + buf = accumulate_getptr(p, &len); + bufend = buf + len - 1; /* One for NULL. */ + errno = 0; + + if (parse_number_from_buffer(p, buf, bufend, is_quoted)) { + multipart_end(p); + return true; + } else { + upb_status_seterrf(&p->status, "error parsing number: %s", buf); + upb_env_reporterror(p->env, &p->status); + multipart_end(p); + return false; + } } static bool parser_putbool(upb_json_parser *p, bool val) { @@ -12182,17 +12122,16 @@ static bool start_stringval(upb_json_parser *p) { multipart_startaccum(p); return true; } - } else if (upb_fielddef_type(p->top->f) == UPB_TYPE_ENUM) { - /* No need to push a frame -- symbolic enum names in quotes remain in the - * current parser frame. - * - * Enum string values must accumulate so we can look up the value in a table - * once it is complete. */ + } else if (upb_fielddef_type(p->top->f) != UPB_TYPE_BOOL && + upb_fielddef_type(p->top->f) != UPB_TYPE_MESSAGE) { + /* No need to push a frame -- numeric values in quotes remain in the + * current parser frame. These values must accmulate so we can convert + * them all at once at the end. */ multipart_startaccum(p); return true; } else { upb_status_seterrf(&p->status, - "String specified for non-string/non-enum field: %s", + "String specified for bool or submessage field: %s", upb_fielddef_name(p->top->f)); upb_env_reporterror(p->env, &p->status); return false; @@ -12239,6 +12178,15 @@ static bool end_stringval(upb_json_parser *p) { break; } + case UPB_TYPE_INT32: + case UPB_TYPE_INT64: + case UPB_TYPE_UINT32: + case UPB_TYPE_UINT64: + case UPB_TYPE_DOUBLE: + case UPB_TYPE_FLOAT: + ok = parse_number(p, true); + break; + default: UPB_ASSERT(false); upb_status_seterrmsg(&p->status, "Internal error in JSON decoder"); @@ -12282,7 +12230,7 @@ static bool parse_mapentry_key(upb_json_parser *p) { case UPB_TYPE_UINT32: case UPB_TYPE_UINT64: /* Invoke end_number. The accum buffer has the number's text already. */ - if (!parse_number(p)) { + if (!parse_number(p, true)) { return false; } break; @@ -12573,11 +12521,11 @@ static void end_object(upb_json_parser *p) { * final state once, when the closing '"' is seen. */ -#line 1244 "upb/json/parser.rl" +#line 1306 "upb/json/parser.rl" -#line 1156 "upb/json/parser.c" +#line 1218 "upb/json/parser.c" static const char _json_actions[] = { 0, 1, 0, 1, 2, 1, 3, 1, 5, 1, 6, 1, 7, 1, 8, 1, @@ -12726,7 +12674,7 @@ static const int json_en_value_machine = 27; static const int json_en_main = 1; -#line 1247 "upb/json/parser.rl" +#line 1309 "upb/json/parser.rl" size_t parse(void *closure, const void *hd, const char *buf, size_t size, const upb_bufhandle *handle) { @@ -12748,7 +12696,7 @@ size_t parse(void *closure, const void *hd, const char *buf, size_t size, capture_resume(parser, buf); -#line 1327 "upb/json/parser.c" +#line 1389 "upb/json/parser.c" { int _klen; unsigned int _trans; @@ -12823,118 +12771,118 @@ _match: switch ( *_acts++ ) { case 0: -#line 1159 "upb/json/parser.rl" +#line 1221 "upb/json/parser.rl" { p--; {cs = stack[--top]; goto _again;} } break; case 1: -#line 1160 "upb/json/parser.rl" +#line 1222 "upb/json/parser.rl" { p--; {stack[top++] = cs; cs = 10; goto _again;} } break; case 2: -#line 1164 "upb/json/parser.rl" +#line 1226 "upb/json/parser.rl" { start_text(parser, p); } break; case 3: -#line 1165 "upb/json/parser.rl" +#line 1227 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_text(parser, p)); } break; case 4: -#line 1171 "upb/json/parser.rl" +#line 1233 "upb/json/parser.rl" { start_hex(parser); } break; case 5: -#line 1172 "upb/json/parser.rl" +#line 1234 "upb/json/parser.rl" { hexdigit(parser, p); } break; case 6: -#line 1173 "upb/json/parser.rl" +#line 1235 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_hex(parser)); } break; case 7: -#line 1179 "upb/json/parser.rl" +#line 1241 "upb/json/parser.rl" { CHECK_RETURN_TOP(escape(parser, p)); } break; case 8: -#line 1185 "upb/json/parser.rl" +#line 1247 "upb/json/parser.rl" { p--; {cs = stack[--top]; goto _again;} } break; case 9: -#line 1188 "upb/json/parser.rl" +#line 1250 "upb/json/parser.rl" { {stack[top++] = cs; cs = 19; goto _again;} } break; case 10: -#line 1190 "upb/json/parser.rl" +#line 1252 "upb/json/parser.rl" { p--; {stack[top++] = cs; cs = 27; goto _again;} } break; case 11: -#line 1195 "upb/json/parser.rl" +#line 1257 "upb/json/parser.rl" { start_member(parser); } break; case 12: -#line 1196 "upb/json/parser.rl" +#line 1258 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_membername(parser)); } break; case 13: -#line 1199 "upb/json/parser.rl" +#line 1261 "upb/json/parser.rl" { end_member(parser); } break; case 14: -#line 1205 "upb/json/parser.rl" +#line 1267 "upb/json/parser.rl" { start_object(parser); } break; case 15: -#line 1208 "upb/json/parser.rl" +#line 1270 "upb/json/parser.rl" { end_object(parser); } break; case 16: -#line 1214 "upb/json/parser.rl" +#line 1276 "upb/json/parser.rl" { CHECK_RETURN_TOP(start_array(parser)); } break; case 17: -#line 1218 "upb/json/parser.rl" +#line 1280 "upb/json/parser.rl" { end_array(parser); } break; case 18: -#line 1223 "upb/json/parser.rl" +#line 1285 "upb/json/parser.rl" { start_number(parser, p); } break; case 19: -#line 1224 "upb/json/parser.rl" +#line 1286 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_number(parser, p)); } break; case 20: -#line 1226 "upb/json/parser.rl" +#line 1288 "upb/json/parser.rl" { CHECK_RETURN_TOP(start_stringval(parser)); } break; case 21: -#line 1227 "upb/json/parser.rl" +#line 1289 "upb/json/parser.rl" { CHECK_RETURN_TOP(end_stringval(parser)); } break; case 22: -#line 1229 "upb/json/parser.rl" +#line 1291 "upb/json/parser.rl" { CHECK_RETURN_TOP(parser_putbool(parser, true)); } break; case 23: -#line 1231 "upb/json/parser.rl" +#line 1293 "upb/json/parser.rl" { CHECK_RETURN_TOP(parser_putbool(parser, false)); } break; case 24: -#line 1233 "upb/json/parser.rl" +#line 1295 "upb/json/parser.rl" { /* null value */ } break; case 25: -#line 1235 "upb/json/parser.rl" +#line 1297 "upb/json/parser.rl" { CHECK_RETURN_TOP(start_subobject(parser)); } break; case 26: -#line 1236 "upb/json/parser.rl" +#line 1298 "upb/json/parser.rl" { end_subobject(parser); } break; case 27: -#line 1241 "upb/json/parser.rl" +#line 1303 "upb/json/parser.rl" { p--; {cs = stack[--top]; goto _again;} } break; -#line 1513 "upb/json/parser.c" +#line 1575 "upb/json/parser.c" } } @@ -12947,7 +12895,7 @@ _again: _out: {} } -#line 1268 "upb/json/parser.rl" +#line 1330 "upb/json/parser.rl" if (p != pe) { upb_status_seterrf(&parser->status, "Parse error at '%.*s'\n", pe - p, p); @@ -12988,13 +12936,13 @@ static void json_parser_reset(upb_json_parser *p) { /* Emit Ragel initialization of the parser. */ -#line 1567 "upb/json/parser.c" +#line 1629 "upb/json/parser.c" { cs = json_start; top = 0; } -#line 1308 "upb/json/parser.rl" +#line 1370 "upb/json/parser.rl" p->current_state = cs; p->parser_top = top; accumulate_clear(p); @@ -13291,10 +13239,23 @@ static void putstring(upb_json_printer *p, const char *buf, unsigned int len) { * Right now we use %.8g and %.17g for float/double, respectively, to match * proto2::util::JsonFormat's defaults. May want to change this later. */ +const char neginf[] = "\"-Infinity\""; +const char inf[] = "\"Infinity\""; + static size_t fmt_double(double val, char* buf, size_t length) { - size_t n = _upb_snprintf(buf, length, "%.17g", val); - CHKLENGTH(n > 0 && n < length); - return n; + if (val == (1.0 / 0.0)) { + CHKLENGTH(length >= strlen(inf)); + strcpy(buf, inf); + return strlen(inf); + } else if (val == (-1.0 / 0.0)) { + CHKLENGTH(length >= strlen(neginf)); + strcpy(buf, neginf); + return strlen(neginf); + } else { + size_t n = _upb_snprintf(buf, length, "%.17g", val); + CHKLENGTH(n > 0 && n < length); + return n; + } } static size_t fmt_float(float val, char* buf, size_t length) { diff --git a/ruby/ext/google/protobuf_c/upb.h b/ruby/ext/google/protobuf_c/upb.h index 6e1e6c6f..3edee0d1 100644 --- a/ruby/ext/google/protobuf_c/upb.h +++ b/ruby/ext/google/protobuf_c/upb.h @@ -2966,6 +2966,17 @@ class upb::FileDef { const char* package() const; bool set_package(const char* package, Status* s); + /* Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. */ + const char* phpprefix() const; + bool set_phpprefix(const char* phpprefix, Status* s); + + /* Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. */ + const char* phpnamespace() const; + bool set_phpnamespace(const char* phpnamespace, Status* s); + /* Syntax for the file. Defaults to proto2. */ upb_syntax_t syntax() const; void set_syntax(upb_syntax_t syntax); @@ -3019,6 +3030,8 @@ UPB_REFCOUNTED_CMETHODS(upb_filedef, upb_filedef_upcast) const char *upb_filedef_name(const upb_filedef *f); const char *upb_filedef_package(const upb_filedef *f); +const char *upb_filedef_phpprefix(const upb_filedef *f); +const char *upb_filedef_phpnamespace(const upb_filedef *f); upb_syntax_t upb_filedef_syntax(const upb_filedef *f); size_t upb_filedef_defcount(const upb_filedef *f); size_t upb_filedef_depcount(const upb_filedef *f); @@ -3028,6 +3041,10 @@ const upb_filedef *upb_filedef_dep(const upb_filedef *f, size_t i); bool upb_filedef_freeze(upb_filedef *f, upb_status *s); bool upb_filedef_setname(upb_filedef *f, const char *name, upb_status *s); bool upb_filedef_setpackage(upb_filedef *f, const char *package, upb_status *s); +bool upb_filedef_setphpprefix(upb_filedef *f, const char *phpprefix, + upb_status *s); +bool upb_filedef_setphpnamespace(upb_filedef *f, const char *phpnamespace, + upb_status *s); bool upb_filedef_setsyntax(upb_filedef *f, upb_syntax_t syntax, upb_status *s); bool upb_filedef_adddef(upb_filedef *f, upb_def *def, const void *ref_donor, @@ -3786,6 +3803,18 @@ inline const char* FileDef::package() const { inline bool FileDef::set_package(const char* package, Status* s) { return upb_filedef_setpackage(this, package, s); } +inline const char* FileDef::phpprefix() const { + return upb_filedef_phpprefix(this); +} +inline bool FileDef::set_phpprefix(const char* phpprefix, Status* s) { + return upb_filedef_setphpprefix(this, phpprefix, s); +} +inline const char* FileDef::phpnamespace() const { + return upb_filedef_phpnamespace(this); +} +inline bool FileDef::set_phpnamespace(const char* phpnamespace, Status* s) { + return upb_filedef_setphpnamespace(this, phpnamespace, s); +} inline int FileDef::def_count() const { return upb_filedef_defcount(this); } @@ -4000,6 +4029,8 @@ struct upb_filedef { const char *name; const char *package; + const char *phpprefix; + const char *phpnamespace; upb_syntax_t syntax; upb_inttable defs; @@ -7206,6 +7237,8 @@ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_string UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_use_deprecated_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 38); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_prefix(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 36); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_for(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 9); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_php_class_prefix(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 40); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_php_namespace(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 41); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 18); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 999); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 3); } @@ -8304,16 +8337,8 @@ UPB_INLINE upb_decoderet upb_decoderet_make(const char *p, uint64_t val) { return ret; } -/* Four functions for decoding a varint of at most eight bytes. They are all - * functionally identical, but are implemented in different ways and likely have - * different performance profiles. We keep them around for performance testing. - * - * Note that these functions may not read byte-by-byte, so they must not be used - * unless there are at least eight bytes left in the buffer! */ upb_decoderet upb_vdecode_max8_branch32(upb_decoderet r); upb_decoderet upb_vdecode_max8_branch64(upb_decoderet r); -upb_decoderet upb_vdecode_max8_wright(upb_decoderet r); -upb_decoderet upb_vdecode_max8_massimino(upb_decoderet r); /* Template for a function that checks the first two bytes with branching * and dispatches 2-10 bytes with a separate function. Note that this may read @@ -8338,8 +8363,6 @@ UPB_INLINE upb_decoderet upb_vdecode_check2_ ## name(const char *_p) { \ UPB_VARINT_DECODER_CHECK2(branch32, upb_vdecode_max8_branch32) UPB_VARINT_DECODER_CHECK2(branch64, upb_vdecode_max8_branch64) -UPB_VARINT_DECODER_CHECK2(wright, upb_vdecode_max8_wright) -UPB_VARINT_DECODER_CHECK2(massimino, upb_vdecode_max8_massimino) #undef UPB_VARINT_DECODER_CHECK2 /* Our canonical functions for decoding varints, based on the currently @@ -8351,10 +8374,6 @@ UPB_INLINE upb_decoderet upb_vdecode_fast(const char *p) { return upb_vdecode_check2_branch32(p); } -UPB_INLINE upb_decoderet upb_vdecode_max8_fast(upb_decoderet r) { - return upb_vdecode_max8_massimino(r); -} - /* Encoding *******************************************************************/ diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb index 02cc7a03..020effb0 100644 --- a/ruby/tests/basic.rb +++ b/ruby/tests/basic.rb @@ -1174,6 +1174,8 @@ module BasicTest json_text = TestMessage.encode_json(m) m2 = TestMessage.decode_json(json_text) + puts m.inspect + puts m2.inspect assert m == m2 # Crash case from GitHub issue 283. -- cgit v1.2.3 From ecca6ea95d56a6f70ff7b223ec3f904758acc8b1 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 30 Jun 2017 12:14:09 -0700 Subject: Add json encode/decode for php. (#3226) * Add json encode/decode for php. * Fix php conformance test on 32-bit machines. * Fix conformance test for c extension. * Fix comments --- Makefile.am | 92 ++- conformance/Makefile.am | 5 +- conformance/autoload.php | 21 + conformance/conformance_php.php | 7 +- conformance/failure_list_php.txt | 513 +----------- conformance/failure_list_php_c.txt | 32 +- conformance/failure_list_php_zts_c.txt | 225 +++++ php/ext/google/protobuf/encode_decode.c | 120 ++- php/ext/google/protobuf/message.c | 4 +- php/ext/google/protobuf/protobuf.h | 4 +- php/ext/google/protobuf/upb.c | 3 + .../Google/Protobuf/Internal/CodedInputStream.php | 373 +++++++++ .../Google/Protobuf/Internal/CodedOutputStream.php | 159 ++++ php/src/Google/Protobuf/Internal/Descriptor.php | 32 +- .../Google/Protobuf/Internal/EnumDescriptor.php | 16 + .../Protobuf/Internal/EnumValueDescriptor.php | 22 + .../Google/Protobuf/Internal/FieldDescriptor.php | 85 +- php/src/Google/Protobuf/Internal/GPBJsonWire.php | 285 +++++++ php/src/Google/Protobuf/Internal/GPBUtil.php | 70 +- php/src/Google/Protobuf/Internal/GPBWire.php | 49 +- php/src/Google/Protobuf/Internal/GPBWireType.php | 43 + php/src/Google/Protobuf/Internal/InputStream.php | 370 --------- php/src/Google/Protobuf/Internal/MapField.php | 2 +- php/src/Google/Protobuf/Internal/MapFieldIter.php | 14 +- php/src/Google/Protobuf/Internal/Message.php | 586 ++++++++++++- php/src/Google/Protobuf/Internal/OutputStream.php | 159 ---- .../Google/Protobuf/Internal/RawInputStream.php | 50 ++ php/tests/array_test.php | 625 +++----------- php/tests/compatibility_test.sh | 34 +- php/tests/encode_decode_test.php | 821 +++++++++--------- php/tests/gdb_test.sh | 2 +- php/tests/generated_class_test.php | 241 ------ php/tests/map_field_test.php | 277 +------ php/tests/memory_leak_test.php | 2 +- php/tests/php_implementation_test.php | 107 +-- php/tests/test_base.php | 3 + php/tests/undefined_test.php | 920 +++++++++++++++++++++ tests.sh | 59 +- 38 files changed, 3638 insertions(+), 2794 deletions(-) create mode 100644 conformance/autoload.php create mode 100644 conformance/failure_list_php_zts_c.txt create mode 100644 php/src/Google/Protobuf/Internal/CodedInputStream.php create mode 100644 php/src/Google/Protobuf/Internal/CodedOutputStream.php create mode 100644 php/src/Google/Protobuf/Internal/GPBJsonWire.php create mode 100644 php/src/Google/Protobuf/Internal/GPBWireType.php delete mode 100644 php/src/Google/Protobuf/Internal/InputStream.php delete mode 100644 php/src/Google/Protobuf/Internal/OutputStream.php create mode 100644 php/src/Google/Protobuf/Internal/RawInputStream.php create mode 100644 php/tests/undefined_test.php (limited to 'conformance') diff --git a/Makefile.am b/Makefile.am index 2798a7fa..f613c0f8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -597,60 +597,63 @@ php_EXTRA_DIST= \ php/ext/google/protobuf/upb.c \ php/ext/google/protobuf/protobuf.c \ php/src/phpdoc.dist.xml \ - php/src/Google/Protobuf/Internal/Descriptor.php \ + php/src/Google/Protobuf/Internal/CodedInputStream.php \ + php/src/Google/Protobuf/Internal/CodedOutputStream.php \ php/src/Google/Protobuf/Internal/DescriptorPool.php \ - php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php \ - php/src/Google/Protobuf/Internal/OneofField.php \ - php/src/Google/Protobuf/Internal/MessageOptions.php \ - php/src/Google/Protobuf/Internal/FileDescriptor.php \ - php/src/Google/Protobuf/Internal/FileDescriptorProto.php \ - php/src/Google/Protobuf/Internal/MapEntry.php \ - php/src/Google/Protobuf/Internal/FieldDescriptor.php \ - php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \ - php/src/Google/Protobuf/Internal/InputStream.php \ - php/src/Google/Protobuf/Internal/UninterpretedOption.php \ - php/src/Google/Protobuf/Internal/ServiceOptions.php \ - php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php \ - php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php \ - php/src/Google/Protobuf/Internal/OneofDescriptor.php \ - php/src/Google/Protobuf/Internal/OneofDescriptorProto.php \ - php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php \ - php/src/Google/Protobuf/Internal/OutputStream.php \ - php/src/Google/Protobuf/Internal/MessageBuilderContext.php \ - php/src/Google/Protobuf/Internal/EnumValueDescriptor.php \ - php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php \ - php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php \ - php/src/Google/Protobuf/Internal/DescriptorProto.php \ - php/src/Google/Protobuf/Internal/MapField.php \ - php/src/Google/Protobuf/Internal/MapFieldIter.php \ - php/src/Google/Protobuf/Internal/MethodDescriptorProto.php \ php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php \ php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php \ - php/src/Google/Protobuf/Internal/RepeatedField.php \ - php/src/Google/Protobuf/Internal/RepeatedFieldIter.php \ - php/src/Google/Protobuf/Internal/EnumValueOptions.php \ - php/src/Google/Protobuf/Internal/MethodOptions.php \ - php/src/Google/Protobuf/Internal/OneofOptions.php \ - php/src/Google/Protobuf/Internal/Message.php \ - php/src/Google/Protobuf/Internal/FileOptions.php \ - php/src/Google/Protobuf/Internal/FileDescriptorSet.php \ + php/src/Google/Protobuf/Internal/DescriptorProto.php \ + php/src/Google/Protobuf/Internal/Descriptor.php \ + php/src/Google/Protobuf/Internal/EnumBuilderContext.php \ php/src/Google/Protobuf/Internal/EnumDescriptor.php \ php/src/Google/Protobuf/Internal/EnumDescriptorProto.php \ - php/src/Google/Protobuf/Internal/GPBWire.php \ + php/src/Google/Protobuf/Internal/EnumOptions.php \ + php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php \ + php/src/Google/Protobuf/Internal/EnumValueDescriptor.php \ + php/src/Google/Protobuf/Internal/EnumValueOptions.php \ php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \ + php/src/Google/Protobuf/Internal/FieldDescriptor.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php \ + php/src/Google/Protobuf/Internal/FieldOptions_CType.php \ + php/src/Google/Protobuf/Internal/FieldOptions_JSType.php \ php/src/Google/Protobuf/Internal/FieldOptions.php \ + php/src/Google/Protobuf/Internal/FileDescriptorProto.php \ + php/src/Google/Protobuf/Internal/FileDescriptorSet.php \ + php/src/Google/Protobuf/Internal/FileDescriptor.php \ + php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php \ + php/src/Google/Protobuf/Internal/FileOptions.php \ php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php \ - php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php \ + php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php \ + php/src/Google/Protobuf/Internal/GPBDecodeException.php \ + php/src/Google/Protobuf/Internal/GPBJsonWire.php \ + php/src/Google/Protobuf/Internal/GPBLabel.php \ php/src/Google/Protobuf/Internal/GPBType.php \ - php/src/Google/Protobuf/Internal/FieldOptions_JSType.php \ + php/src/Google/Protobuf/Internal/GPBUtil.php \ + php/src/Google/Protobuf/Internal/GPBWireType.php \ + php/src/Google/Protobuf/Internal/GPBWire.php \ + php/src/Google/Protobuf/Internal/MapEntry.php \ + php/src/Google/Protobuf/Internal/MapFieldIter.php \ + php/src/Google/Protobuf/Internal/MapField.php \ + php/src/Google/Protobuf/Internal/MessageBuilderContext.php \ + php/src/Google/Protobuf/Internal/MessageOptions.php \ + php/src/Google/Protobuf/Internal/Message.php \ + php/src/Google/Protobuf/Internal/MethodDescriptorProto.php \ + php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php \ + php/src/Google/Protobuf/Internal/MethodOptions.php \ + php/src/Google/Protobuf/Internal/OneofDescriptorProto.php \ + php/src/Google/Protobuf/Internal/OneofDescriptor.php \ + php/src/Google/Protobuf/Internal/OneofField.php \ + php/src/Google/Protobuf/Internal/OneofOptions.php \ + php/src/Google/Protobuf/Internal/RawInputStream.php \ + php/src/Google/Protobuf/Internal/RepeatedFieldIter.php \ + php/src/Google/Protobuf/Internal/RepeatedField.php \ + php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php \ + php/src/Google/Protobuf/Internal/ServiceOptions.php \ php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php \ php/src/Google/Protobuf/Internal/SourceCodeInfo.php \ - php/src/Google/Protobuf/Internal/EnumOptions.php \ - php/src/Google/Protobuf/Internal/GPBLabel.php \ - php/src/Google/Protobuf/Internal/EnumBuilderContext.php \ - php/src/Google/Protobuf/Internal/GPBUtil.php \ - php/src/Google/Protobuf/Internal/FieldOptions_CType.php \ - php/src/Google/Protobuf/Internal/GPBDecodeException.php \ + php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php \ + php/src/Google/Protobuf/Internal/UninterpretedOption.php \ php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php \ php/tests/array_test.php \ php/tests/autoload.php \ @@ -673,10 +676,11 @@ php_EXTRA_DIST= \ php/tests/test_base.php \ php/tests/test_util.php \ php/tests/well_known_test.php \ + php/tests/undefined_test.php \ php/README.md \ - php/phpunit.xml \ php/composer.json \ php/generate_descriptor_protos.sh \ + php/phpunit.xml \ composer.json python_EXTRA_DIST= \ diff --git a/conformance/Makefile.am b/conformance/Makefile.am index 1a8b5748..fe604374 100644 --- a/conformance/Makefile.am +++ b/conformance/Makefile.am @@ -305,7 +305,7 @@ conformance-csharp: $(other_language_protoc_outputs) conformance-php: @echo "Writing shortcut script conformance-php..." @echo '#! /bin/sh' > conformance-php - @echo 'php ./conformance_php.php' >> conformance-php + @echo 'php -d auto_prepend_file=autoload.php ./conformance_php.php' >> conformance-php @chmod +x conformance-php conformance-php-c: @@ -336,6 +336,9 @@ test_php: protoc_middleman conformance-test-runner conformance-php $(other_langu test_php_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs) ./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c.txt ./conformance-php-c +test_php_zts_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs) + ./conformance-test-runner --enforce_recommended --failure_list failure_list_php_zts_c.txt ./conformance-php-c + # These depend on library paths being properly set up. The easiest way to # run them is to just use "tox" from the python dir. test_python: protoc_middleman conformance-test-runner diff --git a/conformance/autoload.php b/conformance/autoload.php new file mode 100644 index 00000000..2cee31c4 --- /dev/null +++ b/conformance/autoload.php @@ -0,0 +1,21 @@ +getPayload() == "json_payload") { try { - $test_message->jsonDecode($request->getJsonPayload()); + $test_message->mergeFromJsonString($request->getJsonPayload()); } catch (Exception $e) { $response->setParseError($e->getMessage()); return $response; @@ -67,7 +67,7 @@ function doTest($request) } elseif ($request->getRequestedOutputFormat() == WireFormat::PROTOBUF) { $response->setProtobufPayload($test_message->serializeToString()); } elseif ($request->getRequestedOutputFormat() == WireFormat::JSON) { - $response->setJsonPayload($test_message->jsonEncode()); + $response->setJsonPayload($test_message->serializeToJsonString()); } return $response; @@ -79,7 +79,8 @@ function doTestIO() if (strlen($length_bytes) == 0) { return false; # EOF } elseif (strlen($length_bytes) != 4) { - trigger_error("I/O error", E_USER_ERROR); + fwrite(STDERR, "I/O error\n"); + return false; } $length = unpack("V", $length_bytes)[1]; diff --git a/conformance/failure_list_php.txt b/conformance/failure_list_php.txt index 6dd93918..2bf9bb12 100644 --- a/conformance/failure_list_php.txt +++ b/conformance/failure_list_php.txt @@ -1,117 +1,17 @@ Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput Recommended.FieldMaskPathsDontRoundTrip.JsonOutput Recommended.FieldMaskTooManyUnderscore.JsonOutput -Recommended.JsonInput.BoolFieldAllCapitalFalse -Recommended.JsonInput.BoolFieldAllCapitalTrue -Recommended.JsonInput.BoolFieldCamelCaseFalse -Recommended.JsonInput.BoolFieldCamelCaseTrue -Recommended.JsonInput.BoolFieldDoubleQuotedFalse -Recommended.JsonInput.BoolFieldDoubleQuotedTrue -Recommended.JsonInput.BoolFieldIntegerOne -Recommended.JsonInput.BoolFieldIntegerZero -Recommended.JsonInput.BoolMapFieldKeyNotQuoted -Recommended.JsonInput.DoubleFieldInfinityNotQuoted -Recommended.JsonInput.DoubleFieldNanNotQuoted -Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted Recommended.JsonInput.DurationHas3FractionalDigits.Validator Recommended.JsonInput.DurationHas6FractionalDigits.Validator Recommended.JsonInput.DurationHas9FractionalDigits.Validator Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator -Recommended.JsonInput.FieldMaskInvalidCharacter -Recommended.JsonInput.FieldNameDuplicate -Recommended.JsonInput.FieldNameDuplicateDifferentCasing1 -Recommended.JsonInput.FieldNameDuplicateDifferentCasing2 -Recommended.JsonInput.FieldNameNotQuoted -Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator -Recommended.JsonInput.FloatFieldInfinityNotQuoted -Recommended.JsonInput.FloatFieldNanNotQuoted -Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted -Recommended.JsonInput.Int32MapFieldKeyNotQuoted -Recommended.JsonInput.Int64FieldBeString.Validator -Recommended.JsonInput.Int64MapFieldKeyNotQuoted -Recommended.JsonInput.JsonWithComments -Recommended.JsonInput.MapFieldKeyIsNull -Recommended.JsonInput.MapFieldValueIsNull -Recommended.JsonInput.MissingCommaMultiline -Recommended.JsonInput.MissingCommaOneLine -Recommended.JsonInput.MultilineNoSpaces.JsonOutput -Recommended.JsonInput.MultilineNoSpaces.ProtobufOutput -Recommended.JsonInput.MultilineWithSpaces.JsonOutput -Recommended.JsonInput.MultilineWithSpaces.ProtobufOutput -Recommended.JsonInput.OneLineNoSpaces.JsonOutput -Recommended.JsonInput.OneLineNoSpaces.ProtobufOutput -Recommended.JsonInput.OneLineWithSpaces.JsonOutput -Recommended.JsonInput.OneLineWithSpaces.ProtobufOutput -Recommended.JsonInput.OneofZeroBool.JsonOutput -Recommended.JsonInput.OneofZeroBool.ProtobufOutput -Recommended.JsonInput.OneofZeroBytes.JsonOutput -Recommended.JsonInput.OneofZeroBytes.ProtobufOutput -Recommended.JsonInput.OneofZeroDouble.JsonOutput -Recommended.JsonInput.OneofZeroDouble.ProtobufOutput -Recommended.JsonInput.OneofZeroEnum.JsonOutput -Recommended.JsonInput.OneofZeroEnum.ProtobufOutput -Recommended.JsonInput.OneofZeroFloat.JsonOutput -Recommended.JsonInput.OneofZeroFloat.ProtobufOutput -Recommended.JsonInput.OneofZeroMessage.JsonOutput -Recommended.JsonInput.OneofZeroMessage.ProtobufOutput -Recommended.JsonInput.OneofZeroString.JsonOutput -Recommended.JsonInput.OneofZeroString.ProtobufOutput -Recommended.JsonInput.OneofZeroUint32.JsonOutput -Recommended.JsonInput.OneofZeroUint32.ProtobufOutput -Recommended.JsonInput.OneofZeroUint64.JsonOutput -Recommended.JsonInput.OneofZeroUint64.ProtobufOutput -Recommended.JsonInput.RepeatedFieldMessageElementIsNull -Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull -Recommended.JsonInput.RepeatedFieldTrailingComma -Recommended.JsonInput.RepeatedFieldTrailingCommaWithNewlines -Recommended.JsonInput.RepeatedFieldTrailingCommaWithSpace -Recommended.JsonInput.RepeatedFieldTrailingCommaWithSpaceCommaSpace -Recommended.JsonInput.StringEndsWithEscapeChar -Recommended.JsonInput.StringFieldInvalidEscape -Recommended.JsonInput.StringFieldSingleQuoteBoth -Recommended.JsonInput.StringFieldSingleQuoteKey -Recommended.JsonInput.StringFieldSingleQuoteValue -Recommended.JsonInput.StringFieldSurrogateInWrongOrder -Recommended.JsonInput.StringFieldUnpairedHighSurrogate -Recommended.JsonInput.StringFieldUnpairedLowSurrogate -Recommended.JsonInput.StringFieldUnterminatedEscape -Recommended.JsonInput.StringFieldUppercaseEscapeLetter Recommended.JsonInput.TimestampHas3FractionalDigits.Validator Recommended.JsonInput.TimestampHas6FractionalDigits.Validator Recommended.JsonInput.TimestampHas9FractionalDigits.Validator Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator Recommended.JsonInput.TimestampZeroNormalized.Validator -Recommended.JsonInput.TrailingCommaInAnObject -Recommended.JsonInput.TrailingCommaInAnObjectWithNewlines -Recommended.JsonInput.TrailingCommaInAnObjectWithSpace -Recommended.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace -Recommended.JsonInput.Uint32MapFieldKeyNotQuoted -Recommended.JsonInput.Uint64FieldBeString.Validator -Recommended.JsonInput.Uint64MapFieldKeyNotQuoted -Recommended.ProtobufInput.OneofZeroBool.JsonOutput -Recommended.ProtobufInput.OneofZeroBool.ProtobufOutput -Recommended.ProtobufInput.OneofZeroBytes.JsonOutput -Recommended.ProtobufInput.OneofZeroBytes.ProtobufOutput -Recommended.ProtobufInput.OneofZeroDouble.JsonOutput -Recommended.ProtobufInput.OneofZeroDouble.ProtobufOutput -Recommended.ProtobufInput.OneofZeroEnum.JsonOutput -Recommended.ProtobufInput.OneofZeroEnum.ProtobufOutput -Recommended.ProtobufInput.OneofZeroFloat.JsonOutput -Recommended.ProtobufInput.OneofZeroFloat.ProtobufOutput -Recommended.ProtobufInput.OneofZeroMessage.JsonOutput -Recommended.ProtobufInput.OneofZeroMessage.ProtobufOutput -Recommended.ProtobufInput.OneofZeroString.JsonOutput -Recommended.ProtobufInput.OneofZeroString.ProtobufOutput -Recommended.ProtobufInput.OneofZeroUint32.JsonOutput -Recommended.ProtobufInput.OneofZeroUint32.ProtobufOutput -Recommended.ProtobufInput.OneofZeroUint64.JsonOutput -Recommended.ProtobufInput.OneofZeroUint64.ProtobufOutput Required.DurationProtoInputTooLarge.JsonOutput Required.DurationProtoInputTooSmall.JsonOutput -Required.JsonInput.AllFieldAcceptNull.JsonOutput -Required.JsonInput.AllFieldAcceptNull.ProtobufOutput Required.JsonInput.Any.JsonOutput Required.JsonInput.Any.ProtobufOutput Required.JsonInput.AnyNested.JsonOutput @@ -132,141 +32,14 @@ Required.JsonInput.AnyWithValueForInteger.JsonOutput Required.JsonInput.AnyWithValueForInteger.ProtobufOutput Required.JsonInput.AnyWithValueForJsonObject.JsonOutput Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput -Required.JsonInput.BoolFieldFalse.JsonOutput -Required.JsonInput.BoolFieldFalse.ProtobufOutput -Required.JsonInput.BoolFieldTrue.JsonOutput -Required.JsonInput.BoolFieldTrue.ProtobufOutput -Required.JsonInput.BoolMapEscapedKey.JsonOutput -Required.JsonInput.BoolMapEscapedKey.ProtobufOutput -Required.JsonInput.BoolMapField.JsonOutput -Required.JsonInput.BoolMapField.ProtobufOutput -Required.JsonInput.BytesField.JsonOutput -Required.JsonInput.BytesField.ProtobufOutput -Required.JsonInput.BytesFieldInvalidBase64Characters -Required.JsonInput.BytesRepeatedField.JsonOutput -Required.JsonInput.BytesRepeatedField.ProtobufOutput -Required.JsonInput.DoubleFieldInfinity.JsonOutput -Required.JsonInput.DoubleFieldInfinity.ProtobufOutput -Required.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput -Required.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput -Required.JsonInput.DoubleFieldMaxPositiveValue.JsonOutput -Required.JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput -Required.JsonInput.DoubleFieldMinNegativeValue.JsonOutput -Required.JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput -Required.JsonInput.DoubleFieldMinPositiveValue.JsonOutput -Required.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput -Required.JsonInput.DoubleFieldNan.JsonOutput -Required.JsonInput.DoubleFieldNan.ProtobufOutput -Required.JsonInput.DoubleFieldNegativeInfinity.JsonOutput -Required.JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput -Required.JsonInput.DoubleFieldQuotedValue.JsonOutput -Required.JsonInput.DoubleFieldQuotedValue.ProtobufOutput -Required.JsonInput.DoubleFieldTooLarge -Required.JsonInput.DoubleFieldTooSmall -Required.JsonInput.DurationJsonInputTooLarge -Required.JsonInput.DurationJsonInputTooSmall Required.JsonInput.DurationMaxValue.JsonOutput Required.JsonInput.DurationMaxValue.ProtobufOutput Required.JsonInput.DurationMinValue.JsonOutput Required.JsonInput.DurationMinValue.ProtobufOutput -Required.JsonInput.DurationMissingS Required.JsonInput.DurationRepeatedValue.JsonOutput Required.JsonInput.DurationRepeatedValue.ProtobufOutput -Required.JsonInput.EnumField.JsonOutput -Required.JsonInput.EnumField.ProtobufOutput -Required.JsonInput.EnumFieldNotQuoted -Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput -Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput -Required.JsonInput.EnumFieldNumericValueZero.JsonOutput -Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput -Required.JsonInput.EnumFieldUnknownValue.Validator -Required.JsonInput.EnumRepeatedField.JsonOutput -Required.JsonInput.EnumRepeatedField.ProtobufOutput Required.JsonInput.FieldMask.JsonOutput Required.JsonInput.FieldMask.ProtobufOutput -Required.JsonInput.FieldNameEscaped.JsonOutput -Required.JsonInput.FieldNameEscaped.ProtobufOutput -Required.JsonInput.FieldNameInLowerCamelCase.Validator -Required.JsonInput.FieldNameInSnakeCase.JsonOutput -Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput -Required.JsonInput.FieldNameWithMixedCases.JsonOutput -Required.JsonInput.FieldNameWithMixedCases.ProtobufOutput -Required.JsonInput.FieldNameWithMixedCases.Validator -Required.JsonInput.FieldNameWithNumbers.JsonOutput -Required.JsonInput.FieldNameWithNumbers.ProtobufOutput -Required.JsonInput.FieldNameWithNumbers.Validator -Required.JsonInput.FloatFieldInfinity.JsonOutput -Required.JsonInput.FloatFieldInfinity.ProtobufOutput -Required.JsonInput.FloatFieldMaxNegativeValue.JsonOutput -Required.JsonInput.FloatFieldMaxNegativeValue.ProtobufOutput -Required.JsonInput.FloatFieldMaxPositiveValue.JsonOutput -Required.JsonInput.FloatFieldMaxPositiveValue.ProtobufOutput -Required.JsonInput.FloatFieldMinNegativeValue.JsonOutput -Required.JsonInput.FloatFieldMinNegativeValue.ProtobufOutput -Required.JsonInput.FloatFieldMinPositiveValue.JsonOutput -Required.JsonInput.FloatFieldMinPositiveValue.ProtobufOutput -Required.JsonInput.FloatFieldNan.JsonOutput -Required.JsonInput.FloatFieldNan.ProtobufOutput -Required.JsonInput.FloatFieldNegativeInfinity.JsonOutput -Required.JsonInput.FloatFieldNegativeInfinity.ProtobufOutput -Required.JsonInput.FloatFieldQuotedValue.JsonOutput -Required.JsonInput.FloatFieldQuotedValue.ProtobufOutput -Required.JsonInput.FloatFieldTooLarge -Required.JsonInput.FloatFieldTooSmall -Required.JsonInput.HelloWorld.JsonOutput -Required.JsonInput.HelloWorld.ProtobufOutput -Required.JsonInput.Int32FieldExponentialFormat.JsonOutput -Required.JsonInput.Int32FieldExponentialFormat.ProtobufOutput -Required.JsonInput.Int32FieldFloatTrailingZero.JsonOutput -Required.JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput -Required.JsonInput.Int32FieldLeadingSpace -Required.JsonInput.Int32FieldLeadingZero -Required.JsonInput.Int32FieldMaxFloatValue.JsonOutput -Required.JsonInput.Int32FieldMaxFloatValue.ProtobufOutput -Required.JsonInput.Int32FieldMaxValue.JsonOutput -Required.JsonInput.Int32FieldMaxValue.ProtobufOutput -Required.JsonInput.Int32FieldMinFloatValue.JsonOutput -Required.JsonInput.Int32FieldMinFloatValue.ProtobufOutput -Required.JsonInput.Int32FieldMinValue.JsonOutput -Required.JsonInput.Int32FieldMinValue.ProtobufOutput -Required.JsonInput.Int32FieldNegativeWithLeadingZero -Required.JsonInput.Int32FieldNotInteger -Required.JsonInput.Int32FieldNotNumber -Required.JsonInput.Int32FieldPlusSign -Required.JsonInput.Int32FieldStringValue.JsonOutput -Required.JsonInput.Int32FieldStringValue.ProtobufOutput -Required.JsonInput.Int32FieldStringValueEscaped.JsonOutput -Required.JsonInput.Int32FieldStringValueEscaped.ProtobufOutput -Required.JsonInput.Int32FieldTooLarge -Required.JsonInput.Int32FieldTooSmall -Required.JsonInput.Int32FieldTrailingSpace -Required.JsonInput.Int32MapEscapedKey.JsonOutput -Required.JsonInput.Int32MapEscapedKey.ProtobufOutput -Required.JsonInput.Int32MapField.JsonOutput -Required.JsonInput.Int32MapField.ProtobufOutput -Required.JsonInput.Int64FieldMaxValue.JsonOutput -Required.JsonInput.Int64FieldMaxValue.ProtobufOutput -Required.JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput -Required.JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput -Required.JsonInput.Int64FieldMinValue.JsonOutput -Required.JsonInput.Int64FieldMinValue.ProtobufOutput -Required.JsonInput.Int64FieldMinValueNotQuoted.JsonOutput -Required.JsonInput.Int64FieldMinValueNotQuoted.ProtobufOutput -Required.JsonInput.Int64FieldNotInteger -Required.JsonInput.Int64FieldNotNumber -Required.JsonInput.Int64FieldTooLarge -Required.JsonInput.Int64FieldTooSmall -Required.JsonInput.Int64MapEscapedKey.JsonOutput -Required.JsonInput.Int64MapEscapedKey.ProtobufOutput -Required.JsonInput.Int64MapField.JsonOutput -Required.JsonInput.Int64MapField.ProtobufOutput -Required.JsonInput.MessageField.JsonOutput -Required.JsonInput.MessageField.ProtobufOutput -Required.JsonInput.MessageMapField.JsonOutput -Required.JsonInput.MessageMapField.ProtobufOutput -Required.JsonInput.MessageRepeatedField.JsonOutput -Required.JsonInput.MessageRepeatedField.ProtobufOutput -Required.JsonInput.OneofFieldDuplicate Required.JsonInput.OptionalBoolWrapper.JsonOutput Required.JsonInput.OptionalBoolWrapper.ProtobufOutput Required.JsonInput.OptionalBytesWrapper.JsonOutput @@ -287,25 +60,12 @@ Required.JsonInput.OptionalUint64Wrapper.JsonOutput Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput -Required.JsonInput.OriginalProtoFieldName.JsonOutput -Required.JsonInput.OriginalProtoFieldName.ProtobufOutput -Required.JsonInput.PrimitiveRepeatedField.JsonOutput -Required.JsonInput.PrimitiveRepeatedField.ProtobufOutput Required.JsonInput.RepeatedBoolWrapper.JsonOutput Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput Required.JsonInput.RepeatedBytesWrapper.JsonOutput Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput Required.JsonInput.RepeatedDoubleWrapper.JsonOutput Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotMessage -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotString -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotBool -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotInt -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotString -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotMessage Required.JsonInput.RepeatedFloatWrapper.JsonOutput Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput Required.JsonInput.RepeatedInt32Wrapper.JsonOutput @@ -318,29 +78,8 @@ Required.JsonInput.RepeatedUint32Wrapper.JsonOutput Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput Required.JsonInput.RepeatedUint64Wrapper.JsonOutput Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput -Required.JsonInput.StringField.JsonOutput -Required.JsonInput.StringField.ProtobufOutput -Required.JsonInput.StringFieldEscape.JsonOutput -Required.JsonInput.StringFieldEscape.ProtobufOutput -Required.JsonInput.StringFieldNotAString -Required.JsonInput.StringFieldSurrogatePair.JsonOutput -Required.JsonInput.StringFieldSurrogatePair.ProtobufOutput -Required.JsonInput.StringFieldUnicode.JsonOutput -Required.JsonInput.StringFieldUnicode.ProtobufOutput -Required.JsonInput.StringFieldUnicodeEscape.JsonOutput -Required.JsonInput.StringFieldUnicodeEscape.ProtobufOutput -Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput -Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.ProtobufOutput -Required.JsonInput.StringRepeatedField.JsonOutput -Required.JsonInput.StringRepeatedField.ProtobufOutput Required.JsonInput.Struct.JsonOutput Required.JsonInput.Struct.ProtobufOutput -Required.JsonInput.TimestampJsonInputLowercaseT -Required.JsonInput.TimestampJsonInputLowercaseZ -Required.JsonInput.TimestampJsonInputMissingT -Required.JsonInput.TimestampJsonInputMissingZ -Required.JsonInput.TimestampJsonInputTooLarge -Required.JsonInput.TimestampJsonInputTooSmall Required.JsonInput.TimestampMaxValue.JsonOutput Required.JsonInput.TimestampMaxValue.ProtobufOutput Required.JsonInput.TimestampMinValue.JsonOutput @@ -351,24 +90,6 @@ Required.JsonInput.TimestampWithNegativeOffset.JsonOutput Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput Required.JsonInput.TimestampWithPositiveOffset.JsonOutput Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput -Required.JsonInput.Uint32FieldMaxFloatValue.JsonOutput -Required.JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput -Required.JsonInput.Uint32FieldMaxValue.JsonOutput -Required.JsonInput.Uint32FieldMaxValue.ProtobufOutput -Required.JsonInput.Uint32FieldNotInteger -Required.JsonInput.Uint32FieldNotNumber -Required.JsonInput.Uint32FieldTooLarge -Required.JsonInput.Uint32MapField.JsonOutput -Required.JsonInput.Uint32MapField.ProtobufOutput -Required.JsonInput.Uint64FieldMaxValue.JsonOutput -Required.JsonInput.Uint64FieldMaxValue.ProtobufOutput -Required.JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput -Required.JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput -Required.JsonInput.Uint64FieldNotInteger -Required.JsonInput.Uint64FieldNotNumber -Required.JsonInput.Uint64FieldTooLarge -Required.JsonInput.Uint64MapField.JsonOutput -Required.JsonInput.Uint64MapField.ProtobufOutput Required.JsonInput.ValueAcceptBool.JsonOutput Required.JsonInput.ValueAcceptBool.ProtobufOutput Required.JsonInput.ValueAcceptFloat.JsonOutput @@ -383,229 +104,15 @@ Required.JsonInput.ValueAcceptObject.JsonOutput Required.JsonInput.ValueAcceptObject.ProtobufOutput Required.JsonInput.ValueAcceptString.JsonOutput Required.JsonInput.ValueAcceptString.ProtobufOutput -Required.JsonInput.WrapperTypesWithNullValue.JsonOutput -Required.JsonInput.WrapperTypesWithNullValue.ProtobufOutput -Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput -Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput -Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput -Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.BOOL -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.BYTES -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.DOUBLE -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.ENUM -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FIXED32 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FIXED64 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FLOAT -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.INT32 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.INT64 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.MESSAGE -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SFIXED32 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SFIXED64 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SINT32 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SINT64 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.STRING -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.UINT32 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.UINT64 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.BOOL -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.BYTES -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.DOUBLE -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.ENUM -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FIXED32 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FIXED64 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FLOAT -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.INT32 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.INT64 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SFIXED32 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SFIXED64 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SINT32 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SINT64 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.STRING -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.UINT32 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.UINT64 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.BOOL -Required.ProtobufInput.PrematureEofBeforeUnknownValue.BYTES -Required.ProtobufInput.PrematureEofBeforeUnknownValue.DOUBLE -Required.ProtobufInput.PrematureEofBeforeUnknownValue.ENUM -Required.ProtobufInput.PrematureEofBeforeUnknownValue.FIXED32 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.FIXED64 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.FLOAT -Required.ProtobufInput.PrematureEofBeforeUnknownValue.INT32 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.INT64 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.MESSAGE -Required.ProtobufInput.PrematureEofBeforeUnknownValue.SFIXED32 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.SFIXED64 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.SINT32 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.SINT64 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.STRING -Required.ProtobufInput.PrematureEofBeforeUnknownValue.UINT32 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.UINT64 -Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.BYTES -Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE -Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.STRING -Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.BYTES -Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE -Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.STRING -Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.BYTES -Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.MESSAGE -Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.STRING -Required.ProtobufInput.PrematureEofInPackedField.BOOL -Required.ProtobufInput.PrematureEofInPackedField.DOUBLE -Required.ProtobufInput.PrematureEofInPackedField.ENUM -Required.ProtobufInput.PrematureEofInPackedField.FIXED32 -Required.ProtobufInput.PrematureEofInPackedField.FIXED64 -Required.ProtobufInput.PrematureEofInPackedField.FLOAT -Required.ProtobufInput.PrematureEofInPackedField.INT32 -Required.ProtobufInput.PrematureEofInPackedField.INT64 -Required.ProtobufInput.PrematureEofInPackedField.SFIXED32 -Required.ProtobufInput.PrematureEofInPackedField.SFIXED64 -Required.ProtobufInput.PrematureEofInPackedField.SINT32 -Required.ProtobufInput.PrematureEofInPackedField.SINT64 -Required.ProtobufInput.PrematureEofInPackedField.UINT32 -Required.ProtobufInput.PrematureEofInPackedField.UINT64 -Required.ProtobufInput.PrematureEofInPackedFieldValue.BOOL -Required.ProtobufInput.PrematureEofInPackedFieldValue.DOUBLE -Required.ProtobufInput.PrematureEofInPackedFieldValue.ENUM -Required.ProtobufInput.PrematureEofInPackedFieldValue.FIXED32 -Required.ProtobufInput.PrematureEofInPackedFieldValue.FIXED64 -Required.ProtobufInput.PrematureEofInPackedFieldValue.FLOAT -Required.ProtobufInput.PrematureEofInPackedFieldValue.INT32 -Required.ProtobufInput.PrematureEofInPackedFieldValue.INT64 -Required.ProtobufInput.PrematureEofInPackedFieldValue.SFIXED32 -Required.ProtobufInput.PrematureEofInPackedFieldValue.SFIXED64 -Required.ProtobufInput.PrematureEofInPackedFieldValue.SINT32 -Required.ProtobufInput.PrematureEofInPackedFieldValue.SINT64 -Required.ProtobufInput.PrematureEofInPackedFieldValue.UINT32 -Required.ProtobufInput.PrematureEofInPackedFieldValue.UINT64 -Required.ProtobufInput.PrematureEofInSubmessageValue.MESSAGE -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.BOOL -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.BYTES -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.DOUBLE -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.ENUM -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FIXED32 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FIXED64 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FLOAT -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.INT32 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.INT64 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.MESSAGE -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SFIXED32 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SFIXED64 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SINT32 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SINT64 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.STRING -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.UINT32 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.UINT64 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.BOOL -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.BYTES -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.DOUBLE -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.ENUM -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FIXED32 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FIXED64 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FLOAT -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.INT32 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.INT64 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.MESSAGE -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SFIXED32 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SFIXED64 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SINT32 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SINT64 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.STRING -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.UINT32 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.UINT64 -Required.ProtobufInput.PrematureEofInsideUnknownValue.BOOL -Required.ProtobufInput.PrematureEofInsideUnknownValue.BYTES -Required.ProtobufInput.PrematureEofInsideUnknownValue.DOUBLE -Required.ProtobufInput.PrematureEofInsideUnknownValue.ENUM -Required.ProtobufInput.PrematureEofInsideUnknownValue.FIXED32 -Required.ProtobufInput.PrematureEofInsideUnknownValue.FIXED64 -Required.ProtobufInput.PrematureEofInsideUnknownValue.FLOAT -Required.ProtobufInput.PrematureEofInsideUnknownValue.INT32 -Required.ProtobufInput.PrematureEofInsideUnknownValue.INT64 -Required.ProtobufInput.PrematureEofInsideUnknownValue.MESSAGE -Required.ProtobufInput.PrematureEofInsideUnknownValue.SFIXED32 -Required.ProtobufInput.PrematureEofInsideUnknownValue.SFIXED64 -Required.ProtobufInput.PrematureEofInsideUnknownValue.SINT32 -Required.ProtobufInput.PrematureEofInsideUnknownValue.SINT64 -Required.ProtobufInput.PrematureEofInsideUnknownValue.STRING -Required.ProtobufInput.PrematureEofInsideUnknownValue.UINT32 -Required.ProtobufInput.PrematureEofInsideUnknownValue.UINT64 -Required.ProtobufInput.RepeatedScalarSelectsLast.BOOL.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.BOOL.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.DOUBLE.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.DOUBLE.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FLOAT.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FLOAT.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.INT32.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.INT32.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.INT64.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.INT64.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SFIXED32.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SFIXED32.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SFIXED64.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SFIXED64.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SINT32.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SINT32.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SINT64.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SINT64.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.UINT32.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.UINT32.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.BOOL.JsonOutput -Required.ProtobufInput.ValidDataRepeated.BOOL.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.DOUBLE.JsonOutput -Required.ProtobufInput.ValidDataRepeated.DOUBLE.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.FIXED32.JsonOutput -Required.ProtobufInput.ValidDataRepeated.FIXED32.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.FIXED64.JsonOutput -Required.ProtobufInput.ValidDataRepeated.FIXED64.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput -Required.ProtobufInput.ValidDataRepeated.FLOAT.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.INT32.JsonOutput -Required.ProtobufInput.ValidDataRepeated.INT32.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.INT64.JsonOutput -Required.ProtobufInput.ValidDataRepeated.INT64.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.SFIXED32.JsonOutput -Required.ProtobufInput.ValidDataRepeated.SFIXED32.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.SFIXED64.JsonOutput -Required.ProtobufInput.ValidDataRepeated.SFIXED64.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.SINT32.JsonOutput -Required.ProtobufInput.ValidDataRepeated.SINT32.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.SINT64.JsonOutput -Required.ProtobufInput.ValidDataRepeated.SINT64.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.UINT32.JsonOutput -Required.ProtobufInput.ValidDataRepeated.UINT32.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.UINT64.JsonOutput -Required.ProtobufInput.ValidDataRepeated.UINT64.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.BOOL.JsonOutput -Required.ProtobufInput.ValidDataScalar.BOOL.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.DOUBLE.JsonOutput -Required.ProtobufInput.ValidDataScalar.DOUBLE.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.FIXED32.JsonOutput -Required.ProtobufInput.ValidDataScalar.FIXED32.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.FIXED64.JsonOutput -Required.ProtobufInput.ValidDataScalar.FIXED64.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.FLOAT.JsonOutput -Required.ProtobufInput.ValidDataScalar.FLOAT.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.INT32.JsonOutput -Required.ProtobufInput.ValidDataScalar.INT32.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.INT64.JsonOutput -Required.ProtobufInput.ValidDataScalar.INT64.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.SFIXED32.JsonOutput -Required.ProtobufInput.ValidDataScalar.SFIXED32.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.SFIXED64.JsonOutput -Required.ProtobufInput.ValidDataScalar.SFIXED64.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.SINT32.JsonOutput -Required.ProtobufInput.ValidDataScalar.SINT32.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.SINT64.JsonOutput -Required.ProtobufInput.ValidDataScalar.SINT64.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.UINT32.JsonOutput -Required.ProtobufInput.ValidDataScalar.UINT32.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.UINT64.JsonOutput -Required.ProtobufInput.ValidDataScalar.UINT64.ProtobufOutput Required.TimestampProtoInputTooLarge.JsonOutput Required.TimestampProtoInputTooSmall.JsonOutput +Required.JsonInput.FloatFieldTooLarge +Required.JsonInput.FloatFieldTooSmall +Required.JsonInput.DoubleFieldTooSmall +Required.JsonInput.Int32FieldNotInteger +Required.JsonInput.Int64FieldNotInteger +Required.JsonInput.Uint32FieldNotInteger +Required.JsonInput.Uint64FieldNotInteger +Required.JsonInput.Int32FieldLeadingSpace +Required.JsonInput.OneofFieldDuplicate +Required.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput diff --git a/conformance/failure_list_php_c.txt b/conformance/failure_list_php_c.txt index f53449f7..591997ef 100644 --- a/conformance/failure_list_php_c.txt +++ b/conformance/failure_list_php_c.txt @@ -9,22 +9,10 @@ Recommended.JsonInput.DurationHas9FractionalDigits.Validator Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator Recommended.JsonInput.Int64FieldBeString.Validator Recommended.JsonInput.MapFieldValueIsNull -Recommended.JsonInput.OneofZeroBool.JsonOutput -Recommended.JsonInput.OneofZeroBool.ProtobufOutput Recommended.JsonInput.OneofZeroBytes.JsonOutput Recommended.JsonInput.OneofZeroBytes.ProtobufOutput -Recommended.JsonInput.OneofZeroDouble.JsonOutput -Recommended.JsonInput.OneofZeroDouble.ProtobufOutput -Recommended.JsonInput.OneofZeroEnum.JsonOutput -Recommended.JsonInput.OneofZeroEnum.ProtobufOutput -Recommended.JsonInput.OneofZeroFloat.JsonOutput -Recommended.JsonInput.OneofZeroFloat.ProtobufOutput Recommended.JsonInput.OneofZeroString.JsonOutput Recommended.JsonInput.OneofZeroString.ProtobufOutput -Recommended.JsonInput.OneofZeroUint32.JsonOutput -Recommended.JsonInput.OneofZeroUint32.ProtobufOutput -Recommended.JsonInput.OneofZeroUint64.JsonOutput -Recommended.JsonInput.OneofZeroUint64.ProtobufOutput Recommended.JsonInput.RepeatedFieldMessageElementIsNull Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull Recommended.JsonInput.StringEndsWithEscapeChar @@ -37,25 +25,12 @@ Recommended.JsonInput.TimestampHas9FractionalDigits.Validator Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator Recommended.JsonInput.TimestampZeroNormalized.Validator Recommended.JsonInput.Uint64FieldBeString.Validator -Recommended.ProtobufInput.OneofZeroBool.JsonOutput -Recommended.ProtobufInput.OneofZeroBool.ProtobufOutput Recommended.ProtobufInput.OneofZeroBytes.JsonOutput Recommended.ProtobufInput.OneofZeroBytes.ProtobufOutput -Recommended.ProtobufInput.OneofZeroDouble.JsonOutput -Recommended.ProtobufInput.OneofZeroDouble.ProtobufOutput -Recommended.ProtobufInput.OneofZeroEnum.JsonOutput -Recommended.ProtobufInput.OneofZeroEnum.ProtobufOutput -Recommended.ProtobufInput.OneofZeroFloat.JsonOutput -Recommended.ProtobufInput.OneofZeroFloat.ProtobufOutput Recommended.ProtobufInput.OneofZeroString.JsonOutput Recommended.ProtobufInput.OneofZeroString.ProtobufOutput -Recommended.ProtobufInput.OneofZeroUint32.JsonOutput -Recommended.ProtobufInput.OneofZeroUint32.ProtobufOutput -Recommended.ProtobufInput.OneofZeroUint64.JsonOutput -Recommended.ProtobufInput.OneofZeroUint64.ProtobufOutput Required.DurationProtoInputTooLarge.JsonOutput Required.DurationProtoInputTooSmall.JsonOutput -Required.JsonInput.AllFieldAcceptNull.ProtobufOutput Required.JsonInput.Any.JsonOutput Required.JsonInput.Any.ProtobufOutput Required.JsonInput.AnyNested.JsonOutput @@ -76,7 +51,6 @@ Required.JsonInput.AnyWithValueForInteger.JsonOutput Required.JsonInput.AnyWithValueForInteger.ProtobufOutput Required.JsonInput.AnyWithValueForJsonObject.JsonOutput Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput -Required.JsonInput.BoolFieldFalse.ProtobufOutput Required.JsonInput.BoolMapField.JsonOutput Required.JsonInput.DoubleFieldInfinity.JsonOutput Required.JsonInput.DoubleFieldInfinity.ProtobufOutput @@ -100,7 +74,6 @@ Required.JsonInput.DurationMinValue.JsonOutput Required.JsonInput.DurationMinValue.ProtobufOutput Required.JsonInput.DurationRepeatedValue.JsonOutput Required.JsonInput.DurationRepeatedValue.ProtobufOutput -Required.JsonInput.EnumField.ProtobufOutput Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput Required.JsonInput.EnumFieldNumericValueZero.JsonOutput @@ -215,13 +188,10 @@ Required.JsonInput.ValueAcceptObject.JsonOutput Required.JsonInput.ValueAcceptObject.ProtobufOutput Required.JsonInput.ValueAcceptString.JsonOutput Required.JsonInput.ValueAcceptString.ProtobufOutput -Required.JsonInput.WrapperTypesWithNullValue.ProtobufOutput Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput +Required.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput Required.TimestampProtoInputTooLarge.JsonOutput Required.TimestampProtoInputTooSmall.JsonOutput diff --git a/conformance/failure_list_php_zts_c.txt b/conformance/failure_list_php_zts_c.txt new file mode 100644 index 00000000..d9a8fe36 --- /dev/null +++ b/conformance/failure_list_php_zts_c.txt @@ -0,0 +1,225 @@ +Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput +Recommended.FieldMaskPathsDontRoundTrip.JsonOutput +Recommended.FieldMaskTooManyUnderscore.JsonOutput +Recommended.JsonInput.BoolFieldIntegerOne +Recommended.JsonInput.BoolFieldIntegerZero +Recommended.JsonInput.DurationHas3FractionalDigits.Validator +Recommended.JsonInput.DurationHas6FractionalDigits.Validator +Recommended.JsonInput.DurationHas9FractionalDigits.Validator +Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator +Recommended.JsonInput.Int64FieldBeString.Validator +Recommended.JsonInput.OneofZeroBytes.JsonOutput +Recommended.JsonInput.OneofZeroBytes.ProtobufOutput +Recommended.JsonInput.OneofZeroDouble.JsonOutput +Recommended.JsonInput.OneofZeroDouble.ProtobufOutput +Recommended.JsonInput.OneofZeroFloat.JsonOutput +Recommended.JsonInput.OneofZeroFloat.ProtobufOutput +Recommended.JsonInput.OneofZeroString.JsonOutput +Recommended.JsonInput.OneofZeroString.ProtobufOutput +Recommended.JsonInput.OneofZeroUint32.JsonOutput +Recommended.JsonInput.OneofZeroUint32.ProtobufOutput +Recommended.JsonInput.OneofZeroUint64.JsonOutput +Recommended.JsonInput.OneofZeroUint64.ProtobufOutput +Recommended.JsonInput.StringEndsWithEscapeChar +Recommended.JsonInput.StringFieldSurrogateInWrongOrder +Recommended.JsonInput.StringFieldUnpairedHighSurrogate +Recommended.JsonInput.StringFieldUnpairedLowSurrogate +Recommended.JsonInput.TimestampHas3FractionalDigits.Validator +Recommended.JsonInput.TimestampHas6FractionalDigits.Validator +Recommended.JsonInput.TimestampHas9FractionalDigits.Validator +Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator +Recommended.JsonInput.TimestampZeroNormalized.Validator +Recommended.JsonInput.Uint64FieldBeString.Validator +Recommended.ProtobufInput.OneofZeroBytes.JsonOutput +Recommended.ProtobufInput.OneofZeroBytes.ProtobufOutput +Recommended.ProtobufInput.OneofZeroString.JsonOutput +Recommended.ProtobufInput.OneofZeroString.ProtobufOutput +Required.DurationProtoInputTooLarge.JsonOutput +Required.DurationProtoInputTooSmall.JsonOutput +Required.JsonInput.AllFieldAcceptNull.ProtobufOutput +Required.JsonInput.Any.JsonOutput +Required.JsonInput.Any.ProtobufOutput +Required.JsonInput.AnyNested.JsonOutput +Required.JsonInput.AnyNested.ProtobufOutput +Required.JsonInput.AnyUnorderedTypeTag.JsonOutput +Required.JsonInput.AnyUnorderedTypeTag.ProtobufOutput +Required.JsonInput.AnyWithDuration.JsonOutput +Required.JsonInput.AnyWithDuration.ProtobufOutput +Required.JsonInput.AnyWithFieldMask.JsonOutput +Required.JsonInput.AnyWithFieldMask.ProtobufOutput +Required.JsonInput.AnyWithInt32ValueWrapper.JsonOutput +Required.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput +Required.JsonInput.AnyWithStruct.JsonOutput +Required.JsonInput.AnyWithStruct.ProtobufOutput +Required.JsonInput.AnyWithTimestamp.JsonOutput +Required.JsonInput.AnyWithTimestamp.ProtobufOutput +Required.JsonInput.AnyWithValueForInteger.JsonOutput +Required.JsonInput.AnyWithValueForInteger.ProtobufOutput +Required.JsonInput.AnyWithValueForJsonObject.JsonOutput +Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput +Required.JsonInput.BoolFieldFalse.ProtobufOutput +Required.JsonInput.BoolMapField.JsonOutput +Required.JsonInput.DoubleFieldInfinity.JsonOutput +Required.JsonInput.DoubleFieldInfinity.ProtobufOutput +Required.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput +Required.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput +Required.JsonInput.DoubleFieldMaxPositiveValue.JsonOutput +Required.JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput +Required.JsonInput.DoubleFieldMinNegativeValue.JsonOutput +Required.JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput +Required.JsonInput.DoubleFieldMinPositiveValue.JsonOutput +Required.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput +Required.JsonInput.DoubleFieldNan.JsonOutput +Required.JsonInput.DoubleFieldNan.ProtobufOutput +Required.JsonInput.DoubleFieldNegativeInfinity.JsonOutput +Required.JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput +Required.JsonInput.DoubleFieldQuotedValue.JsonOutput +Required.JsonInput.DoubleFieldQuotedValue.ProtobufOutput +Required.JsonInput.DurationMaxValue.JsonOutput +Required.JsonInput.DurationMaxValue.ProtobufOutput +Required.JsonInput.DurationMinValue.JsonOutput +Required.JsonInput.DurationMinValue.ProtobufOutput +Required.JsonInput.DurationRepeatedValue.JsonOutput +Required.JsonInput.DurationRepeatedValue.ProtobufOutput +Required.JsonInput.EnumField.ProtobufOutput +Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput +Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput +Required.JsonInput.EnumFieldNumericValueZero.JsonOutput +Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput +Required.JsonInput.EnumFieldUnknownValue.Validator +Required.JsonInput.FieldMask.JsonOutput +Required.JsonInput.FieldMask.ProtobufOutput +Required.JsonInput.FloatFieldInfinity.JsonOutput +Required.JsonInput.FloatFieldInfinity.ProtobufOutput +Required.JsonInput.FloatFieldNan.JsonOutput +Required.JsonInput.FloatFieldNan.ProtobufOutput +Required.JsonInput.FloatFieldNegativeInfinity.JsonOutput +Required.JsonInput.FloatFieldNegativeInfinity.ProtobufOutput +Required.JsonInput.FloatFieldQuotedValue.JsonOutput +Required.JsonInput.FloatFieldQuotedValue.ProtobufOutput +Required.JsonInput.FloatFieldTooLarge +Required.JsonInput.FloatFieldTooSmall +Required.JsonInput.Int32FieldExponentialFormat.JsonOutput +Required.JsonInput.Int32FieldExponentialFormat.ProtobufOutput +Required.JsonInput.Int32FieldFloatTrailingZero.JsonOutput +Required.JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput +Required.JsonInput.Int32FieldMaxFloatValue.JsonOutput +Required.JsonInput.Int32FieldMaxFloatValue.ProtobufOutput +Required.JsonInput.Int32FieldMinFloatValue.JsonOutput +Required.JsonInput.Int32FieldMinFloatValue.ProtobufOutput +Required.JsonInput.Int32FieldStringValue.JsonOutput +Required.JsonInput.Int32FieldStringValue.ProtobufOutput +Required.JsonInput.Int32FieldStringValueEscaped.JsonOutput +Required.JsonInput.Int32FieldStringValueEscaped.ProtobufOutput +Required.JsonInput.Int32MapEscapedKey.JsonOutput +Required.JsonInput.Int32MapEscapedKey.ProtobufOutput +Required.JsonInput.Int32MapField.JsonOutput +Required.JsonInput.Int32MapField.ProtobufOutput +Required.JsonInput.Int64FieldMaxValue.JsonOutput +Required.JsonInput.Int64FieldMaxValue.ProtobufOutput +Required.JsonInput.Int64FieldMinValue.JsonOutput +Required.JsonInput.Int64FieldMinValue.ProtobufOutput +Required.JsonInput.Int64MapEscapedKey.JsonOutput +Required.JsonInput.Int64MapEscapedKey.ProtobufOutput +Required.JsonInput.Int64MapField.JsonOutput +Required.JsonInput.Int64MapField.ProtobufOutput +Required.JsonInput.MessageField.JsonOutput +Required.JsonInput.MessageField.ProtobufOutput +Required.JsonInput.MessageMapField.JsonOutput +Required.JsonInput.MessageMapField.ProtobufOutput +Required.JsonInput.MessageRepeatedField.JsonOutput +Required.JsonInput.MessageRepeatedField.ProtobufOutput +Required.JsonInput.OptionalBoolWrapper.JsonOutput +Required.JsonInput.OptionalBoolWrapper.ProtobufOutput +Required.JsonInput.OptionalBytesWrapper.JsonOutput +Required.JsonInput.OptionalBytesWrapper.ProtobufOutput +Required.JsonInput.OptionalDoubleWrapper.JsonOutput +Required.JsonInput.OptionalDoubleWrapper.ProtobufOutput +Required.JsonInput.OptionalFloatWrapper.JsonOutput +Required.JsonInput.OptionalFloatWrapper.ProtobufOutput +Required.JsonInput.OptionalInt32Wrapper.JsonOutput +Required.JsonInput.OptionalInt32Wrapper.ProtobufOutput +Required.JsonInput.OptionalInt64Wrapper.JsonOutput +Required.JsonInput.OptionalInt64Wrapper.ProtobufOutput +Required.JsonInput.OptionalStringWrapper.JsonOutput +Required.JsonInput.OptionalStringWrapper.ProtobufOutput +Required.JsonInput.OptionalUint32Wrapper.JsonOutput +Required.JsonInput.OptionalUint32Wrapper.ProtobufOutput +Required.JsonInput.OptionalUint64Wrapper.JsonOutput +Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput +Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput +Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput +Required.JsonInput.PrimitiveRepeatedField.JsonOutput +Required.JsonInput.PrimitiveRepeatedField.ProtobufOutput +Required.JsonInput.RepeatedBoolWrapper.JsonOutput +Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput +Required.JsonInput.RepeatedBytesWrapper.JsonOutput +Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput +Required.JsonInput.RepeatedDoubleWrapper.JsonOutput +Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput +Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt +Required.JsonInput.RepeatedFloatWrapper.JsonOutput +Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput +Required.JsonInput.RepeatedInt32Wrapper.JsonOutput +Required.JsonInput.RepeatedInt32Wrapper.ProtobufOutput +Required.JsonInput.RepeatedInt64Wrapper.JsonOutput +Required.JsonInput.RepeatedInt64Wrapper.ProtobufOutput +Required.JsonInput.RepeatedStringWrapper.JsonOutput +Required.JsonInput.RepeatedStringWrapper.ProtobufOutput +Required.JsonInput.RepeatedUint32Wrapper.JsonOutput +Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput +Required.JsonInput.RepeatedUint64Wrapper.JsonOutput +Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput +Required.JsonInput.StringFieldEscape.JsonOutput +Required.JsonInput.StringFieldEscape.ProtobufOutput +Required.JsonInput.StringFieldNotAString +Required.JsonInput.StringFieldSurrogatePair.JsonOutput +Required.JsonInput.StringFieldSurrogatePair.ProtobufOutput +Required.JsonInput.StringFieldUnicodeEscape.JsonOutput +Required.JsonInput.StringFieldUnicodeEscape.ProtobufOutput +Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput +Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.ProtobufOutput +Required.JsonInput.Struct.JsonOutput +Required.JsonInput.Struct.ProtobufOutput +Required.JsonInput.TimestampMaxValue.JsonOutput +Required.JsonInput.TimestampMaxValue.ProtobufOutput +Required.JsonInput.TimestampMinValue.JsonOutput +Required.JsonInput.TimestampMinValue.ProtobufOutput +Required.JsonInput.TimestampRepeatedValue.JsonOutput +Required.JsonInput.TimestampRepeatedValue.ProtobufOutput +Required.JsonInput.TimestampWithNegativeOffset.JsonOutput +Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput +Required.JsonInput.TimestampWithPositiveOffset.JsonOutput +Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput +Required.JsonInput.Uint32FieldMaxFloatValue.JsonOutput +Required.JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput +Required.JsonInput.Uint32MapField.JsonOutput +Required.JsonInput.Uint32MapField.ProtobufOutput +Required.JsonInput.Uint64FieldMaxValue.JsonOutput +Required.JsonInput.Uint64FieldMaxValue.ProtobufOutput +Required.JsonInput.Uint64MapField.JsonOutput +Required.JsonInput.Uint64MapField.ProtobufOutput +Required.JsonInput.ValueAcceptBool.JsonOutput +Required.JsonInput.ValueAcceptBool.ProtobufOutput +Required.JsonInput.ValueAcceptFloat.JsonOutput +Required.JsonInput.ValueAcceptFloat.ProtobufOutput +Required.JsonInput.ValueAcceptInteger.JsonOutput +Required.JsonInput.ValueAcceptInteger.ProtobufOutput +Required.JsonInput.ValueAcceptList.JsonOutput +Required.JsonInput.ValueAcceptList.ProtobufOutput +Required.JsonInput.ValueAcceptNull.JsonOutput +Required.JsonInput.ValueAcceptNull.ProtobufOutput +Required.JsonInput.ValueAcceptObject.JsonOutput +Required.JsonInput.ValueAcceptObject.ProtobufOutput +Required.JsonInput.ValueAcceptString.JsonOutput +Required.JsonInput.ValueAcceptString.ProtobufOutput +Required.JsonInput.WrapperTypesWithNullValue.ProtobufOutput +Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput +Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput +Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput +Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput +Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.ProtobufOutput +Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput +Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput +Required.TimestampProtoInputTooLarge.JsonOutput +Required.TimestampProtoInputTooSmall.JsonOutput diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c index 6e3c606b..b07abfa7 100644 --- a/php/ext/google/protobuf/encode_decode.c +++ b/php/ext/google/protobuf/encode_decode.c @@ -164,18 +164,21 @@ typedef struct { int property_ofs; // properties table cache uint32_t oneof_case_num; // oneof-case number to place in oneof_case field const upb_msgdef *md; // msgdef, for oneof submessage handler + const upb_msgdef *parent_md; // msgdef, for parent submessage } oneof_handlerdata_t; static const void *newoneofhandlerdata(upb_handlers *h, uint32_t ofs, uint32_t case_ofs, int property_ofs, + const upb_msgdef *m, const upb_fielddef *f) { oneof_handlerdata_t* hd = (oneof_handlerdata_t*)malloc(sizeof(oneof_handlerdata_t)); hd->ofs = ofs; hd->case_ofs = case_ofs; hd->property_ofs = property_ofs; + hd->parent_md = m; // We reuse the field tag number as a oneof union discriminant tag. Note that // we don't expose these numbers to the user, so the only requirement is that // we have some unique ID for each union case/possibility. The field tag @@ -284,10 +287,19 @@ DEFINE_SINGULAR_HANDLER(double, double) #if PHP_MAJOR_VERSION < 7 static void *empty_php_string(zval** value_ptr) { SEPARATE_ZVAL_IF_NOT_REF(value_ptr); + if (Z_TYPE_PP(value_ptr) == IS_STRING && + !IS_INTERNED(Z_STRVAL_PP(value_ptr))) { + FREE(Z_STRVAL_PP(value_ptr)); + } + ZVAL_EMPTY_STRING(*value_ptr); return (void*)(*value_ptr); } #else static void *empty_php_string(zval* value_ptr) { + if (Z_TYPE_P(value_ptr) == IS_STRING) { + zend_string_release(Z_STR_P(value_ptr)); + } + ZVAL_EMPTY_STRING(value_ptr); return value_ptr; } #endif @@ -462,7 +474,7 @@ static void map_slot_init(void* memory, upb_fieldtype_t type, zval* cache) { *(zval***)memory = holder; #else *(zval**)memory = cache; - PHP_PROTO_ZVAL_STRINGL(*(zval**)memory, "", 0, 1); + // PHP_PROTO_ZVAL_STRINGL(*(zval**)memory, "", 0, 1); #endif break; } @@ -654,6 +666,44 @@ DEFINE_ONEOF_HANDLER(double, double) #undef DEFINE_ONEOF_HANDLER +static void oneof_cleanup(MessageHeader* msg, + const oneof_handlerdata_t* oneofdata) { + uint32_t old_case_num = + DEREF(message_data(msg), oneofdata->case_ofs, uint32_t); + if (old_case_num == 0) { + return; + } + + const upb_fielddef* old_field = + upb_msgdef_itof(oneofdata->parent_md, old_case_num); + bool need_clean = false; + + switch (upb_fielddef_type(old_field)) { + case UPB_TYPE_STRING: + case UPB_TYPE_BYTES: + need_clean = true; + break; + case UPB_TYPE_MESSAGE: + if (oneofdata->oneof_case_num != old_case_num) { + need_clean = true; + } + break; + default: + break; + } + + if (need_clean) { +#if PHP_MAJOR_VERSION < 7 + SEPARATE_ZVAL_IF_NOT_REF( + DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*)); + php_proto_zval_ptr_dtor( + *DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*)); + MAKE_STD_ZVAL(*DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*)); + ZVAL_NULL(*DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*)); +#endif + } +} + // Handlers for string/bytes in a oneof. static void *oneofbytes_handler(void *closure, const void *hd, @@ -661,6 +711,8 @@ static void *oneofbytes_handler(void *closure, MessageHeader* msg = closure; const oneof_handlerdata_t *oneofdata = hd; + oneof_cleanup(msg, oneofdata); + DEREF(message_data(msg), oneofdata->case_ofs, uint32_t) = oneofdata->oneof_case_num; DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*) = @@ -691,22 +743,11 @@ static void* oneofsubmsg_handler(void* closure, const void* hd) { MessageHeader* submsg; if (oldcase != oneofdata->oneof_case_num) { - // Ideally, we should clean up the old data. However, we don't even know the - // type of the old data. So, we will defer the desctruction of the old data - // to the time that containing message's destroyed or the same oneof field - // is accessed again and find that the old data hasn't been cleaned. - DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*) = - &(msg->std.properties_table)[oneofdata->property_ofs]; - - // Old data was't cleaned when the oneof was accessed from another field. - if (Z_TYPE_P(CACHED_PTR_TO_ZVAL_PTR(DEREF( - message_data(msg), oneofdata->ofs, CACHED_VALUE*))) != IS_NULL) { - php_proto_zval_ptr_dtor( - CACHED_PTR_TO_ZVAL_PTR( - DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*))); - } + oneof_cleanup(msg, oneofdata); // Create new message. + DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*) = + &(msg->std.properties_table)[oneofdata->property_ofs]; ZVAL_OBJ(CACHED_PTR_TO_ZVAL_PTR( DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*)), subklass->create_object(subklass TSRMLS_CC)); @@ -856,6 +897,7 @@ static void add_handlers_for_mapentry(const upb_msgdef* msgdef, upb_handlers* h, // Set up handlers for a oneof field. static void add_handlers_for_oneof_field(upb_handlers *h, + const upb_msgdef *m, const upb_fielddef *f, size_t offset, size_t oneof_case_offset, @@ -864,7 +906,7 @@ static void add_handlers_for_oneof_field(upb_handlers *h, upb_handlerattr attr = UPB_HANDLERATTR_INITIALIZER; upb_handlerattr_sethandlerdata( &attr, newoneofhandlerdata(h, offset, oneof_case_offset, - property_cache_offset, f)); + property_cache_offset, m, f)); switch (upb_fielddef_type(f)) { @@ -936,8 +978,8 @@ static void add_handlers_for_message(const void* closure, desc->layout->fields[upb_fielddef_index(f)].case_offset; int property_cache_index = desc->layout->fields[upb_fielddef_index(f)].cache_index; - add_handlers_for_oneof_field(h, f, offset, oneof_case_offset, - property_cache_index); + add_handlers_for_oneof_field(h, desc->msgdef, f, offset, + oneof_case_offset, property_cache_index); } else if (is_map_field(f)) { add_handlers_for_mapfield(h, f, offset, desc); } else if (upb_fielddef_isseq(f)) { @@ -1198,7 +1240,7 @@ static void putrawmsg(MessageHeader* msg, const Descriptor* desc, } else if (upb_fielddef_isstring(f)) { zval* str = CACHED_PTR_TO_ZVAL_PTR( DEREF(message_data(msg), offset, CACHED_VALUE*)); - if (Z_STRLEN_P(str) > 0) { + if (containing_oneof || Z_STRLEN_P(str) > 0) { putstr(str, f, sink); } } else if (upb_fielddef_issubmsg(f)) { @@ -1221,10 +1263,10 @@ static void putrawmsg(MessageHeader* msg, const Descriptor* desc, T(UPB_TYPE_DOUBLE, double, double, 0.0) T(UPB_TYPE_BOOL, bool, uint8_t, 0) case UPB_TYPE_ENUM: - T(UPB_TYPE_INT32, int32, int32_t, 0) - T(UPB_TYPE_UINT32, uint32, uint32_t, 0) - T(UPB_TYPE_INT64, int64, int64_t, 0) - T(UPB_TYPE_UINT64, uint64, uint64_t, 0) + T(UPB_TYPE_INT32, int32, int32_t, 0) + T(UPB_TYPE_UINT32, uint32, uint32_t, 0) + T(UPB_TYPE_INT64, int64, int64_t, 0) + T(UPB_TYPE_UINT64, uint64, uint64_t, 0) case UPB_TYPE_STRING: case UPB_TYPE_BYTES: @@ -1246,18 +1288,23 @@ static void putstr(zval* str, const upb_fielddef *f, upb_sink *sink) { assert(Z_TYPE_P(str) == IS_STRING); - // Ensure that the string has the correct encoding. We also check at field-set - // time, but the user may have mutated the string object since then. - if (upb_fielddef_type(f) == UPB_TYPE_STRING && - !is_structurally_valid_utf8(Z_STRVAL_P(str), Z_STRLEN_P(str))) { - zend_error(E_USER_ERROR, "Given string is not UTF8 encoded."); - return; - } - upb_sink_startstr(sink, getsel(f, UPB_HANDLER_STARTSTR), Z_STRLEN_P(str), &subsink); - upb_sink_putstring(&subsink, getsel(f, UPB_HANDLER_STRING), Z_STRVAL_P(str), - Z_STRLEN_P(str), NULL); + + // For oneof string field, we may get here with string length is zero. + if (Z_STRLEN_P(str) > 0) { + // Ensure that the string has the correct encoding. We also check at + // field-set time, but the user may have mutated the string object since + // then. + if (upb_fielddef_type(f) == UPB_TYPE_STRING && + !is_structurally_valid_utf8(Z_STRVAL_P(str), Z_STRLEN_P(str))) { + zend_error(E_USER_ERROR, "Given string is not UTF8 encoded."); + return; + } + upb_sink_putstring(&subsink, getsel(f, UPB_HANDLER_STRING), Z_STRVAL_P(str), + Z_STRLEN_P(str), NULL); + } + upb_sink_endstr(sink, getsel(f, UPB_HANDLER_ENDSTR)); } @@ -1452,7 +1499,7 @@ PHP_METHOD(Message, mergeFromString) { } } -PHP_METHOD(Message, jsonEncode) { +PHP_METHOD(Message, serializeToJsonString) { Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, get_ce_obj(Z_OBJCE_P(getThis()))); @@ -1483,13 +1530,14 @@ PHP_METHOD(Message, jsonEncode) { } } -PHP_METHOD(Message, jsonDecode) { +PHP_METHOD(Message, mergeFromJsonString) { Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, get_ce_obj(Z_OBJCE_P(getThis()))); MessageHeader* msg = UNBOX(MessageHeader, getThis()); char *data = NULL; - int data_len; + PHP_PROTO_SIZE data_len; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) { return; diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index 79a2739a..b8ef9fc0 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -40,8 +40,8 @@ static zend_function_entry message_methods[] = { PHP_ME(Message, clear, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, serializeToString, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, mergeFromString, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Message, jsonEncode, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Message, jsonDecode, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Message, serializeToJsonString, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Message, mergeFromJsonString, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, mergeFrom, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, readOneof, NULL, ZEND_ACC_PROTECTED) PHP_ME(Message, writeOneof, NULL, ZEND_ACC_PROTECTED) diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index e6d42eba..406a09a5 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -593,8 +593,8 @@ const upb_pbdecodermethod *new_fillmsg_decodermethod(Descriptor *desc, PHP_METHOD(Message, serializeToString); PHP_METHOD(Message, mergeFromString); -PHP_METHOD(Message, jsonEncode); -PHP_METHOD(Message, jsonDecode); +PHP_METHOD(Message, serializeToJsonString); +PHP_METHOD(Message, mergeFromJsonString); // ----------------------------------------------------------------------------- // Type check / conversion. diff --git a/php/ext/google/protobuf/upb.c b/php/ext/google/protobuf/upb.c index cac2b401..d701dcba 100644 --- a/php/ext/google/protobuf/upb.c +++ b/php/ext/google/protobuf/upb.c @@ -2308,6 +2308,9 @@ bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status *status) { bool ret; n = upb_filedef_defcount(file); + if (n == 0) { + return true; + } defs = upb_gmalloc(sizeof(*defs) * n); if (defs == NULL) { diff --git a/php/src/Google/Protobuf/Internal/CodedInputStream.php b/php/src/Google/Protobuf/Internal/CodedInputStream.php new file mode 100644 index 00000000..6131d5d1 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/CodedInputStream.php @@ -0,0 +1,373 @@ +buffer = $buffer; + $this->buffer_size_after_limit = 0; + $this->buffer_end = $end; + $this->current = $start; + $this->current_limit = $end; + $this->legitimate_message_end = false; + $this->recursion_budget = self::DEFAULT_RECURSION_LIMIT; + $this->recursion_limit = self::DEFAULT_RECURSION_LIMIT; + $this->total_bytes_limit = self::DEFAULT_TOTAL_BYTES_LIMIT; + $this->total_bytes_read = $end - $start; + } + + private function advance($amount) + { + $this->current += $amount; + } + + public function bufferSize() + { + return $this->buffer_end - $this->current; + } + + private function current() + { + return $this->total_bytes_read - + ($this->buffer_end - $this->current + + $this->buffer_size_after_limit); + } + + private function recomputeBufferLimits() + { + $this->buffer_end += $this->buffer_size_after_limit; + $closest_limit = min($this->current_limit, $this->total_bytes_limit); + if ($closest_limit < $this->total_bytes_read) { + // The limit position is in the current buffer. We must adjust the + // buffer size accordingly. + $this->buffer_size_after_limit = $this->total_bytes_read - + $closest_limit; + $this->buffer_end -= $this->buffer_size_after_limit; + } else { + $this->buffer_size_after_limit = 0; + } + } + + private function consumedEntireMessage() + { + return $this->legitimate_message_end; + } + + /** + * Read uint32 into $var. Advance buffer with consumed bytes. If the + * contained varint is larger than 32 bits, discard the high order bits. + * @param $var. + */ + public function readVarint32(&$var) + { + if (!$this->readVarint64($var)) { + return false; + } + + if (PHP_INT_SIZE == 4) { + $var = bcmod($var, 4294967296); + } else { + $var &= 0xFFFFFFFF; + } + + // Convert large uint32 to int32. + if ($var > 0x7FFFFFFF) { + if (PHP_INT_SIZE === 8) { + $var = $var | (0xFFFFFFFF << 32); + } else { + $var = bcsub($var, 4294967296); + } + } + + $var = intval($var); + return true; + } + + /** + * Read Uint64 into $var. Advance buffer with consumed bytes. + * @param $var. + */ + public function readVarint64(&$var) + { + $count = 0; + + if (PHP_INT_SIZE == 4) { + $high = 0; + $low = 0; + $b = 0; + + do { + if ($this->current === $this->buffer_end) { + return false; + } + if ($count === self::MAX_VARINT_BYTES) { + return false; + } + $b = ord($this->buffer[$this->current]); + $bits = 7 * $count; + if ($bits >= 32) { + $high |= (($b & 0x7F) << ($bits - 32)); + } else if ($bits > 25){ + // $bits is 28 in this case. + $low |= (($b & 0x7F) << 28); + $high = ($b & 0x7F) >> 4; + } else { + $low |= (($b & 0x7F) << $bits); + } + + $this->advance(1); + $count += 1; + } while ($b & 0x80); + + $var = GPBUtil::combineInt32ToInt64($high, $low); + if (bccomp($var, 0) < 0) { + $var = bcadd($var, "18446744073709551616"); + } + } else { + $result = 0; + $shift = 0; + + do { + if ($this->current === $this->buffer_end) { + return false; + } + if ($count === self::MAX_VARINT_BYTES) { + return false; + } + + $byte = ord($this->buffer[$this->current]); + $result |= ($byte & 0x7f) << $shift; + $shift += 7; + $this->advance(1); + $count += 1; + } while ($byte > 0x7f); + + $var = $result; + } + + return true; + } + + /** + * Read int into $var. If the result is larger than the largest integer, $var + * will be -1. Advance buffer with consumed bytes. + * @param $var. + */ + public function readVarintSizeAsInt(&$var) + { + if (!$this->readVarint64($var)) { + return false; + } + $var = (int)$var; + return true; + } + + /** + * Read 32-bit unsiged integer to $var. If the buffer has less than 4 bytes, + * return false. Advance buffer with consumed bytes. + * @param $var. + */ + public function readLittleEndian32(&$var) + { + $data = null; + if (!$this->readRaw(4, $data)) { + return false; + } + $var = unpack('V', $data); + $var = $var[1]; + return true; + } + + /** + * Read 64-bit unsiged integer to $var. If the buffer has less than 8 bytes, + * return false. Advance buffer with consumed bytes. + * @param $var. + */ + public function readLittleEndian64(&$var) + { + $data = null; + if (!$this->readRaw(4, $data)) { + return false; + } + $low = unpack('V', $data)[1]; + if (!$this->readRaw(4, $data)) { + return false; + } + $high = unpack('V', $data)[1]; + if (PHP_INT_SIZE == 4) { + $var = GPBUtil::combineInt32ToInt64($high, $low); + } else { + $var = ($high << 32) | $low; + } + return true; + } + + /** + * Read tag into $var. Advance buffer with consumed bytes. + * @param $var. + */ + public function readTag() + { + if ($this->current === $this->buffer_end) { + // Make sure that it failed due to EOF, not because we hit + // total_bytes_limit, which, unlike normal limits, is not a valid + // place to end a message. + $current_position = $this->total_bytes_read - + $this->buffer_size_after_limit; + if ($current_position >= $this->total_bytes_limit) { + // Hit total_bytes_limit_. But if we also hit the normal limit, + // we're still OK. + $this->legitimate_message_end = + ($this->current_limit === $this->total_bytes_limit); + } else { + $this->legitimate_message_end = true; + } + return 0; + } + + $result = 0; + // The larget tag is 2^29 - 1, which can be represented by int32. + $success = $this->readVarint32($result); + if ($success) { + return $result; + } else { + return 0; + } + } + + public function readRaw($size, &$buffer) + { + $current_buffer_size = 0; + if ($this->bufferSize() < $size) { + return false; + } + + $buffer = substr($this->buffer, $this->current, $size); + $this->advance($size); + + return true; + } + + /* Places a limit on the number of bytes that the stream may read, starting + * from the current position. Once the stream hits this limit, it will act + * like the end of the input has been reached until popLimit() is called. + * + * As the names imply, the stream conceptually has a stack of limits. The + * shortest limit on the stack is always enforced, even if it is not the top + * limit. + * + * The value returned by pushLimit() is opaque to the caller, and must be + * passed unchanged to the corresponding call to popLimit(). + * + * @param integer $byte_limit + * @throws Exception Fail to push limit. + */ + public function pushLimit($byte_limit) + { + // Current position relative to the beginning of the stream. + $current_position = $this->current(); + $old_limit = $this->current_limit; + + // security: byte_limit is possibly evil, so check for negative values + // and overflow. + if ($byte_limit >= 0 && + $byte_limit <= PHP_INT_MAX - $current_position && + $byte_limit <= $this->current_limit - $current_position) { + $this->current_limit = $current_position + $byte_limit; + $this->recomputeBufferLimits(); + } else { + throw new GPBDecodeException("Fail to push limit."); + } + + return $old_limit; + } + + /* The limit passed in is actually the *old* limit, which we returned from + * PushLimit(). + * + * @param integer $byte_limit + */ + public function popLimit($byte_limit) + { + $this->current_limit = $byte_limit; + $this->recomputeBufferLimits(); + // We may no longer be at a legitimate message end. ReadTag() needs to + // be called again to find out. + $this->legitimate_message_end = false; + } + + public function incrementRecursionDepthAndPushLimit( + $byte_limit, &$old_limit, &$recursion_budget) + { + $old_limit = $this->pushLimit($byte_limit); + $recursion_limit = --$this->recursion_limit; + } + + public function decrementRecursionDepthAndPopLimit($byte_limit) + { + $result = $this->consumedEntireMessage(); + $this->popLimit($byte_limit); + ++$this->recursion_budget; + return $result; + } + + public function bytesUntilLimit() + { + if ($this->current_limit === PHP_INT_MAX) { + return -1; + } + return $this->current_limit - $this->current; + } +} diff --git a/php/src/Google/Protobuf/Internal/CodedOutputStream.php b/php/src/Google/Protobuf/Internal/CodedOutputStream.php new file mode 100644 index 00000000..4525d8dd --- /dev/null +++ b/php/src/Google/Protobuf/Internal/CodedOutputStream.php @@ -0,0 +1,159 @@ +current = 0; + $this->buffer_size = $size; + $this->buffer = str_repeat(chr(0), $this->buffer_size); + } + + public function getData() + { + return $this->buffer; + } + + public function writeVarint32($value, $trim) + { + $bytes = str_repeat(chr(0), self::MAX_VARINT64_BYTES); + $size = self::writeVarintToArray($value, $bytes, $trim); + return $this->writeRaw($bytes, $size); + } + + public function writeVarint64($value) + { + $bytes = str_repeat(chr(0), self::MAX_VARINT64_BYTES); + $size = self::writeVarintToArray($value, $bytes); + return $this->writeRaw($bytes, $size); + } + + public function writeLittleEndian32($value) + { + $bytes = str_repeat(chr(0), 4); + $size = self::writeLittleEndian32ToArray($value, $bytes); + return $this->writeRaw($bytes, $size); + } + + public function writeLittleEndian64($value) + { + $bytes = str_repeat(chr(0), 8); + $size = self::writeLittleEndian64ToArray($value, $bytes); + return $this->writeRaw($bytes, $size); + } + + public function writeTag($tag) + { + return $this->writeVarint32($tag, true); + } + + public function writeRaw($data, $size) + { + if ($this->buffer_size < $size) { + trigger_error("Output stream doesn't have enough buffer."); + return false; + } + + for ($i = 0; $i < $size; $i++) { + $this->buffer[$this->current] = $data[$i]; + $this->current++; + $this->buffer_size--; + } + return true; + } + + private static function writeVarintToArray($value, &$buffer, $trim = false) + { + $current = 0; + + $high = 0; + $low = 0; + if (PHP_INT_SIZE == 4) { + GPBUtil::divideInt64ToInt32($value, $high, $low, $trim); + } else { + $low = $value; + } + + while (($low >= 0x80 || $low < 0) || $high != 0) { + $buffer[$current] = chr($low | 0x80); + $value = ($value >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7)); + $carry = ($high & 0x7F) << ((PHP_INT_SIZE << 3) - 7); + $high = ($high >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7)); + $low = (($low >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7)) | $carry); + $current++; + } + $buffer[$current] = chr($low); + return $current + 1; + } + + private static function writeLittleEndian32ToArray($value, &$buffer) + { + $buffer[0] = chr($value & 0x000000FF); + $buffer[1] = chr(($value >> 8) & 0x000000FF); + $buffer[2] = chr(($value >> 16) & 0x000000FF); + $buffer[3] = chr(($value >> 24) & 0x000000FF); + return 4; + } + + private static function writeLittleEndian64ToArray($value, &$buffer) + { + $high = 0; + $low = 0; + if (PHP_INT_SIZE == 4) { + GPBUtil::divideInt64ToInt32($value, $high, $low); + } else { + $low = $value & 0xFFFFFFFF; + $high = ($value >> 32) & 0xFFFFFFFF; + } + + $buffer[0] = chr($low & 0x000000FF); + $buffer[1] = chr(($low >> 8) & 0x000000FF); + $buffer[2] = chr(($low >> 16) & 0x000000FF); + $buffer[3] = chr(($low >> 24) & 0x000000FF); + $buffer[4] = chr($high & 0x000000FF); + $buffer[5] = chr(($high >> 8) & 0x000000FF); + $buffer[6] = chr(($high >> 16) & 0x000000FF); + $buffer[7] = chr(($high >> 24) & 0x000000FF); + return 8; + } + +} diff --git a/php/src/Google/Protobuf/Internal/Descriptor.php b/php/src/Google/Protobuf/Internal/Descriptor.php index f8d24e45..44225ad2 100644 --- a/php/src/Google/Protobuf/Internal/Descriptor.php +++ b/php/src/Google/Protobuf/Internal/Descriptor.php @@ -37,6 +37,8 @@ class Descriptor private $full_name; private $field = []; + private $json_to_field = []; + private $name_to_field = []; private $nested_type = []; private $enum_type = []; private $klass; @@ -66,6 +68,8 @@ class Descriptor public function addField($field) { $this->field[$field->getNumber()] = $field; + $this->json_to_field[$field->getJsonName()] = $field; + $this->name_to_field[$field->getName()] = $field; } public function getField() @@ -95,11 +99,29 @@ class Descriptor public function getFieldByNumber($number) { - if (!isset($this->field[$number])) { - return NULL; - } else { - return $this->field[$number]; - } + if (!isset($this->field[$number])) { + return NULL; + } else { + return $this->field[$number]; + } + } + + public function getFieldByJsonName($json_name) + { + if (!isset($this->json_to_field[$json_name])) { + return NULL; + } else { + return $this->json_to_field[$json_name]; + } + } + + public function getFieldByName($name) + { + if (!isset($this->name_to_field[$name])) { + return NULL; + } else { + return $this->name_to_field[$name]; + } } public function setClass($klass) diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptor.php b/php/src/Google/Protobuf/Internal/EnumDescriptor.php index 7360a477..33a55a4a 100644 --- a/php/src/Google/Protobuf/Internal/EnumDescriptor.php +++ b/php/src/Google/Protobuf/Internal/EnumDescriptor.php @@ -8,6 +8,7 @@ class EnumDescriptor private $klass; private $full_name; private $value; + private $name_to_value; public function setFullName($full_name) { @@ -22,6 +23,17 @@ class EnumDescriptor public function addValue($number, $value) { $this->value[$number] = $value; + $this->name_to_value[$value->getName()] = $value; + } + + public function getValueByNumber($number) + { + return $this->value[$number]; + } + + public function getValueByName($name) + { + return $this->name_to_value[$name]; } public function setClass($klass) @@ -50,6 +62,10 @@ class EnumDescriptor $fullname); $desc->setFullName($fullname); $desc->setClass($classname); + $values = $proto->getValue(); + foreach ($values as $value) { + $desc->addValue($value->getNumber(), $value); + } return $desc; } diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptor.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptor.php index e65a4e8d..549766e3 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueDescriptor.php +++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptor.php @@ -34,4 +34,26 @@ namespace Google\Protobuf\Internal; class EnumValueDescriptor { + private $name; + private $number; + + public function setName($name) + { + $this->name = $name; + } + + public function getName() + { + return $this->name; + } + + public function setNumber($number) + { + $this->number = $number; + } + + public function getNumber() + { + return $this->number; + } } diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptor.php b/php/src/Google/Protobuf/Internal/FieldDescriptor.php index 6c91950f..f18bf810 100644 --- a/php/src/Google/Protobuf/Internal/FieldDescriptor.php +++ b/php/src/Google/Protobuf/Internal/FieldDescriptor.php @@ -36,6 +36,7 @@ class FieldDescriptor { private $name; + private $json_name; private $setter; private $getter; private $number; @@ -67,6 +68,16 @@ class FieldDescriptor return $this->name; } + public function setJsonName($json_name) + { + $this->json_name = $json_name; + } + + public function getJsonName() + { + return $this->json_name; + } + public function setSetter($setter) { $this->setter = $setter; @@ -172,23 +183,49 @@ class FieldDescriptor $field_type !== GPBType::BYTES); } - public static function getFieldDescriptor( - $name, - $label, - $type, - $number, - $oneof_index, - $packed, - $type_name = null) + public static function getFieldDescriptor($proto) { + $type_name = null; + $type = $proto->getType(); + switch ($type) { + case GPBType::MESSAGE: + case GPBType::GROUP: + case GPBType::ENUM: + $type_name = $proto->getTypeName(); + break; + default: + break; + } + + $oneof_index = $proto->hasOneofIndex() ? $proto->getOneofIndex() : -1; + $packed = false; + $options = $proto->getOptions(); + if ($options !== null) { + $packed = $options->getPacked(); + } + $field = new FieldDescriptor(); - $field->setName($name); - $camel_name = implode('', array_map('ucwords', explode('_', $name))); + $field->setName($proto->getName()); + + $json_name = $proto->hasJsonName() ? $proto->getJsonName() : + lcfirst(implode('', array_map('ucwords', explode('_', $proto->getName())))); + if ($proto->hasJsonName()) { + $json_name = $proto->getJsonName(); + } else { + $proto_name = $proto->getName(); + $json_name = implode('', array_map('ucwords', explode('_', $proto_name))); + if ($proto_name[0] !== "_" && !ctype_upper($proto_name[0])) { + $json_name = lcfirst($json_name); + } + } + $field->setJsonName($json_name); + + $camel_name = implode('', array_map('ucwords', explode('_', $proto->getName()))); $field->setGetter('get' . $camel_name); $field->setSetter('set' . $camel_name); - $field->setType($type); - $field->setNumber($number); - $field->setLabel($label); + $field->setType($proto->getType()); + $field->setNumber($proto->getNumber()); + $field->setLabel($proto->getLabel()); $field->setPacked($packed); $field->setOneofIndex($oneof_index); @@ -211,26 +248,6 @@ class FieldDescriptor public static function buildFromProto($proto) { - $type_name = null; - switch ($proto->getType()) { - case GPBType::MESSAGE: - case GPBType::GROUP: - case GPBType::ENUM: - $type_name = $proto->getTypeName(); - break; - default: - break; - } - - $oneof_index = $proto->hasOneofIndex() ? $proto->getOneofIndex() : -1; - $packed = false; - $options = $proto->getOptions(); - if ($options !== null) { - $packed = $options->getPacked(); - } - - return FieldDescriptor::getFieldDescriptor( - $proto->getName(), $proto->getLabel(), $proto->getType(), - $proto->getNumber(), $oneof_index, $packed, $type_name); + return FieldDescriptor::getFieldDescriptor($proto); } } diff --git a/php/src/Google/Protobuf/Internal/GPBJsonWire.php b/php/src/Google/Protobuf/Internal/GPBJsonWire.php new file mode 100644 index 00000000..97789356 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/GPBJsonWire.php @@ -0,0 +1,285 @@ +writeRaw("\"", 1); + $field_name = GPBJsonWire::formatFieldName($field); + $output->writeRaw($field_name, strlen($field_name)); + $output->writeRaw("\":", 2); + return static::serializeFieldValueToStream($value, $field, $output); + } + + private static function serializeFieldValueToStream( + $values, + $field, + &$output) + { + if ($field->isMap()) { + $output->writeRaw("{", 1); + $first = true; + $map_entry = $field->getMessageType(); + $key_field = $map_entry->getFieldByNumber(1); + $value_field = $map_entry->getFieldByNumber(2); + + switch ($key_field->getType()) { + case GPBType::STRING: + case GPBType::SFIXED64: + case GPBType::INT64: + case GPBType::SINT64: + case GPBType::FIXED64: + case GPBType::UINT64: + $additional_quote = false; + break; + default: + $additional_quote = true; + } + + foreach ($values as $key => $value) { + if ($first) { + $first = false; + } else { + $output->writeRaw(",", 1); + } + if ($additional_quote) { + $output->writeRaw("\"", 1); + } + if (!static::serializeSingularFieldValueToStream( + $key, + $key_field, + $output)) { + return false; + } + if ($additional_quote) { + $output->writeRaw("\"", 1); + } + $output->writeRaw(":", 1); + if (!static::serializeSingularFieldValueToStream( + $value, + $value_field, + $output)) { + return false; + } + } + $output->writeRaw("}", 1); + return true; + } elseif ($field->isRepeated()) { + $output->writeRaw("[", 1); + $first = true; + foreach ($values as $value) { + if ($first) { + $first = false; + } else { + $output->writeRaw(",", 1); + } + if (!static::serializeSingularFieldValueToStream( + $value, + $field, + $output)) { + return false; + } + } + $output->writeRaw("]", 1); + return true; + } else { + return static::serializeSingularFieldValueToStream( + $values, + $field, + $output); + } + } + + private static function serializeSingularFieldValueToStream( + $value, + $field, + &$output) + { + switch ($field->getType()) { + case GPBType::SFIXED32: + case GPBType::SINT32: + case GPBType::INT32: + $str_value = strval($value); + $output->writeRaw($str_value, strlen($str_value)); + break; + case GPBType::FIXED32: + case GPBType::UINT32: + if ($value < 0) { + $value = bcadd($value, "4294967296"); + } + $str_value = strval($value); + $output->writeRaw($str_value, strlen($str_value)); + break; + case GPBType::FIXED64: + case GPBType::UINT64: + if ($value < 0) { + $value = bcadd($value, "18446744073709551616"); + } + // Intentional fall through. + case GPBType::SFIXED64: + case GPBType::INT64: + case GPBType::SINT64: + $output->writeRaw("\"", 1); + $str_value = strval($value); + $output->writeRaw($str_value, strlen($str_value)); + $output->writeRaw("\"", 1); + break; + case GPBType::FLOAT: + if (is_nan($value)) { + $str_value = "\"NaN\""; + } elseif ($value === INF) { + $str_value = "\"Infinity\""; + } elseif ($value === -INF) { + $str_value = "\"-Infinity\""; + } else { + $str_value = sprintf("%.8g", $value); + } + $output->writeRaw($str_value, strlen($str_value)); + break; + case GPBType::DOUBLE: + if (is_nan($value)) { + $str_value = "\"NaN\""; + } elseif ($value === INF) { + $str_value = "\"Infinity\""; + } elseif ($value === -INF) { + $str_value = "\"-Infinity\""; + } else { + $str_value = sprintf("%.17g", $value); + } + $output->writeRaw($str_value, strlen($str_value)); + break; + case GPBType::ENUM: + $enum_desc = $field->getEnumType(); + $enum_value_desc = $enum_desc->getValueByNumber($value); + if (!is_null($enum_value_desc)) { + $str_value = $enum_value_desc->getName(); + $output->writeRaw("\"", 1); + $output->writeRaw($str_value, strlen($str_value)); + $output->writeRaw("\"", 1); + } else { + $str_value = strval($value); + $output->writeRaw($str_value, strlen($str_value)); + } + break; + case GPBType::BOOL: + if ($value) { + $output->writeRaw("true", 4); + } else { + $output->writeRaw("false", 5); + } + break; + case GPBType::BYTES: + $value = base64_encode($value); + case GPBType::STRING: + $value = json_encode($value); + $output->writeRaw($value, strlen($value)); + break; + // case GPBType::GROUP: + // echo "GROUP\xA"; + // trigger_error("Not implemented.", E_ERROR); + // break; + case GPBType::MESSAGE: + $value->serializeToJsonStream($output); + break; + default: + user_error("Unsupported type."); + return false; + } + return true; + } + + private static function formatFieldName($field) + { + return $field->getJsonName(); + } + + // Used for escaping control chars in strings. + private static $k_control_char_limit = 0x20; + + private static function jsonNiceEscape($c) + { + switch ($c) { + case '"': return "\\\""; + case '\\': return "\\\\"; + case '/': return "\\/"; + case '\b': return "\\b"; + case '\f': return "\\f"; + case '\n': return "\\n"; + case '\r': return "\\r"; + case '\t': return "\\t"; + default: return NULL; + } + } + + private static function isJsonEscaped($c) + { + // See RFC 4627. + return $c < chr($k_control_char_limit) || $c === "\"" || $c === "\\"; + } + + public static function escapedJson($value) + { + $escaped_value = ""; + $unescaped_run = ""; + for ($i = 0; $i < strlen($value); $i++) { + $c = $value[$i]; + // Handle escaping. + if (static::isJsonEscaped($c)) { + // Use a "nice" escape, like \n, if one exists for this + // character. + $escape = static::jsonNiceEscape($c); + if (is_null($escape)) { + $escape = "\\u00" . bin2hex($c); + } + if ($unescaped_run !== "") { + $escaped_value .= $unescaped_run; + $unescaped_run = ""; + } + $escaped_value .= $escape; + } else { + if ($unescaped_run === "") { + $unescaped_run .= $c; + } + } + } + $escaped_value .= $unescaped_run; + return $escaped_value; + } + +} diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php index 8c97e9fa..22ad27f9 100644 --- a/php/src/Google/Protobuf/Internal/GPBUtil.php +++ b/php/src/Google/Protobuf/Internal/GPBUtil.php @@ -45,8 +45,13 @@ class GPBUtil $value = bcsub(0, $value); } - $high = (int) bcdiv(bcadd($value, 1), 4294967296); + $high = bcdiv($value, 4294967296); $low = bcmod($value, 4294967296); + if (bccomp($high, 2147483647) > 0) { + $high = (int) bcsub($high, 4294967296); + } else { + $high = (int) $high; + } if (bccomp($low, 2147483647) > 0) { $low = (int) bcsub($low, 4294967296); } else { @@ -58,7 +63,7 @@ class GPBUtil $low = ~$low; $low++; if (!$low) { - $high++; + $high = (int)($high + 1); } } @@ -70,15 +75,13 @@ class GPBUtil public static function checkString(&$var, $check_utf8) { if (is_array($var) || is_object($var)) { - trigger_error("Expect string.", E_USER_ERROR); - return; + throw new \InvalidArgumentException("Expect string."); } if (!is_string($var)) { $var = strval($var); } if ($check_utf8 && !preg_match('//u', $var)) { - trigger_error("Expect utf-8 encoding.", E_USER_ERROR); - return; + throw new \Exception("Expect utf-8 encoding."); } } @@ -92,7 +95,7 @@ class GPBUtil if (is_numeric($var)) { $var = intval($var); } else { - trigger_error("Expect integer.", E_USER_ERROR); + throw new \Exception("Expect integer."); } } @@ -109,7 +112,7 @@ class GPBUtil $var = (int) $var; } } else { - trigger_error("Expect integer.", E_USER_ERROR); + throw new \Exception("Expect integer."); } } @@ -119,10 +122,15 @@ class GPBUtil if (PHP_INT_SIZE == 8) { $var = intval($var); } else { - $var = bcdiv($var, 1, 0); + if (is_float($var) || + is_integer($var) || + (is_string($var) && + bccomp($var, "9223372036854774784") < 0)) { + $var = number_format($var, 0, ".", ""); + } } } else { - trigger_error("Expect integer.", E_USER_ERROR); + throw new \Exception("Expect integer."); } } @@ -132,10 +140,10 @@ class GPBUtil if (PHP_INT_SIZE == 8) { $var = intval($var); } else { - $var = bcdiv($var, 1, 0); + $var = number_format($var, 0, ".", ""); } } else { - trigger_error("Expect integer.", E_USER_ERROR); + throw new \Exception("Expect integer."); } } @@ -144,7 +152,7 @@ class GPBUtil if (is_float($var) || is_numeric($var)) { $var = floatval($var); } else { - trigger_error("Expect float.", E_USER_ERROR); + throw new \Exception("Expect float."); } } @@ -153,15 +161,14 @@ class GPBUtil if (is_float($var) || is_numeric($var)) { $var = floatval($var); } else { - trigger_error("Expect float.", E_USER_ERROR); + throw new \Exception("Expect float."); } } public static function checkBool(&$var) { if (is_array($var) || is_object($var)) { - trigger_error("Expect boolean.", E_USER_ERROR); - return; + throw new \Exception("Expect boolean."); } $var = boolval($var); } @@ -169,14 +176,14 @@ class GPBUtil public static function checkMessage(&$var, $klass) { if (!$var instanceof $klass && !is_null($var)) { - trigger_error("Expect message.", E_USER_ERROR); + throw new \Exception("Expect message."); } } public static function checkRepeatedField(&$var, $type, $klass = null) { if (!$var instanceof RepeatedField && !is_array($var)) { - trigger_error("Expect array.", E_USER_ERROR); + throw new \Exception("Expect array."); } if (is_array($var)) { $tmp = new RepeatedField($type, $klass); @@ -186,15 +193,13 @@ class GPBUtil return $tmp; } else { if ($var->getType() != $type) { - trigger_error( - "Expect repeated field of different type.", - E_USER_ERROR); + throw new \Exception( + "Expect repeated field of different type."); } if ($var->getType() === GPBType::MESSAGE && $var->getClass() !== $klass) { - trigger_error( - "Expect repeated field of different message.", - E_USER_ERROR); + throw new \Exception( + "Expect repeated field of different message."); } return $var; } @@ -203,7 +208,7 @@ class GPBUtil public static function checkMapField(&$var, $key_type, $value_type, $klass = null) { if (!$var instanceof MapField && !is_array($var)) { - trigger_error("Expect dict.", E_USER_ERROR); + throw new \Exception("Expect dict."); } if (is_array($var)) { $tmp = new MapField($key_type, $value_type, $klass); @@ -213,20 +218,15 @@ class GPBUtil return $tmp; } else { if ($var->getKeyType() != $key_type) { - trigger_error( - "Expect map field of key type.", - E_USER_ERROR); + throw new \Exception("Expect map field of key type."); } if ($var->getValueType() != $value_type) { - trigger_error( - "Expect map field of value type.", - E_USER_ERROR); + throw new \Exception("Expect map field of value type."); } if ($var->getValueType() === GPBType::MESSAGE && $var->getValueClass() !== $klass) { - trigger_error( - "Expect map field of different value message.", - E_USER_ERROR); + throw new \Exception( + "Expect map field of different value message."); } return $var; } @@ -328,7 +328,7 @@ class GPBUtil $low = ~$low; $low++; if (!$low) { - $high++; + $high = (int) ($high + 1); } } $result = bcadd(bcmul($high, 4294967296), $low); diff --git a/php/src/Google/Protobuf/Internal/GPBWire.php b/php/src/Google/Protobuf/Internal/GPBWire.php index 67eb1bee..e7eec552 100644 --- a/php/src/Google/Protobuf/Internal/GPBWire.php +++ b/php/src/Google/Protobuf/Internal/GPBWire.php @@ -117,19 +117,12 @@ class GPBWire // << decode << public static function zigZagEncode32($int32) { - // Fill high 32 bits. - if (PHP_INT_SIZE === 8) { - $int32 |= ((($int32 << 32) >> 31) & (0xFFFFFFFF << 32)); + if (PHP_INT_SIZE == 8) { + $trim_int32 = $int32 & 0xFFFFFFFF; + return (($trim_int32 << 1) ^ ($int32 << 32 >> 63)) & 0xFFFFFFFF; + } else { + return ($int32 << 1) ^ ($int32 >> 31); } - - $uint32 = ($int32 << 1) ^ ($int32 >> 31); - - // Fill high 32 bits. - if (PHP_INT_SIZE === 8) { - $uint32 |= ((($uint32 << 32) >> 31) & (0xFFFFFFFF << 32)); - } - - return $uint32; } public static function zigZagDecode32($uint32) @@ -177,7 +170,11 @@ class GPBWire public static function readInt64(&$input, &$value) { - return $input->readVarint64($value); + $success = $input->readVarint64($value); + if (PHP_INT_SIZE == 4 && bccomp($value, "9223372036854775807") > 0) { + $value = bcsub($value, "18446744073709551616"); + } + return $success; } public static function readUint32(&$input, &$value) @@ -231,7 +228,11 @@ class GPBWire public static function readSfixed64(&$input, &$value) { - return $input->readLittleEndian64($value); + $success = $input->readLittleEndian64($value); + if (PHP_INT_SIZE == 4 && bccomp($value, "9223372036854775807") > 0) { + $value = bcsub($value, "18446744073709551616"); + } + return $success; } public static function readFloat(&$input, &$value) @@ -298,7 +299,7 @@ class GPBWire public static function writeInt32(&$output, $value) { - return $output->writeVarint32($value); + return $output->writeVarint32($value, false); } public static function writeInt64(&$output, $value) @@ -308,7 +309,7 @@ class GPBWire public static function writeUint32(&$output, $value) { - return $output->writeVarint32($value); + return $output->writeVarint32($value, true); } public static function writeUint64(&$output, $value) @@ -319,7 +320,7 @@ class GPBWire public static function writeSint32(&$output, $value) { $value = GPBWire::zigZagEncode32($value); - return $output->writeVarint64($value); + return $output->writeVarint32($value, true); } public static function writeSint64(&$output, $value) @@ -351,9 +352,9 @@ class GPBWire public static function writeBool(&$output, $value) { if ($value) { - return $output->writeVarint32(1); + return $output->writeVarint32(1, true); } else { - return $output->writeVarint32(0); + return $output->writeVarint32(0, true); } } @@ -377,7 +378,7 @@ class GPBWire public static function writeBytes(&$output, $value) { $size = strlen($value); - if (!$output->writeVarint32($size)) { + if (!$output->writeVarint32($size, true)) { return false; } return $output->writeRaw($value, $size); @@ -386,7 +387,7 @@ class GPBWire public static function writeMessage(&$output, $value) { $size = $value->byteSize(); - if (!$output->writeVarint32($size)) { + if (!$output->writeVarint32($size, true)) { return false; } return $value->serializeToStream($output); @@ -442,7 +443,8 @@ class GPBWire public static function varint64Size($value) { if (PHP_INT_SIZE == 4) { - if (bccomp($value, 0) < 0) { + if (bccomp($value, 0) < 0 || + bccomp($value, "9223372036854775807") > 0) { return 10; } if (bccomp($value, 1 << 7) < 0) { @@ -578,6 +580,9 @@ class GPBWire } break; case GPBType::UINT32: + if (PHP_INT_SIZE === 8 && $value < 0) { + $value += 4294967296; + } if (!GPBWire::writeUint32($output, $value)) { return false; } diff --git a/php/src/Google/Protobuf/Internal/GPBWireType.php b/php/src/Google/Protobuf/Internal/GPBWireType.php new file mode 100644 index 00000000..c1ad370e --- /dev/null +++ b/php/src/Google/Protobuf/Internal/GPBWireType.php @@ -0,0 +1,43 @@ +buffer = $buffer; - $this->buffer_size_after_limit = 0; - $this->buffer_end = $end; - $this->current = $start; - $this->current_limit = $end; - $this->legitimate_message_end = false; - $this->recursion_budget = self::DEFAULT_RECURSION_LIMIT; - $this->recursion_limit = self::DEFAULT_RECURSION_LIMIT; - $this->total_bytes_limit = self::DEFAULT_TOTAL_BYTES_LIMIT; - $this->total_bytes_read = $end - $start; - } - - private function advance($amount) - { - $this->current += $amount; - } - - private function bufferSize() - { - return $this->buffer_end - $this->current; - } - - private function current() - { - return $this->total_bytes_read - - ($this->buffer_end - $this->current + - $this->buffer_size_after_limit); - } - - private function recomputeBufferLimits() - { - $this->buffer_end += $this->buffer_size_after_limit; - $closest_limit = min($this->current_limit, $this->total_bytes_limit); - if ($closest_limit < $this->total_bytes_read) { - // The limit position is in the current buffer. We must adjust the - // buffer size accordingly. - $this->buffer_size_after_limit = $this->total_bytes_read - - $closest_limit; - $this->buffer_end -= $this->buffer_size_after_limit; - } else { - $this->buffer_size_after_limit = 0; - } - } - - private function consumedEntireMessage() - { - return $this->legitimate_message_end; - } - - /** - * Read uint32 into $var. Advance buffer with consumed bytes. If the - * contained varint is larger than 32 bits, discard the high order bits. - * @param $var. - */ - public function readVarint32(&$var) - { - if (!$this->readVarint64($var)) { - return false; - } - - if (PHP_INT_SIZE == 4) { - $var = bcmod($var, 4294967296); - } else { - $var &= 0xFFFFFFFF; - } - - // Convert large uint32 to int32. - if ($var > 0x7FFFFFFF) { - if (PHP_INT_SIZE === 8) { - $var = $var | (0xFFFFFFFF << 32); - } else { - $var = bcsub($var, 4294967296); - } - } - - $var = intval($var); - return true; - } - - /** - * Read Uint64 into $var. Advance buffer with consumed bytes. - * @param $var. - */ - public function readVarint64(&$var) - { - $count = 0; - - if (PHP_INT_SIZE == 4) { - $high = 0; - $low = 0; - $b = 0; - - do { - if ($this->current === $this->buffer_end) { - return false; - } - if ($count === self::MAX_VARINT_BYTES) { - return false; - } - $b = ord($this->buffer[$this->current]); - $bits = 7 * $count; - if ($bits >= 32) { - $high |= (($b & 0x7F) << ($bits - 32)); - } else if ($bits > 25){ - // $bits is 28 in this case. - $low |= (($b & 0x7F) << 28); - $high = ($b & 0x7F) >> 4; - } else { - $low |= (($b & 0x7F) << $bits); - } - - $this->advance(1); - $count += 1; - } while ($b & 0x80); - - $var = GPBUtil::combineInt32ToInt64($high, $low); - } else { - $result = 0; - $shift = 0; - - do { - if ($this->current === $this->buffer_end) { - return false; - } - if ($count === self::MAX_VARINT_BYTES) { - return false; - } - - $byte = ord($this->buffer[$this->current]); - $result |= ($byte & 0x7f) << $shift; - $shift += 7; - $this->advance(1); - $count += 1; - } while ($byte > 0x7f); - - $var = $result; - } - - return true; - } - - /** - * Read int into $var. If the result is larger than the largest integer, $var - * will be -1. Advance buffer with consumed bytes. - * @param $var. - */ - public function readVarintSizeAsInt(&$var) - { - if (!$this->readVarint64($var)) { - return false; - } - $var = (int)$var; - return true; - } - - /** - * Read 32-bit unsiged integer to $var. If the buffer has less than 4 bytes, - * return false. Advance buffer with consumed bytes. - * @param $var. - */ - public function readLittleEndian32(&$var) - { - $data = null; - if (!$this->readRaw(4, $data)) { - return false; - } - $var = unpack('V', $data); - $var = $var[1]; - return true; - } - - /** - * Read 64-bit unsiged integer to $var. If the buffer has less than 8 bytes, - * return false. Advance buffer with consumed bytes. - * @param $var. - */ - public function readLittleEndian64(&$var) - { - $data = null; - if (!$this->readRaw(4, $data)) { - return false; - } - $low = unpack('V', $data)[1]; - if (!$this->readRaw(4, $data)) { - return false; - } - $high = unpack('V', $data)[1]; - if (PHP_INT_SIZE == 4) { - $var = GPBUtil::combineInt32ToInt64($high, $low); - } else { - $var = ($high << 32) | $low; - } - return true; - } - - /** - * Read tag into $var. Advance buffer with consumed bytes. - * @param $var. - */ - public function readTag() - { - if ($this->current === $this->buffer_end) { - // Make sure that it failed due to EOF, not because we hit - // total_bytes_limit, which, unlike normal limits, is not a valid - // place to end a message. - $current_position = $this->total_bytes_read - - $this->buffer_size_after_limit; - if ($current_position >= $this->total_bytes_limit) { - // Hit total_bytes_limit_. But if we also hit the normal limit, - // we're still OK. - $this->legitimate_message_end = - ($this->current_limit === $this->total_bytes_limit); - } else { - $this->legitimate_message_end = true; - } - return 0; - } - - $result = 0; - // The larget tag is 2^29 - 1, which can be represented by int32. - $success = $this->readVarint32($result); - if ($success) { - return $result; - } else { - return 0; - } - } - - public function readRaw($size, &$buffer) - { - $current_buffer_size = 0; - if ($this->bufferSize() < $size) { - return false; - } - - $buffer = substr($this->buffer, $this->current, $size); - $this->advance($size); - - return true; - } - - /* Places a limit on the number of bytes that the stream may read, starting - * from the current position. Once the stream hits this limit, it will act - * like the end of the input has been reached until popLimit() is called. - * - * As the names imply, the stream conceptually has a stack of limits. The - * shortest limit on the stack is always enforced, even if it is not the top - * limit. - * - * The value returned by pushLimit() is opaque to the caller, and must be - * passed unchanged to the corresponding call to popLimit(). - * - * @param integer $byte_limit - * @throws Exception Fail to push limit. - */ - public function pushLimit($byte_limit) - { - // Current position relative to the beginning of the stream. - $current_position = $this->current(); - $old_limit = $this->current_limit; - - // security: byte_limit is possibly evil, so check for negative values - // and overflow. - if ($byte_limit >= 0 && - $byte_limit <= PHP_INT_MAX - $current_position && - $byte_limit <= $this->current_limit - $current_position) { - $this->current_limit = $current_position + $byte_limit; - $this->recomputeBufferLimits(); - } else { - throw new GPBDecodeException("Fail to push limit."); - } - - return $old_limit; - } - - /* The limit passed in is actually the *old* limit, which we returned from - * PushLimit(). - * - * @param integer $byte_limit - */ - public function popLimit($byte_limit) - { - $this->current_limit = $byte_limit; - $this->recomputeBufferLimits(); - // We may no longer be at a legitimate message end. ReadTag() needs to - // be called again to find out. - $this->legitimate_message_end = false; - } - - public function incrementRecursionDepthAndPushLimit( - $byte_limit, &$old_limit, &$recursion_budget) - { - $old_limit = $this->pushLimit($byte_limit); - $recursion_limit = --$this->recursion_limit; - } - - public function decrementRecursionDepthAndPopLimit($byte_limit) - { - $result = $this->consumedEntireMessage(); - $this->popLimit($byte_limit); - ++$this->recursion_budget; - return $result; - } - - public function bytesUntilLimit() - { - if ($this->current_limit === PHP_INT_MAX) { - return -1; - } - return $this->current_limit - $this->current; - } -} diff --git a/php/src/Google/Protobuf/Internal/MapField.php b/php/src/Google/Protobuf/Internal/MapField.php index 12f09d61..38736dad 100644 --- a/php/src/Google/Protobuf/Internal/MapField.php +++ b/php/src/Google/Protobuf/Internal/MapField.php @@ -205,7 +205,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable */ public function getIterator() { - return new MapFieldIter($this->container); + return new MapFieldIter($this->container, $this->key_type); } /** diff --git a/php/src/Google/Protobuf/Internal/MapFieldIter.php b/php/src/Google/Protobuf/Internal/MapFieldIter.php index a0388d92..cb707955 100644 --- a/php/src/Google/Protobuf/Internal/MapFieldIter.php +++ b/php/src/Google/Protobuf/Internal/MapFieldIter.php @@ -54,11 +54,13 @@ class MapFieldIter implements \Iterator * * @param MapField The MapField instance for which this iterator is * created. + * @param GPBType Map key type. * @ignore */ - public function __construct($container) + public function __construct($container, $key_type) { $this->container = $container; + $this->key_type = $key_type; } /** @@ -88,7 +90,13 @@ class MapFieldIter implements \Iterator */ public function key() { - return key($this->container); + $key = key($this->container); + // PHP associative array stores bool as integer for key. + if ($this->key_type === GPBType::BOOL) { + return boolval($key); + } else { + return $key; + } } /** @@ -110,4 +118,4 @@ class MapFieldIter implements \Iterator { return key($this->container) !== null; } -} \ No newline at end of file +} diff --git a/php/src/Google/Protobuf/Internal/Message.php b/php/src/Google/Protobuf/Internal/Message.php index 9ba249a0..1ecd4fa2 100644 --- a/php/src/Google/Protobuf/Internal/Message.php +++ b/php/src/Google/Protobuf/Internal/Message.php @@ -36,8 +36,8 @@ namespace Google\Protobuf\Internal; -use Google\Protobuf\Internal\InputStream; -use Google\Protobuf\Internal\OutputStream; +use Google\Protobuf\Internal\CodedInputStream; +use Google\Protobuf\Internal\CodedOutputStream; use Google\Protobuf\Internal\DescriptorPool; use Google\Protobuf\Internal\GPBLabel; use Google\Protobuf\Internal\GPBType; @@ -68,6 +68,10 @@ class Message // specific descriptor from the descriptor pool. if (get_class($this) === 'Google\Protobuf\Internal\MapEntry') { $this->desc = $desc; + foreach ($desc->getField() as $field) { + $setter = $field->getSetter(); + $this->$setter($this->defaultValue($field)); + } return; } $pool = DescriptorPool::getGeneratedPool(); @@ -216,6 +220,58 @@ class Message } } + /** + * @ignore + */ + private static function skipField($input, $tag) + { + $number = GPBWire::getTagFieldNumber($tag); + if ($number === 0) { + throw new GPBDecodeException("Illegal field number zero."); + } + + switch (GPBWire::getTagWireType($tag)) { + case GPBWireType::VARINT: + $uint64 = 0; + if (!$input->readVarint64($uint64)) { + throw new GPBDecodeException( + "Unexpected EOF inside varint."); + } + return; + case GPBWireType::FIXED64: + $uint64 = 0; + if (!$input->readLittleEndian64($uint64)) { + throw new GPBDecodeException( + "Unexpected EOF inside fixed64."); + } + return; + case GPBWireType::FIXED32: + $uint32 = 0; + if (!$input->readLittleEndian32($uint32)) { + throw new GPBDecodeException( + "Unexpected EOF inside fixed32."); + } + return; + case GPBWireType::LENGTH_DELIMITED: + $length = 0; + if (!$input->readVarint32($length)) { + throw new GPBDecodeException( + "Unexpected EOF inside length."); + } + $data = NULL; + if (!$input->readRaw($length, $data)) { + throw new GPBDecodeException( + "Unexpected EOF inside length delimited data."); + } + return; + case GPBWireType::START_GROUP: + case GPBWireType::END_GROUP: + throw new GPBDecodeException("Unexpected wire type."); + default: + throw new GPBDecodeException("Unexpected wire type."); + } + } + /** * @ignore */ @@ -278,7 +334,6 @@ class Message } break; case GPBType::GROUP: - echo "GROUP\xA"; trigger_error("Not implemented.", E_ERROR); break; case GPBType::MESSAGE: @@ -349,19 +404,25 @@ class Message private function parseFieldFromStream($tag, $input, $field) { $value = null; - $field_type = $field->getType(); - $value_format = GPBWire::UNKNOWN; - if (GPBWire::getTagWireType($tag) === - GPBWire::getWireType($field_type)) { + if (is_null($field)) { + $value_format = GPBWire::UNKNOWN; + } elseif (GPBWire::getTagWireType($tag) === + GPBWire::getWireType($field->getType())) { $value_format = GPBWire::NORMAL_FORMAT; } elseif ($field->isPackable() && GPBWire::getTagWireType($tag) === GPBWire::WIRETYPE_LENGTH_DELIMITED) { $value_format = GPBWire::PACKED_FORMAT; + } else { + // the wire type doesn't match. Put it in our unknown field set. + $value_format = GPBWire::UNKNOWN; } - if ($value_format === GPBWire::NORMAL_FORMAT) { + if ($value_format === GPBWire::UNKNOWN) { + self::skipField($input, $tag); + return; + } elseif ($value_format === GPBWire::NORMAL_FORMAT) { self::parseFieldFromStreamNoTag($input, $field, $value); } elseif ($value_format === GPBWire::PACKED_FORMAT) { $length = 0; @@ -378,7 +439,7 @@ class Message $input->popLimit($limit); return; } else { - return false; + return; } if ($field->isMap()) { @@ -583,10 +644,28 @@ class Message */ public function mergeFromString($data) { - $input = new InputStream($data); + $input = new CodedInputStream($data); $this->parseFromStream($input); } + /** + * Parses a json string to protobuf message. + * + * This function takes a string in the json wire format, matching the + * encoding output by serializeToJsonString(). + * See mergeFrom() for merging behavior, if the field is already set in the + * specified message. + * + * @param string $data Json protobuf data. + * @return null. + * @throws Exception Invalid data. + */ + public function mergeFromJsonString($data) + { + $input = new RawInputStream($data); + $this->parseFromJsonStream($input); + } + /** * @ignore */ @@ -602,12 +681,233 @@ class Message $number = GPBWire::getTagFieldNumber($tag); $field = $this->desc->getFieldByNumber($number); - // Check whether we retrieved a known field - if ($field === NULL) { - continue; + $this->parseFieldFromStream($tag, $input, $field); + } + } + + private function convertJsonValueToProtoValue( + $value, + $field, + $is_map_key = false) + { + if (is_null($value)) { + return $this->defaultValue($field); + } + switch ($field->getType()) { + case GPBType::MESSAGE: + $klass = $field->getMessageType()->getClass(); + if (!is_object($value) && !is_array($value)) { + throw new \Exception("Expect message."); + } + $submsg = new $klass; + if (!is_null($value) && + $klass !== "Google\Protobuf\Any") { + $submsg->mergeFromJsonArray($value); + } + return $submsg; + case GPBType::ENUM: + if (is_integer($value)) { + return $value; + } else { + $enum_value = + $field->getEnumType()->getValueByName($value); + } + if (!is_null($enum_value)) { + return $enum_value->getNumber(); + } + case GPBType::STRING: + if (!is_string($value)) { + throw new GPBDecodeException("Expect string"); + } + return $value; + case GPBType::BYTES: + if (!is_string($value)) { + throw new GPBDecodeException("Expect string"); + } + $proto_value = base64_decode($value, true); + if ($proto_value === false) { + throw new GPBDecodeException( + "Invalid base64 characters"); + } + return $proto_value; + case GPBType::BOOL: + if ($is_map_key) { + if ($value === "true") { + return true; + } + if ($value === "false") { + return false; + } + throw new GPBDecodeException( + "Bool field only accept bool value"); + } + if (!is_bool($value)) { + throw new GPBDecodeException( + "Bool field only accept bool value"); + } + return $value; + case GPBType::FLOAT: + if ($value === "Infinity") { + return INF; + } + if ($value === "-Infinity") { + return -INF; + } + if ($value === "NaN") { + return NAN; + } + return $value; + case GPBType::DOUBLE: + if ($value === "Infinity") { + return INF; + } + if ($value === "-Infinity") { + return -INF; + } + if ($value === "NaN") { + return NAN; + } + return $value; + case GPBType::INT32: + if (!is_numeric($value)) { + throw new GPBDecodeException( + "Invalid data type for int32 field"); + } + if (bccomp($value, "2147483647") > 0) { + throw new GPBDecodeException( + "Int32 too large"); + } + if (bccomp($value, "-2147483648") < 0) { + throw new GPBDecodeException( + "Int32 too small"); + } + return $value; + case GPBType::UINT32: + if (!is_numeric($value)) { + throw new GPBDecodeException( + "Invalid data type for uint32 field"); + } + if (bccomp($value, 4294967295) > 0) { + throw new GPBDecodeException( + "Uint32 too large"); + } + return $value; + case GPBType::INT64: + if (!is_numeric($value)) { + throw new GPBDecodeException( + "Invalid data type for int64 field"); + } + if (bccomp($value, "9223372036854775807") > 0) { + throw new GPBDecodeException( + "Int64 too large"); + } + if (bccomp($value, "-9223372036854775808") < 0) { + throw new GPBDecodeException( + "Int64 too small"); + } + return $value; + case GPBType::UINT64: + if (!is_numeric($value)) { + throw new GPBDecodeException( + "Invalid data type for int64 field"); + } + if (bccomp($value, "18446744073709551615") > 0) { + throw new GPBDecodeException( + "Uint64 too large"); + } + if (bccomp($value, "9223372036854775807") > 0) { + $value = bcsub($value, "18446744073709551616"); + } + return $value; + case GPBType::FIXED64: + return $value; + default: + return $value; + } + } + + private function mergeFromJsonArray($array) + { + foreach ($array as $key => $value) { + $field = $this->desc->getFieldByJsonName($key); + if (is_null($field)) { + $field = $this->desc->getFieldByName($key); + if (is_null($field)) { + continue; + } + } + $setter = $field->getSetter(); + if ($field->isMap()) { + if (is_null($value)) { + continue; + } + $getter = $field->getGetter(); + $key_field = $field->getMessageType()->getFieldByNumber(1); + $value_field = $field->getMessageType()->getFieldByNumber(2); + foreach ($value as $tmp_key => $tmp_value) { + if (is_null($tmp_value)) { + throw new \Exception( + "Map value field element cannot be null."); + } + $proto_key = + $this->convertJsonValueToProtoValue( + $tmp_key, + $key_field, + true); + $proto_value = + $this->convertJsonValueToProtoValue( + $tmp_value, + $value_field); + $this->$getter()[$proto_key] = $proto_value; + } + } else if ($field->isRepeated()) { + if (is_null($value)) { + continue; + } + $getter = $field->getGetter(); + foreach ($value as $tmp) { + if (is_null($tmp)) { + throw new \Exception( + "Repeated field elements cannot be null."); + } + $proto_value = + $this->convertJsonValueToProtoValue($tmp, $field); + $this->$getter()[] = $proto_value; + } + } else { + $setter = $field->getSetter(); + $proto_value = + $this->convertJsonValueToProtoValue($value, $field); + if ($field->getType() === GPBType::MESSAGE) { + if (is_null($proto_value)) { + continue; + } + $getter = $field->getGetter(); + $submsg = $this->$getter(); + if (!is_null($submsg)) { + $submsg->mergeFrom($proto_value); + continue; + } + } + $this->$setter($proto_value); } + } + } - $this->parseFieldFromStream($tag, $input, $field); + /** + * @ignore + */ + public function parseFromJsonStream($input) + { + $array = json_decode($input->getData(), JSON_BIGINT_AS_STRING); + if (is_null($array)) { + throw new GPBDecodeException( + "Cannot decode json string."); + } + try { + $this->mergeFromJsonArray($array); + } catch (Exception $e) { + throw new GPBDecodeException($e->getMessage()); } } @@ -650,7 +950,7 @@ class Message foreach ($values as $value) { $size += $this->fieldDataOnlyByteSize($field, $value); } - if (!$output->writeVarint32($size)) { + if (!$output->writeVarint32($size, true)) { return false; } } @@ -708,6 +1008,16 @@ class Message } } + /** + * @ignore + */ + private function serializeFieldToJsonStream(&$output, $field) + { + $getter = $field->getGetter(); + $values = $this->$getter(); + return GPBJsonWire::serializeFieldToStream($values, $field, $output); + } + /** * @ignore */ @@ -722,17 +1032,52 @@ class Message return true; } + /** + * @ignore + */ + public function serializeToJsonStream(&$output) + { + $output->writeRaw("{", 1); + $fields = $this->desc->getField(); + $first = true; + foreach ($fields as $field) { + if ($this->existField($field)) { + if ($first) { + $first = false; + } else { + $output->writeRaw(",", 1); + } + if (!$this->serializeFieldToJsonStream($output, $field)) { + return false; + } + } + } + $output->writeRaw("}", 1); + return true; + } + /** * Serialize the message to string. * @return string Serialized binary protobuf data. */ public function serializeToString() { - $output = new OutputStream($this->byteSize()); + $output = new CodedOutputStream($this->byteSize()); $this->serializeToStream($output); return $output->getData(); } + /** + * Serialize the message to json string. + * @return string Serialized json protobuf data. + */ + public function serializeToJsonString() + { + $output = new CodedOutputStream($this->jsonByteSize()); + $this->serializeToJsonStream($output); + return $output->getData(); + } + /** * @ignore */ @@ -746,8 +1091,14 @@ class Message } $getter = $field->getGetter(); - $value = $this->$getter(); - return $value !== $this->defaultValue($field); + $values = $this->$getter(); + if ($field->isMap()) { + return count($values) !== 0; + } elseif ($field->isRepeated()) { + return count($values) !== 0; + } else { + return $values !== $this->defaultValue($field); + } } /** @@ -827,6 +1178,101 @@ class Message return $size; } + /** + * @ignore + */ + private function fieldDataOnlyJsonByteSize($field, $value) + { + $size = 0; + + switch ($field->getType()) { + case GPBType::SFIXED32: + case GPBType::SINT32: + case GPBType::INT32: + $size += strlen(strval($value)); + break; + case GPBType::FIXED32: + case GPBType::UINT32: + if ($value < 0) { + $value = bcadd($value, "4294967296"); + } + $size += strlen(strval($value)); + break; + case GPBType::FIXED64: + case GPBType::UINT64: + if ($value < 0) { + $value = bcadd($value, "18446744073709551616"); + } + // Intentional fall through. + case GPBType::SFIXED64: + case GPBType::INT64: + case GPBType::SINT64: + $size += 2; // size for "" + $size += strlen(strval($value)); + break; + case GPBType::FLOAT: + if (is_nan($value)) { + $size += strlen("NaN") + 2; + } elseif ($value === INF) { + $size += strlen("Infinity") + 2; + } elseif ($value === -INF) { + $size += strlen("-Infinity") + 2; + } else { + $size += strlen(sprintf("%.8g", $value)); + } + break; + case GPBType::DOUBLE: + if (is_nan($value)) { + $size += strlen("NaN") + 2; + } elseif ($value === INF) { + $size += strlen("Infinity") + 2; + } elseif ($value === -INF) { + $size += strlen("-Infinity") + 2; + } else { + $size += strlen(sprintf("%.17g", $value)); + } + break; + case GPBType::ENUM: + $enum_desc = $field->getEnumType(); + $enum_value_desc = $enum_desc->getValueByNumber($value); + if (!is_null($enum_value_desc)) { + $size += 2; // size for "" + $size += strlen($enum_value_desc->getName()); + } else { + $str_value = strval($value); + $size += strlen($str_value); + } + break; + case GPBType::BOOL: + if ($value) { + $size += 4; + } else { + $size += 5; + } + break; + case GPBType::STRING: + $value = json_encode($value); + $size += strlen($value); + break; + case GPBType::BYTES: + $size += strlen(base64_encode($value)); + $size += 2; // size for \"\" + break; + case GPBType::MESSAGE: + $size += $value->jsonByteSize(); + break; +# case GPBType::GROUP: +# // TODO(teboring): Add support. +# user_error("Unsupported type."); +# break; + default: + user_error("Unsupported type " . $field->getType()); + return 0; + } + + return $size; + } + /** * @ignore */ @@ -844,12 +1290,18 @@ class Message $value_field = $message_type->getFieldByNumber(2); foreach ($values as $key => $value) { $data_size = 0; - $data_size += $this->fieldDataOnlyByteSize($key_field, $key); - $data_size += $this->fieldDataOnlyByteSize( - $value_field, - $value); - $data_size += GPBWire::tagSize($key_field); - $data_size += GPBWire::tagSize($value_field); + if ($key != $this->defaultValue($key_field)) { + $data_size += $this->fieldDataOnlyByteSize( + $key_field, + $key); + $data_size += GPBWire::tagSize($key_field); + } + if ($value != $this->defaultValue($value_field)) { + $data_size += $this->fieldDataOnlyByteSize( + $value_field, + $value); + $data_size += GPBWire::tagSize($value_field); + } $size += GPBWire::varint32Size($data_size) + $data_size; } } @@ -882,6 +1334,68 @@ class Message return $size; } + /** + * @ignore + */ + private function fieldJsonByteSize($field) + { + $size = 0; + if ($field->isMap()) { + $getter = $field->getGetter(); + $values = $this->$getter(); + $count = count($values); + if ($count !== 0) { + $size += 5; // size for "\"\":{}". + $size += strlen($field->getJsonName()); // size for field name + $size += $count - 1; // size for commas + $getter = $field->getGetter(); + $map_entry = $field->getMessageType(); + $key_field = $map_entry->getFieldByNumber(1); + $value_field = $map_entry->getFieldByNumber(2); + switch ($key_field->getType()) { + case GPBType::STRING: + case GPBType::SFIXED64: + case GPBType::INT64: + case GPBType::SINT64: + case GPBType::FIXED64: + case GPBType::UINT64: + $additional_quote = false; + break; + default: + $additional_quote = true; + } + foreach ($values as $key => $value) { + if ($additional_quote) { + $size += 2; // size for "" + } + $size += $this->fieldDataOnlyJsonByteSize($key_field, $key); + $size += $this->fieldDataOnlyJsonByteSize($value_field, $value); + $size += 1; // size for : + } + } + } elseif ($field->isRepeated()) { + $getter = $field->getGetter(); + $values = $this->$getter(); + $count = count($values); + if ($count !== 0) { + $size += 5; // size for "\"\":[]". + $size += strlen($field->getJsonName()); // size for field name + $size += $count - 1; // size for commas + $getter = $field->getGetter(); + foreach ($values as $value) { + $size += $this->fieldDataOnlyJsonByteSize($field, $value); + } + } + } elseif ($this->existField($field)) { + $size += 3; // size for "\"\":". + $size += strlen($field->getJsonName()); // size for field name + $getter = $field->getGetter(); + $value = $this->$getter(); + $size += $this->fieldDataOnlyJsonByteSize($field, $value); + } + return $size; + } + /** * @ignore */ @@ -921,4 +1435,28 @@ class Message $this->$setter($field_arr_value); } } + + /** + * @ignore + */ + public function jsonByteSize() + { + $size = 0; + + // Size for "{}". + $size += 2; + + $fields = $this->desc->getField(); + $count = 0; + foreach ($fields as $field) { + $field_size = $this->fieldJsonByteSize($field); + $size += $field_size; + if ($field_size != 0) { + $count++; + } + } + // size for comma + $size += $count > 0 ? ($count - 1) : 0; + return $size; + } } diff --git a/php/src/Google/Protobuf/Internal/OutputStream.php b/php/src/Google/Protobuf/Internal/OutputStream.php deleted file mode 100644 index 8c6d9b68..00000000 --- a/php/src/Google/Protobuf/Internal/OutputStream.php +++ /dev/null @@ -1,159 +0,0 @@ -current = 0; - $this->buffer_size = $size; - $this->buffer = str_repeat(chr(0), $this->buffer_size); - } - - public function getData() - { - return $this->buffer; - } - - public function writeVarint32($value) - { - $bytes = str_repeat(chr(0), self::MAX_VARINT64_BYTES); - $size = self::writeVarintToArray($value, $bytes); - return $this->writeRaw($bytes, $size); - } - - public function writeVarint64($value) - { - $bytes = str_repeat(chr(0), self::MAX_VARINT64_BYTES); - $size = self::writeVarintToArray($value, $bytes); - return $this->writeRaw($bytes, $size); - } - - public function writeLittleEndian32($value) - { - $bytes = str_repeat(chr(0), 4); - $size = self::writeLittleEndian32ToArray($value, $bytes); - return $this->writeRaw($bytes, $size); - } - - public function writeLittleEndian64($value) - { - $bytes = str_repeat(chr(0), 8); - $size = self::writeLittleEndian64ToArray($value, $bytes); - return $this->writeRaw($bytes, $size); - } - - public function writeTag($tag) - { - return $this->writeVarint32($tag); - } - - public function writeRaw($data, $size) - { - if ($this->buffer_size < $size) { - trigger_error("Output stream doesn't have enough buffer."); - return false; - } - - for ($i = 0; $i < $size; $i++) { - $this->buffer[$this->current] = $data[$i]; - $this->current++; - $this->buffer_size--; - } - return true; - } - - private static function writeVarintToArray($value, &$buffer) - { - $current = 0; - - $high = 0; - $low = 0; - if (PHP_INT_SIZE == 4) { - GPBUtil::divideInt64ToInt32($value, $high, $low); - } else { - $low = $value; - } - - while ($low >= 0x80 || $low < 0) { - $buffer[$current] = chr($low | 0x80); - $value = ($value >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7)); - $carry = ($high & 0x7F) << ((PHP_INT_SIZE << 3) - 7); - $high = ($high >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7)); - $low = (($low >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7)) | $carry); - $current++; - } - $buffer[$current] = chr($low); - return $current + 1; - } - - private static function writeLittleEndian32ToArray($value, &$buffer) - { - $buffer[0] = chr($value & 0x000000FF); - $buffer[1] = chr(($value >> 8) & 0x000000FF); - $buffer[2] = chr(($value >> 16) & 0x000000FF); - $buffer[3] = chr(($value >> 24) & 0x000000FF); - return 4; - } - - private static function writeLittleEndian64ToArray($value, &$buffer) - { - $high = 0; - $low = 0; - if (PHP_INT_SIZE == 4) { - GPBUtil::divideInt64ToInt32($value, $high, $low); - } else { - $low = $value & 0xFFFFFFFF; - $high = ($value >> 32) & 0xFFFFFFFF; - } - - $buffer[0] = chr($low & 0x000000FF); - $buffer[1] = chr(($low >> 8) & 0x000000FF); - $buffer[2] = chr(($low >> 16) & 0x000000FF); - $buffer[3] = chr(($low >> 24) & 0x000000FF); - $buffer[4] = chr($high & 0x000000FF); - $buffer[5] = chr(($high >> 8) & 0x000000FF); - $buffer[6] = chr(($high >> 16) & 0x000000FF); - $buffer[7] = chr(($high >> 24) & 0x000000FF); - return 8; - } - -} diff --git a/php/src/Google/Protobuf/Internal/RawInputStream.php b/php/src/Google/Protobuf/Internal/RawInputStream.php new file mode 100644 index 00000000..4e7ed5cb --- /dev/null +++ b/php/src/Google/Protobuf/Internal/RawInputStream.php @@ -0,0 +1,50 @@ +buffer = $buffer; + } + + public function getData() + { + return $this->buffer; + } + +} diff --git a/php/tests/array_test.php b/php/tests/array_test.php index b55408da..271389ba 100644 --- a/php/tests/array_test.php +++ b/php/tests/array_test.php @@ -19,23 +19,23 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::INT32); // Test append. - $arr []= MAX_INT32; + $arr[] = MAX_INT32; $this->assertSame(MAX_INT32, $arr[0]); - $arr []= MIN_INT32; + $arr[] = MIN_INT32; $this->assertSame(MIN_INT32, $arr[1]); - $arr []= 1.1; + $arr[] = 1.1; $this->assertSame(1, $arr[2]); - $arr []= MAX_INT32_FLOAT; + $arr[] = MAX_INT32_FLOAT; $this->assertSame(MAX_INT32, $arr[3]); - $arr []= MAX_INT32_FLOAT; + $arr[] = MAX_INT32_FLOAT; $this->assertSame(MAX_INT32, $arr[4]); - $arr []= '2'; + $arr[] = '2'; $this->assertSame(2, $arr[5]); - $arr []= '3.1'; + $arr[] = '3.1'; $this->assertSame(3, $arr[6]); - $arr []= MAX_INT32_STRING; + $arr[] = MAX_INT32_STRING; $this->assertSame(MAX_INT32, $arr[7]); $this->assertEquals(8, count($arr)); @@ -46,29 +46,29 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= MAX_INT32; + $arr[0] = MAX_INT32; $this->assertSame(MAX_INT32, $arr[0]); - $arr [1]= MIN_INT32; + $arr[1] = MIN_INT32; $this->assertSame(MIN_INT32, $arr[1]); - $arr [2]= 1.1; + $arr[2] = 1.1; $this->assertSame(1, $arr[2]); - $arr [3]= MAX_INT32_FLOAT; + $arr[3] = MAX_INT32_FLOAT; $this->assertSame(MAX_INT32, $arr[3]); - $arr [4]= MAX_INT32_FLOAT; + $arr[4] = MAX_INT32_FLOAT; $this->assertSame(MAX_INT32, $arr[4]); - $arr [5]= '2'; + $arr[5] = '2'; $this->assertSame(2, $arr[5]); - $arr [6]= '3.1'; + $arr[6] = '3.1'; $this->assertSame(3, $arr[6]); - $arr [7]= MAX_INT32_STRING; + $arr[7] = MAX_INT32_STRING; $this->assertSame(MAX_INT32, $arr[7]); // Test foreach. $arr = new RepeatedField(GPBType::INT32); for ($i = 0; $i < 3; $i++) { - $arr []= $i; + $arr[] = $i; } $i = 0; foreach ($arr as $val) { @@ -77,44 +77,6 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $this->assertSame(3, $i); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32AppendStringFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr []= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetStringFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr []= 0; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32AppendMessageFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetMessageFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr []= 0; - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test uint32 field. ######################################################### @@ -124,31 +86,31 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::UINT32); // Test append. - $arr []= MAX_UINT32; + $arr[] = MAX_UINT32; $this->assertSame(-1, $arr[0]); - $arr []= -1; + $arr[] = -1; $this->assertSame(-1, $arr[1]); - $arr []= MIN_UINT32; + $arr[] = MIN_UINT32; $this->assertSame(MIN_UINT32, $arr[2]); - $arr []= 1.1; + $arr[] = 1.1; $this->assertSame(1, $arr[3]); - $arr []= MAX_UINT32_FLOAT; + $arr[] = MAX_UINT32_FLOAT; $this->assertSame(-1, $arr[4]); - $arr []= -1.0; + $arr[] = -1.0; $this->assertSame(-1, $arr[5]); - $arr []= MIN_UINT32_FLOAT; + $arr[] = MIN_UINT32_FLOAT; $this->assertSame(MIN_UINT32, $arr[6]); - $arr []= '2'; + $arr[] = '2'; $this->assertSame(2, $arr[7]); - $arr []= '3.1'; + $arr[] = '3.1'; $this->assertSame(3, $arr[8]); - $arr []= MAX_UINT32_STRING; + $arr[] = MAX_UINT32_STRING; $this->assertSame(-1, $arr[9]); - $arr []= '-1.0'; + $arr[] = '-1.0'; $this->assertSame(-1, $arr[10]); - $arr []= MIN_UINT32_STRING; + $arr[] = MIN_UINT32_STRING; $this->assertSame(MIN_UINT32, $arr[11]); $this->assertEquals(12, count($arr)); @@ -159,72 +121,34 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= MAX_UINT32; + $arr[0] = MAX_UINT32; $this->assertSame(-1, $arr[0]); - $arr [1]= -1; + $arr[1] = -1; $this->assertSame(-1, $arr[1]); - $arr [2]= MIN_UINT32; + $arr[2] = MIN_UINT32; $this->assertSame(MIN_UINT32, $arr[2]); - $arr [3]= 1.1; + $arr[3] = 1.1; $this->assertSame(1, $arr[3]); - $arr [4]= MAX_UINT32_FLOAT; + $arr[4] = MAX_UINT32_FLOAT; $this->assertSame(-1, $arr[4]); - $arr [5]= -1.0; + $arr[5] = -1.0; $this->assertSame(-1, $arr[5]); - $arr [6]= MIN_UINT32_FLOAT; + $arr[6] = MIN_UINT32_FLOAT; $this->assertSame(MIN_UINT32, $arr[6]); - $arr [7]= '2'; + $arr[7] = '2'; $this->assertSame(2, $arr[7]); - $arr [8]= '3.1'; + $arr[8] = '3.1'; $this->assertSame(3, $arr[8]); - $arr [9]= MAX_UINT32_STRING; + $arr[9] = MAX_UINT32_STRING; $this->assertSame(-1, $arr[9]); - $arr [10]= '-1.0'; + $arr[10] = '-1.0'; $this->assertSame(-1, $arr[10]); - $arr [11]= MIN_UINT32_STRING; + $arr[11] = MIN_UINT32_STRING; $this->assertSame(MIN_UINT32, $arr[11]); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32AppendStringFail() - { - $arr = new RepeatedField(GPBType::UINT32); - $arr []= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetStringFail() - { - $arr = new RepeatedField(GPBType::UINT32); - $arr []= 0; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32AppendMessageFail() - { - $arr = new RepeatedField(GPBType::UINT32); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetMessageFail() - { - $arr = new RepeatedField(GPBType::UINT32); - $arr []= 0; - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test int64 field. ######################################################### @@ -234,13 +158,13 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::INT64); // Test append. - $arr []= MAX_INT64; - $arr []= MIN_INT64; - $arr []= 1.1; - $arr []= '2'; - $arr []= '3.1'; - $arr []= MAX_INT64_STRING; - $arr []= MIN_INT64_STRING; + $arr[] = MAX_INT64; + $arr[] = MIN_INT64; + $arr[] = 1.1; + $arr[] = '2'; + $arr[] = '3.1'; + $arr[] = MAX_INT64_STRING; + $arr[] = MIN_INT64_STRING; if (PHP_INT_SIZE == 4) { $this->assertSame(MAX_INT64, $arr[0]); $this->assertSame(MIN_INT64, $arr[1]); @@ -272,13 +196,13 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= MAX_INT64; - $arr [1]= MIN_INT64; - $arr [2]= 1.1; - $arr [3]= '2'; - $arr [4]= '3.1'; - $arr [5]= MAX_INT64_STRING; - $arr [6]= MIN_INT64_STRING; + $arr[0] = MAX_INT64; + $arr[1] = MIN_INT64; + $arr[2] = 1.1; + $arr[3] = '2'; + $arr[4] = '3.1'; + $arr[5] = MAX_INT64_STRING; + $arr[6] = MIN_INT64_STRING; if (PHP_INT_SIZE == 4) { $this->assertSame(MAX_INT64_STRING, $arr[0]); @@ -299,44 +223,6 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64AppendStringFail() - { - $arr = new RepeatedField(GPBType::INT64); - $arr []= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetStringFail() - { - $arr = new RepeatedField(GPBType::INT64); - $arr []= 0; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64AppendMessageFail() - { - $arr = new RepeatedField(GPBType::INT64); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetMessageFail() - { - $arr = new RepeatedField(GPBType::INT64); - $arr []= 0; - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test uint64 field. ######################################################### @@ -346,11 +232,11 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::UINT64); // Test append. - $arr []= MAX_UINT64; - $arr []= 1.1; - $arr []= '2'; - $arr []= '3.1'; - $arr []= MAX_UINT64_STRING; + $arr[] = MAX_UINT64; + $arr[] = 1.1; + $arr[] = '2'; + $arr[] = '3.1'; + $arr[] = MAX_UINT64_STRING; if (PHP_INT_SIZE == 4) { $this->assertSame(MAX_UINT64_STRING, $arr[0]); @@ -379,11 +265,11 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= MAX_UINT64; - $arr [1]= 1.1; - $arr [2]= '2'; - $arr [3]= '3.1'; - $arr [4]= MAX_UINT64_STRING; + $arr[0] = MAX_UINT64; + $arr[1] = 1.1; + $arr[2] = '2'; + $arr[3] = '3.1'; + $arr[4] = MAX_UINT64_STRING; if (PHP_INT_SIZE == 4) { $this->assertSame(MAX_UINT64_STRING, $arr[0]); @@ -400,44 +286,6 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64AppendStringFail() - { - $arr = new RepeatedField(GPBType::UINT64); - $arr []= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetStringFail() - { - $arr = new RepeatedField(GPBType::UINT64); - $arr []= 0; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64AppendMessageFail() - { - $arr = new RepeatedField(GPBType::UINT64); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetMessageFail() - { - $arr = new RepeatedField(GPBType::UINT64); - $arr []= 0; - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test float field. ######################################################### @@ -447,15 +295,15 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::FLOAT); // Test append. - $arr []= 1; + $arr[] = 1; $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF); - $arr []= 1.1; + $arr[] = 1.1; $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF); - $arr []= '2'; + $arr[] = '2'; $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF); - $arr []= '3.1'; + $arr[] = '3.1'; $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF); $this->assertEquals(4, count($arr)); @@ -466,56 +314,18 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= 1; + $arr[0] = 1; $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF); - $arr [1]= 1.1; + $arr[1] = 1.1; $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF); - $arr [2]= '2'; + $arr[2] = '2'; $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF); - $arr [3]= '3.1'; + $arr[3] = '3.1'; $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatAppendStringFail() - { - $arr = new RepeatedField(GPBType::FLOAT); - $arr []= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatSetStringFail() - { - $arr = new RepeatedField(GPBType::FLOAT); - $arr []= 0.0; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatAppendMessageFail() - { - $arr = new RepeatedField(GPBType::FLOAT); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatSetMessageFail() - { - $arr = new RepeatedField(GPBType::FLOAT); - $arr []= 0.0; - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test double field. ######################################################### @@ -525,15 +335,15 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::DOUBLE); // Test append. - $arr []= 1; + $arr[] = 1; $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF); - $arr []= 1.1; + $arr[] = 1.1; $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF); - $arr []= '2'; + $arr[] = '2'; $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF); - $arr []= '3.1'; + $arr[] = '3.1'; $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF); $this->assertEquals(4, count($arr)); @@ -544,56 +354,18 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= 1; + $arr[0] = 1; $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF); - $arr [1]= 1.1; + $arr[1] = 1.1; $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF); - $arr [2]= '2'; + $arr[2] = '2'; $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF); - $arr [3]= '3.1'; + $arr[3] = '3.1'; $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleAppendStringFail() - { - $arr = new RepeatedField(GPBType::DOUBLE); - $arr []= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleSetStringFail() - { - $arr = new RepeatedField(GPBType::DOUBLE); - $arr []= 0.0; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleAppendMessageFail() - { - $arr = new RepeatedField(GPBType::DOUBLE); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleSetMessageFail() - { - $arr = new RepeatedField(GPBType::DOUBLE); - $arr []= 0.0; - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test bool field. ######################################################### @@ -603,16 +375,16 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::BOOL); // Test append. - $arr []= true; + $arr[] = true; $this->assertSame(true, $arr[0]); - $arr []= -1; + $arr[] = -1; $this->assertSame(true, $arr[1]); - $arr []= 1.1; + $arr[] = 1.1; $this->assertSame(true, $arr[2]); - $arr []= ''; + $arr[] = ''; $this->assertSame(false, $arr[3]); $this->assertEquals(4, count($arr)); @@ -623,38 +395,19 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= true; + $arr[0] = true; $this->assertSame(true, $arr[0]); - $arr [1]= -1; + $arr[1] = -1; $this->assertSame(true, $arr[1]); - $arr [2]= 1.1; + $arr[2] = 1.1; $this->assertSame(true, $arr[2]); - $arr [3]= ''; + $arr[3] = ''; $this->assertSame(false, $arr[3]); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolAppendMessageFail() - { - $arr = new RepeatedField(GPBType::BOOL); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolSetMessageFail() - { - $arr = new RepeatedField(GPBType::BOOL); - $arr []= true; - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test string field. ######################################################### @@ -664,16 +417,16 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::STRING); // Test append. - $arr []= 'abc'; + $arr[] = 'abc'; $this->assertSame('abc', $arr[0]); - $arr []= 1; + $arr[] = 1; $this->assertSame('1', $arr[1]); - $arr []= 1.1; + $arr[] = 1.1; $this->assertSame('1.1', $arr[2]); - $arr []= true; + $arr[] = true; $this->assertSame('1', $arr[3]); $this->assertEquals(4, count($arr)); @@ -684,59 +437,19 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= 'abc'; + $arr[0] = 'abc'; $this->assertSame('abc', $arr[0]); - $arr [1]= 1; + $arr[1] = 1; $this->assertSame('1', $arr[1]); - $arr [2]= 1.1; + $arr[2] = 1.1; $this->assertSame('1.1', $arr[2]); - $arr [3]= true; + $arr[3] = true; $this->assertSame('1', $arr[3]); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringAppendMessageFail() - { - $arr = new RepeatedField(GPBType::STRING); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetMessageFail() - { - $arr = new RepeatedField(GPBType::STRING); - $arr []= 'abc'; - $arr [0]= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringAppendInvalidUTF8Fail() - { - $arr = new RepeatedField(GPBType::STRING); - $hex = hex2bin("ff"); - $arr []= $hex; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetInvalidUTF8Fail() - { - $arr = new RepeatedField(GPBType::STRING); - $arr []= 'abc'; - $hex = hex2bin("ff"); - $arr [0]= $hex; - } - ######################################################### # Test message field. ######################################################### @@ -748,7 +461,7 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase // Test append. $sub_m = new TestMessage_Sub(); $sub_m->setA(1); - $arr []= $sub_m; + $arr[] = $sub_m; $this->assertSame(1, $arr[0]->getA()); $this->assertEquals(1, count($arr)); @@ -756,78 +469,10 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase // Test set. $sub_m = new TestMessage_Sub(); $sub_m->setA(2); - $arr [0]= $sub_m; + $arr[0] = $sub_m; $this->assertSame(2, $arr[0]->getA()); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageAppendIntFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr []= 1; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetIntFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr []= new TestMessage_Sub; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageAppendStringFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr []= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetStringFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr []= new TestMessage_Sub; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageAppendOtherMessageFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr []= new TestMessage; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageAppendNullFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $null = null; - $arr []= $null; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetNullFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr []= new TestMessage_Sub(); - $null = null; - $arr[0] = $null; - } - ######################################################### # Test offset type ######################################################### @@ -835,18 +480,18 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase public function testOffset() { $arr = new RepeatedField(GPBType::INT32); - $arr []= 0; + $arr[] = 0; - $arr [0]= 1; + $arr[0] = 1; $this->assertSame(1, $arr[0]); $this->assertSame(1, count($arr)); - $arr ['0']= 2; + $arr['0'] = 2; $this->assertSame(2, $arr['0']); $this->assertSame(2, $arr[0]); $this->assertSame(1, count($arr)); - $arr [0.0]= 3; + $arr[0.0] = 3; $this->assertSame(3, $arr[0.0]); $this->assertSame(1, count($arr)); } @@ -855,9 +500,9 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase { $arr = new RepeatedField(GPBType::INT32); - $arr []= 0; - $arr []= 1; - $arr []= 2; + $arr[] = 0; + $arr[] = 1; + $arr[] = 2; $this->assertSame(3, count($arr)); unset($arr[2]); @@ -865,67 +510,13 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $this->assertSame(0, $arr[0]); $this->assertSame(1, $arr[1]); - $arr [] = 3; + $arr[] = 3; $this->assertSame(3, count($arr)); $this->assertSame(0, $arr[0]); $this->assertSame(1, $arr[1]); $this->assertSame(3, $arr[2]); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRemoveMiddleFail() - { - $arr = new RepeatedField(GPBType::INT32); - - $arr []= 0; - $arr []= 1; - $arr []= 2; - $this->assertSame(3, count($arr)); - - unset($arr[1]); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRemoveEmptyFail() - { - $arr = new RepeatedField(GPBType::INT32); - - unset($arr[0]); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageOffsetFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr []= 0; - $arr [new TestMessage_Sub()]= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringOffsetFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr []= 0; - $arr ['abc']= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testSetNonExistedOffsetFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr [0]= 0; - } - ######################################################### # Test memory leak ######################################################### @@ -933,7 +524,7 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase public function testCycleLeak() { $arr = new RepeatedField(GPBType::MESSAGE, TestMessage::class); - $arr []= new TestMessage; + $arr[] = new TestMessage; $arr[0]->SetRepeatedRecursive($arr); // Clean up memory before test. diff --git a/php/tests/compatibility_test.sh b/php/tests/compatibility_test.sh index e05b2af1..6f1e4900 100755 --- a/php/tests/compatibility_test.sh +++ b/php/tests/compatibility_test.sh @@ -1,6 +1,6 @@ #!/bin/bash -use_php() { +function use_php() { VERSION=$1 PHP=`which php` PHP_CONFIG=`which php-config` @@ -10,7 +10,7 @@ use_php() { ln -sfn "/usr/local/php-${VERSION}/bin/phpize" $PHPIZE } -generate_proto() { +function generate_proto() { PROTOC1=$1 PROTOC2=$2 @@ -25,6 +25,27 @@ generate_proto() { popd } +# Remove tests to expect error. These were added to API tests by mistake. +function remove_error_test() { + local TEMPFILE=`tempfile` + cat $1 | \ + awk -v file=`basename $1` -v dir=`basename $(dirname $1)` ' + BEGIN { + show = 1 + } + /@expectedException PHPUnit_Framework_Error/ { show = 0; next; } + / *\*\// { print; next; } + / *}/ { + if (!show) { + show = 1; + next; + } + } + show { print } + ' > $TEMPFILE + cp $TEMPFILE $1 +} + set -ex # Change to the script's directory. @@ -81,6 +102,15 @@ OLD_PROTOC=`pwd`/old_protoc cd protobuf/php cp -r /usr/local/vendor-5.5 vendor wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit + +# Remove implementation detail tests. +tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php ) +sed -i.bak '/php_implementation_test.php/d' phpunit.xml +for t in "${tests[@]}" +do + remove_error_test tests/$t +done + cd tests # Test A.1: diff --git a/php/tests/encode_decode_test.php b/php/tests/encode_decode_test.php index b4cfed42..e2912ad4 100644 --- a/php/tests/encode_decode_test.php +++ b/php/tests/encode_decode_test.php @@ -14,417 +14,432 @@ use Foo\TestUnpackedMessage; class EncodeDecodeTest extends TestBase { - public function testEncode() - { - $from = new TestMessage(); - $this->expectEmptyFields($from); - $this->setFields($from); - $this->expectFields($from); - - $data = $from->serializeToString(); - $this->assertSame(bin2hex(TestUtil::getGoldenTestMessage()), - bin2hex($data)); - } - - public function testDecode() - { - $to = new TestMessage(); - $to->mergeFromString(TestUtil::getGoldenTestMessage()); - $this->expectFields($to); - } - - public function testEncodeDecode() - { - $from = new TestMessage(); - $this->expectEmptyFields($from); - $this->setFields($from); - $this->expectFields($from); - - $data = $from->serializeToString(); - - $to = new TestMessage(); - $to->mergeFromString($data); - $this->expectFields($to); - } - - public function testEncodeDecodeEmpty() - { - $from = new TestMessage(); - $this->expectEmptyFields($from); - - $data = $from->serializeToString(); - - $to = new TestMessage(); - $to->mergeFromString($data); - $this->expectEmptyFields($to); - } +# public function testEncode() +# { +# $from = new TestMessage(); +# $this->expectEmptyFields($from); +# $this->setFields($from); +# $this->expectFields($from); +# +# $data = $from->serializeToString(); +# $this->assertSame(bin2hex(TestUtil::getGoldenTestMessage()), +# bin2hex($data)); +# } +# +# public function testDecode() +# { +# $to = new TestMessage(); +# $to->mergeFromString(TestUtil::getGoldenTestMessage()); +# $this->expectFields($to); +# } +# +# public function testEncodeDecode() +# { +# $from = new TestMessage(); +# $this->expectEmptyFields($from); +# $this->setFields($from); +# $this->expectFields($from); +# +# $data = $from->serializeToString(); +# +# $to = new TestMessage(); +# $to->mergeFromString($data); +# $this->expectFields($to); +# } +# +# public function testEncodeDecodeEmpty() +# { +# $from = new TestMessage(); +# $this->expectEmptyFields($from); +# +# $data = $from->serializeToString(); +# +# $to = new TestMessage(); +# $to->mergeFromString($data); +# $this->expectEmptyFields($to); +# } public function testEncodeDecodeOneof() { $m = new TestMessage(); - $m->setOneofInt32(1); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame(1, $n->getOneofInt32()); - - $m->setOneofFloat(2.0); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame(2.0, $n->getOneofFloat()); - - $m->setOneofString('abc'); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame('abc', $n->getOneofString()); - - $sub_m = new TestMessage_Sub(); - $sub_m->setA(1); - $m->setOneofMessage($sub_m); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame(1, $n->getOneofMessage()->getA()); +# $m->setOneofInt32(1); +# $data = $m->serializeToString(); +# $n = new TestMessage(); +# $n->mergeFromString($data); +# $this->assertSame(1, $n->getOneofInt32()); +# +# $m->setOneofFloat(2.0); +# $data = $m->serializeToString(); +# $n = new TestMessage(); +# $n->mergeFromString($data); +# $this->assertSame(2.0, $n->getOneofFloat()); +# +# $m->setOneofString('abc'); +# $data = $m->serializeToString(); +# $n = new TestMessage(); +# $n->mergeFromString($data); +# $this->assertSame('abc', $n->getOneofString()); +# +# $sub_m = new TestMessage_Sub(); +# $sub_m->setA(1); +# $m->setOneofMessage($sub_m); +# $data = $m->serializeToString(); +# $n = new TestMessage(); +# $n->mergeFromString($data); +# $this->assertSame(1, $n->getOneofMessage()->getA()); // Encode default value - $m->setOneofEnum(TestEnum::ZERO); +# $m->setOneofEnum(TestEnum::ZERO); +# $data = $m->serializeToString(); +# $n = new TestMessage(); +# $n->mergeFromString($data); +# $this->assertSame("oneof_enum", $n->getMyOneof()); +# $this->assertSame(TestEnum::ZERO, $n->getOneofEnum()); + + $m->setOneofString(""); $data = $m->serializeToString(); $n = new TestMessage(); $n->mergeFromString($data); - $this->assertSame("oneof_enum", $n->getMyOneof()); - } - - public function testPackedEncode() - { - $from = new TestPackedMessage(); - TestUtil::setTestPackedMessage($from); - $this->assertSame(TestUtil::getGoldenTestPackedMessage(), - $from->serializeToString()); - } - - public function testPackedDecodePacked() - { - $to = new TestPackedMessage(); - $to->mergeFromString(TestUtil::getGoldenTestPackedMessage()); - TestUtil::assertTestPackedMessage($to); - } - - public function testPackedDecodeUnpacked() - { - $to = new TestPackedMessage(); - $to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage()); - TestUtil::assertTestPackedMessage($to); - } - - public function testUnpackedEncode() - { - $from = new TestUnpackedMessage(); - TestUtil::setTestPackedMessage($from); - $this->assertSame(TestUtil::getGoldenTestUnpackedMessage(), - $from->serializeToString()); - } - - public function testUnpackedDecodePacked() - { - $to = new TestUnpackedMessage(); - $to->mergeFromString(TestUtil::getGoldenTestPackedMessage()); - TestUtil::assertTestPackedMessage($to); - } - - public function testUnpackedDecodeUnpacked() - { - $to = new TestUnpackedMessage(); - $to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage()); - TestUtil::assertTestPackedMessage($to); - } - - public function testDecodeInt64() - { - // Read 64 testing - $testVals = array( - '10' => '100a', - '100' => '1064', - '800' => '10a006', - '6400' => '108032', - '70400' => '1080a604', - '774400' => '1080a22f', - '9292800' => '108098b704', - '74342400' => '1080c0b923', - '743424000' => '108080bfe202', - '8177664000' => '108080b5bb1e', - '65421312000' => '108080a8dbf301', - '785055744000' => '108080e0c7ec16', - '9420668928000' => '10808080dd969202', - '103627358208000' => '10808080fff9c717', - '1139900940288000' => '10808080f5bd978302', - '13678811283456000' => '10808080fce699a618', - '109430490267648000' => '10808080e0b7ceb1c201', - '984874412408832000' => '10808080e0f5c1bed50d', - ); - - $msg = new TestMessage(); - foreach ($testVals as $original => $encoded) { - $msg->setOptionalInt64($original); - $data = $msg->serializeToString(); - $this->assertSame($encoded, bin2hex($data)); - $msg->setOptionalInt64(0); - $msg->mergeFromString($data); - $this->assertEquals($original, $msg->getOptionalInt64()); - } - } - - public function testDecodeToExistingMessage() - { - $m1 = new TestMessage(); - $this->setFields($m1); - $this->expectFields($m1); - - $m2 = new TestMessage(); - $this->setFields2($m2); - $data = $m2->serializeToString(); - - $m1->mergeFromString($data); - $this->expectFieldsMerged($m1); - } - - public function testDecodeFieldNonExist() - { - $data = hex2bin('c80501'); - $m = new TestMessage(); - $m->mergeFromString($data); - } - - public function testEncodeNegativeInt32() - { - $m = new TestMessage(); - $m->setOptionalInt32(-1); - $data = $m->serializeToString(); - $this->assertSame("08ffffffffffffffffff01", bin2hex($data)); - } - - public function testDecodeNegativeInt32() - { - $m = new TestMessage(); - $this->assertEquals(0, $m->getOptionalInt32()); - $m->mergeFromString(hex2bin("08ffffffffffffffffff01")); - $this->assertEquals(-1, $m->getOptionalInt32()); - - $m = new TestMessage(); - $this->assertEquals(0, $m->getOptionalInt32()); - $m->mergeFromString(hex2bin("08ffffffff0f")); - $this->assertEquals(-1, $m->getOptionalInt32()); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidInt32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('08')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSubMessage() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('9A010108')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidInt64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('10')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidUInt32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('18')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidUInt64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('20')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSInt32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('28')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSInt64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('30')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidFixed32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('3D')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidFixed64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('41')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSFixed32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('4D')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSFixed64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('51')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidFloat() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('5D')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidDouble() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('61')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidBool() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('68')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidStringLengthMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('72')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidStringDataMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('7201')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidBytesLengthMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('7A')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidBytesDataMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('7A01')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidEnum() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('8001')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidMessageLengthMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('8A01')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidMessageDataMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('8A0101')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidPackedMessageLength() - { - $m = new TestPackedMessage(); - $m->mergeFromString(hex2bin('D205')); - } - - # TODO(teboring): Add test back when php implementation is ready for json - # encode/decode. - # public function testJsonEncode() - # { - # $from = new TestMessage(); - # $this->setFields($from); - # $data = $from->jsonEncode(); - # $to = new TestMessage(); - # $to->jsonDecode($data); - # $this->expectFields($to); - # } + $this->assertSame("oneof_string", $n->getMyOneof()); + $this->assertSame("", $n->getOneofString()); + +# $sub_m = new TestMessage_Sub(); +# $m->setOneofMessage($sub_m); +# $data = $m->serializeToString(); +# $n = new TestMessage(); +# $n->mergeFromString($data); +# $this->assertSame("oneof_message", $n->getMyOneof()); +# $this->assertFalse(is_null($n->getOneofMessage())); + + } + +# public function testPackedEncode() +# { +# $from = new TestPackedMessage(); +# TestUtil::setTestPackedMessage($from); +# $this->assertSame(TestUtil::getGoldenTestPackedMessage(), +# $from->serializeToString()); +# } +# +# public function testPackedDecodePacked() +# { +# $to = new TestPackedMessage(); +# $to->mergeFromString(TestUtil::getGoldenTestPackedMessage()); +# TestUtil::assertTestPackedMessage($to); +# } +# +# public function testPackedDecodeUnpacked() +# { +# $to = new TestPackedMessage(); +# $to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage()); +# TestUtil::assertTestPackedMessage($to); +# } +# +# public function testUnpackedEncode() +# { +# $from = new TestUnpackedMessage(); +# TestUtil::setTestPackedMessage($from); +# $this->assertSame(TestUtil::getGoldenTestUnpackedMessage(), +# $from->serializeToString()); +# } +# +# public function testUnpackedDecodePacked() +# { +# $to = new TestUnpackedMessage(); +# $to->mergeFromString(TestUtil::getGoldenTestPackedMessage()); +# TestUtil::assertTestPackedMessage($to); +# } +# +# public function testUnpackedDecodeUnpacked() +# { +# $to = new TestUnpackedMessage(); +# $to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage()); +# TestUtil::assertTestPackedMessage($to); +# } +# +# public function testDecodeInt64() +# { +# // Read 64 testing +# $testVals = array( +# '10' => '100a', +# '100' => '1064', +# '800' => '10a006', +# '6400' => '108032', +# '70400' => '1080a604', +# '774400' => '1080a22f', +# '9292800' => '108098b704', +# '74342400' => '1080c0b923', +# '743424000' => '108080bfe202', +# '8177664000' => '108080b5bb1e', +# '65421312000' => '108080a8dbf301', +# '785055744000' => '108080e0c7ec16', +# '9420668928000' => '10808080dd969202', +# '103627358208000' => '10808080fff9c717', +# '1139900940288000' => '10808080f5bd978302', +# '13678811283456000' => '10808080fce699a618', +# '109430490267648000' => '10808080e0b7ceb1c201', +# '984874412408832000' => '10808080e0f5c1bed50d', +# ); +# +# $msg = new TestMessage(); +# foreach ($testVals as $original => $encoded) { +# $msg->setOptionalInt64($original); +# $data = $msg->serializeToString(); +# $this->assertSame($encoded, bin2hex($data)); +# $msg->setOptionalInt64(0); +# $msg->mergeFromString($data); +# $this->assertEquals($original, $msg->getOptionalInt64()); +# } +# } +# +# public function testDecodeToExistingMessage() +# { +# $m1 = new TestMessage(); +# $this->setFields($m1); +# $this->expectFields($m1); +# +# $m2 = new TestMessage(); +# $this->setFields2($m2); +# $data = $m2->serializeToString(); +# +# $m1->mergeFromString($data); +# $this->expectFieldsMerged($m1); +# } +# +# public function testDecodeFieldNonExist() +# { +# $data = hex2bin('c80501'); +# $m = new TestMessage(); +# $m->mergeFromString($data); +# } +# +# public function testEncodeNegativeInt32() +# { +# $m = new TestMessage(); +# $m->setOptionalInt32(-1); +# $data = $m->serializeToString(); +# $this->assertSame("08ffffffffffffffffff01", bin2hex($data)); +# } +# +# public function testDecodeNegativeInt32() +# { +# $m = new TestMessage(); +# $this->assertEquals(0, $m->getOptionalInt32()); +# $m->mergeFromString(hex2bin("08ffffffffffffffffff01")); +# $this->assertEquals(-1, $m->getOptionalInt32()); +# +# $m = new TestMessage(); +# $this->assertEquals(0, $m->getOptionalInt32()); +# $m->mergeFromString(hex2bin("08ffffffff0f")); +# $this->assertEquals(-1, $m->getOptionalInt32()); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidInt32() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('08')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidSubMessage() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('9A010108')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidInt64() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('10')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidUInt32() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('18')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidUInt64() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('20')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidSInt32() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('28')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidSInt64() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('30')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidFixed32() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('3D')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidFixed64() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('41')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidSFixed32() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('4D')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidSFixed64() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('51')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidFloat() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('5D')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidDouble() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('61')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidBool() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('68')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidStringLengthMiss() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('72')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidStringDataMiss() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('7201')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidBytesLengthMiss() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('7A')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidBytesDataMiss() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('7A01')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidEnum() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('8001')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidMessageLengthMiss() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('8A01')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidMessageDataMiss() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('8A0101')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidPackedMessageLength() +# { +# $m = new TestPackedMessage(); +# $m->mergeFromString(hex2bin('D205')); +# } +# +# public function testJsonEncode() +# { +# $from = new TestMessage(); +# $this->setFields($from); +# $data = $from->serializeToJsonString(); +# $to = new TestMessage(); +# $to->mergeFromJsonString($data); +# $this->expectFields($to); +# } } diff --git a/php/tests/gdb_test.sh b/php/tests/gdb_test.sh index 0809bef3..484e2edf 100755 --- a/php/tests/gdb_test.sh +++ b/php/tests/gdb_test.sh @@ -3,7 +3,7 @@ # gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which # phpunit` --bootstrap autoload.php tmp_test.php # -gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php well_known_test.php +gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php encode_decode_test.php # # gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php # diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php index 33f38e1c..56e3be20 100644 --- a/php/tests/generated_class_test.php +++ b/php/tests/generated_class_test.php @@ -62,24 +62,6 @@ class GeneratedClassTest extends TestBase $this->assertSame(MIN_INT32, $m->getOptionalInt32()); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32FieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalInt32(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32FieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalInt32('abc'); - } - ######################################################### # Test uint32 field. ######################################################### @@ -119,24 +101,6 @@ class GeneratedClassTest extends TestBase $this->assertSame(MIN_INT32, $m->getOptionalUint32()); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32FieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalUint32(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32FieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalUint32('abc'); - } - ######################################################### # Test int64 field. ######################################################### @@ -189,24 +153,6 @@ class GeneratedClassTest extends TestBase } } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64FieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalInt64(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64FieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalInt64('abc'); - } - ######################################################### # Test uint64 field. ######################################################### @@ -254,24 +200,6 @@ class GeneratedClassTest extends TestBase } } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64FieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalUint64(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64FieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalUint64('abc'); - } - ######################################################### # Test enum field. ######################################################### @@ -326,24 +254,6 @@ class GeneratedClassTest extends TestBase $this->assertEquals(3.1, $m->getOptionalFloat(), '', MAX_FLOAT_DIFF); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatFieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalFloat(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatFieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalFloat('abc'); - } - ######################################################### # Test double field. ######################################################### @@ -367,24 +277,6 @@ class GeneratedClassTest extends TestBase $this->assertEquals(3.1, $m->getOptionalDouble(), '', MAX_FLOAT_DIFF); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleFieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalDouble(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleFieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalDouble('abc'); - } - ######################################################### # Test bool field. ######################################################### @@ -410,15 +302,6 @@ class GeneratedClassTest extends TestBase $this->assertSame(false, $m->getOptionalBool()); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolFieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalBool(new TestMessage()); - } - ######################################################### # Test string field. ######################################################### @@ -444,16 +327,6 @@ class GeneratedClassTest extends TestBase $this->assertSame('1', $m->getOptionalString()); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringFieldInvalidUTF8Fail() - { - $m = new TestMessage(); - $hex = hex2bin("ff"); - $m->setOptionalString($hex); - } - ######################################################### # Test bytes field. ######################################################### @@ -504,25 +377,6 @@ class GeneratedClassTest extends TestBase $this->assertNull($m->getOptionalMessage()); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageFieldWrongTypeFail() - { - $m = new TestMessage(); - $a = 1; - $m->setOptionalMessage($a); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageFieldWrongClassFail() - { - $m = new TestMessage(); - $m->setOptionalMessage(new TestMessage()); - } - ######################################################### # Test repeated field. ######################################################### @@ -556,48 +410,6 @@ class GeneratedClassTest extends TestBase $this->assertFalse($arr instanceof RepeatedField); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRepeatedFieldWrongTypeFail() - { - $m = new TestMessage(); - $a = 1; - $m->setRepeatedInt32($a); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRepeatedFieldWrongObjectFail() - { - $m = new TestMessage(); - $m->setRepeatedInt32($m); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRepeatedFieldWrongRepeatedTypeFail() - { - $m = new TestMessage(); - - $repeated_int32 = new RepeatedField(GPBType::UINT32); - $m->setRepeatedInt32($repeated_int32); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRepeatedFieldWrongRepeatedMessageClassFail() - { - $m = new TestMessage(); - - $repeated_message = new RepeatedField(GPBType::MESSAGE, - TestMessage::class); - $m->setRepeatedMessage($repeated_message); - } - ######################################################### # Test map field. ######################################################### @@ -629,49 +441,6 @@ class GeneratedClassTest extends TestBase $this->assertFalse($dict instanceof MapField); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMapFieldWrongTypeFail() - { - $m = new TestMessage(); - $a = 1; - $m->setMapInt32Int32($a); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMapFieldWrongObjectFail() - { - $m = new TestMessage(); - $m->setMapInt32Int32($m); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMapFieldWrongRepeatedTypeFail() - { - $m = new TestMessage(); - - $map_uint32_uint32 = new MapField(GPBType::UINT32, GPBType::UINT32); - $m->setMapInt32Int32($map_uint32_uint32); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMapFieldWrongRepeatedMessageClassFail() - { - $m = new TestMessage(); - - $map_int32_message = new MapField(GPBType::INT32, - GPBType::MESSAGE, - TestMessage::class); - $m->setMapInt32Message($map_int32_message); - } - ######################################################### # Test oneof field. ######################################################### @@ -851,16 +620,6 @@ class GeneratedClassTest extends TestBase $this->expectFields($n); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageMergeFromInvalidTypeFail() - { - $m = new TestMessage(); - $n = new TestMessage_Sub(); - $m->mergeFrom($n); - } - ######################################################### # Test message/enum without namespace. ######################################################### diff --git a/php/tests/map_field_test.php b/php/tests/map_field_test.php index 2fda9135..c5d21264 100644 --- a/php/tests/map_field_test.php +++ b/php/tests/map_field_test.php @@ -58,42 +58,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(0, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetStringKeyFail() - { - $arr = new MapField(GPBType::INT32, GPBType::INT32); - $arr ['abc']= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetStringValueFail() - { - $arr = new MapField(GPBType::INT32, GPBType::INT32); - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetMessageKeyFail() - { - $arr = new MapField(GPBType::INT32, GPBType::INT32); - $arr [new TestMessage_Sub()]= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetMessageValueFail() - { - $arr = new MapField(GPBType::INT32, GPBType::INT32); - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test uint32 field. ######################################################### @@ -159,42 +123,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(0, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetStringKeyFail() - { - $arr = new MapField(GPBType::UINT32, GPBType::UINT32); - $arr ['abc']= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetStringValueFail() - { - $arr = new MapField(GPBType::UINT32, GPBType::UINT32); - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetMessageKeyFail() - { - $arr = new MapField(GPBType::UINT32, GPBType::UINT32); - $arr [new TestMessage_Sub()]= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetMessageValueFail() - { - $arr = new MapField(GPBType::UINT32, GPBType::UINT32); - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test int64 field. ######################################################### @@ -252,42 +180,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(0, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetStringKeyFail() - { - $arr = new MapField(GPBType::INT64, GPBType::INT64); - $arr ['abc']= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetStringValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::INT64); - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetMessageKeyFail() - { - $arr = new MapField(GPBType::INT64, GPBType::INT64); - $arr [new TestMessage_Sub()]= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetMessageValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::INT64); - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test uint64 field. ######################################################### @@ -339,42 +231,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(0, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetStringKeyFail() - { - $arr = new MapField(GPBType::UINT64, GPBType::UINT64); - $arr ['abc']= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetStringValueFail() - { - $arr = new MapField(GPBType::UINT64, GPBType::UINT64); - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetMessageKeyFail() - { - $arr = new MapField(GPBType::UINT64, GPBType::UINT64); - $arr [new TestMessage_Sub()]= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetMessageValueFail() - { - $arr = new MapField(GPBType::UINT64, GPBType::UINT64); - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test float field. ######################################################### @@ -397,24 +253,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(4, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatSetStringValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::FLOAT); - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatSetMessageValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::FLOAT); - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test double field. ######################################################### @@ -437,24 +275,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(4, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleSetStringValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::DOUBLE); - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleSetMessageValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::DOUBLE); - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test bool field. ######################################################### @@ -515,24 +335,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(0, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolSetMessageKeyFail() - { - $arr = new MapField(GPBType::BOOL, GPBType::BOOL); - $arr [new TestMessage_Sub()]= true; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolSetMessageValueFail() - { - $arr = new MapField(GPBType::BOOL, GPBType::BOOL); - $arr [true]= new TestMessage_Sub(); - } - ######################################################### # Test string field. ######################################################### @@ -566,42 +368,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(0, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetInvalidUTF8KeyFail() - { - $arr = new MapField(GPBType::STRING, GPBType::STRING); - $arr[hex2bin("ff")]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetInvalidUTF8ValueFail() - { - $arr = new MapField(GPBType::STRING, GPBType::STRING); - $arr ['abc']= hex2bin("ff"); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetMessageKeyFail() - { - $arr = new MapField(GPBType::STRING, GPBType::STRING); - $arr [new TestMessage_Sub()]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetMessageValueFail() - { - $arr = new MapField(GPBType::STRING, GPBType::STRING); - $arr ['abc']= new TestMessage_Sub(); - } - ######################################################### # Test message field. ######################################################### @@ -619,47 +385,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(1, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetIntValueFail() - { - $arr = - new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); - $arr[0] = 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetStringValueFail() - { - $arr = - new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetOtherMessageValueFail() - { - $arr = - new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetNullFail() - { - $arr = - new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); - $null = NULL; - $arr[0] = $null; - } - ######################################################### # Test memory leak ######################################################### @@ -669,7 +394,7 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { // { // $arr = new MapField(GPBType::INT32, // GPBType::MESSAGE, TestMessage::class); - // $arr [0]= new TestMessage; + // $arr[0] = new TestMessage; // $arr[0]->SetMapRecursive($arr); // // Clean up memory before test. diff --git a/php/tests/memory_leak_test.php b/php/tests/memory_leak_test.php index 4f951a89..6572fdd0 100644 --- a/php/tests/memory_leak_test.php +++ b/php/tests/memory_leak_test.php @@ -49,7 +49,7 @@ TestUtil::assertTestMessage($to); $from->setRecursive($from); $arr = new RepeatedField(GPBType::MESSAGE, TestMessage::class); -$arr []= new TestMessage; +$arr[] = new TestMessage; $arr[0]->SetRepeatedRecursive($arr); // Test oneof fields. diff --git a/php/tests/php_implementation_test.php b/php/tests/php_implementation_test.php index e1249808..5dbc9233 100644 --- a/php/tests/php_implementation_test.php +++ b/php/tests/php_implementation_test.php @@ -6,12 +6,12 @@ require_once('test_util.php'); use Foo\TestMessage; use Foo\TestMessage_Sub; use Foo\TestPackedMessage; -use Google\Protobuf\Internal\InputStream; +use Google\Protobuf\Internal\CodedInputStream; use Google\Protobuf\Internal\FileDescriptorSet; use Google\Protobuf\Internal\GPBLabel; use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\OutputStream; +use Google\Protobuf\Internal\CodedOutputStream; class ImplementationTest extends TestBase { @@ -21,17 +21,17 @@ class ImplementationTest extends TestBase $value = null; // Positive number. - $input = new InputStream(hex2bin("01")); + $input = new CodedInputStream(hex2bin("01")); GPBWire::readInt32($input, $value); $this->assertSame(1, $value); // Negative number. - $input = new InputStream(hex2bin("ffffffff0f")); + $input = new CodedInputStream(hex2bin("ffffffff0f")); GPBWire::readInt32($input, $value); $this->assertSame(-1, $value); // Discard overflow bits. - $input = new InputStream(hex2bin("ffffffff7f")); + $input = new CodedInputStream(hex2bin("ffffffff7f")); GPBWire::readInt32($input, $value); $this->assertSame(-1, $value); } @@ -41,17 +41,17 @@ class ImplementationTest extends TestBase $value = null; // Positive number. - $input = new InputStream(hex2bin("01")); + $input = new CodedInputStream(hex2bin("01")); GPBWire::readUint32($input, $value); $this->assertSame(1, $value); // Max uint32. - $input = new InputStream(hex2bin("ffffffff0f")); + $input = new CodedInputStream(hex2bin("ffffffff0f")); GPBWire::readUint32($input, $value); $this->assertSame(-1, $value); // Discard overflow bits. - $input = new InputStream(hex2bin("ffffffff7f")); + $input = new CodedInputStream(hex2bin("ffffffff7f")); GPBWire::readUint32($input, $value); $this->assertSame(-1, $value); } @@ -61,17 +61,17 @@ class ImplementationTest extends TestBase $value = null; // Positive number. - $input = new InputStream(hex2bin("01")); + $input = new CodedInputStream(hex2bin("01")); GPBWire::readInt64($input, $value); $this->assertEquals(1, $value); // Negative number. - $input = new InputStream(hex2bin("ffffffffffffffffff01")); + $input = new CodedInputStream(hex2bin("ffffffffffffffffff01")); GPBWire::readInt64($input, $value); $this->assertEquals(-1, $value); // Discard overflow bits. - $input = new InputStream(hex2bin("ffffffffffffffffff0f")); + $input = new CodedInputStream(hex2bin("ffffffffffffffffff0f")); GPBWire::readInt64($input, $value); $this->assertEquals(-1, $value); } @@ -81,17 +81,17 @@ class ImplementationTest extends TestBase $value = null; // Positive number. - $input = new InputStream(hex2bin("01")); + $input = new CodedInputStream(hex2bin("01")); GPBWire::readUint64($input, $value); $this->assertEquals(1, $value); // Negative number. - $input = new InputStream(hex2bin("FFFFFFFFFFFFFFFFFF01")); + $input = new CodedInputStream(hex2bin("FFFFFFFFFFFFFFFFFF01")); GPBWire::readUint64($input, $value); $this->assertEquals(-1, $value); // Discard overflow bits. - $input = new InputStream(hex2bin("FFFFFFFFFFFFFFFFFF0F")); + $input = new CodedInputStream(hex2bin("FFFFFFFFFFFFFFFFFF0F")); GPBWire::readUint64($input, $value); $this->assertEquals(-1, $value); } @@ -100,15 +100,15 @@ class ImplementationTest extends TestBase { $value = null; - $input = new InputStream(hex2bin("00")); + $input = new CodedInputStream(hex2bin("00")); GPBWire::readSint32($input, $value); $this->assertSame(0, $value); - $input = new InputStream(hex2bin("01")); + $input = new CodedInputStream(hex2bin("01")); GPBWire::readSint32($input, $value); $this->assertSame(-1, $value); - $input = new InputStream(hex2bin("02")); + $input = new CodedInputStream(hex2bin("02")); GPBWire::readSint32($input, $value); $this->assertSame(1, $value); } @@ -117,15 +117,15 @@ class ImplementationTest extends TestBase { $value = null; - $input = new InputStream(hex2bin("00")); + $input = new CodedInputStream(hex2bin("00")); GPBWire::readSint64($input, $value); $this->assertEquals(0, $value); - $input = new InputStream(hex2bin("01")); + $input = new CodedInputStream(hex2bin("01")); GPBWire::readSint64($input, $value); $this->assertEquals(-1, $value); - $input = new InputStream(hex2bin("02")); + $input = new CodedInputStream(hex2bin("02")); GPBWire::readSint64($input, $value); $this->assertEquals(1, $value); } @@ -133,7 +133,7 @@ class ImplementationTest extends TestBase public function testReadFixed32() { $value = null; - $input = new InputStream(hex2bin("12345678")); + $input = new CodedInputStream(hex2bin("12345678")); GPBWire::readFixed32($input, $value); $this->assertSame(0x78563412, $value); } @@ -141,7 +141,7 @@ class ImplementationTest extends TestBase public function testReadFixed64() { $value = null; - $input = new InputStream(hex2bin("1234567812345678")); + $input = new CodedInputStream(hex2bin("1234567812345678")); GPBWire::readFixed64($input, $value); if (PHP_INT_SIZE == 4) { $this->assertSame("8671175386481439762", $value); @@ -153,7 +153,7 @@ class ImplementationTest extends TestBase public function testReadSfixed32() { $value = null; - $input = new InputStream(hex2bin("12345678")); + $input = new CodedInputStream(hex2bin("12345678")); GPBWire::readSfixed32($input, $value); $this->assertSame(0x78563412, $value); } @@ -161,7 +161,7 @@ class ImplementationTest extends TestBase public function testReadFloat() { $value = null; - $input = new InputStream(hex2bin("0000803F")); + $input = new CodedInputStream(hex2bin("0000803F")); GPBWire::readFloat($input, $value); $this->assertSame(1.0, $value); } @@ -170,11 +170,11 @@ class ImplementationTest extends TestBase { $value = null; - $input = new InputStream(hex2bin("00")); + $input = new CodedInputStream(hex2bin("00")); GPBWire::readBool($input, $value); $this->assertSame(false, $value); - $input = new InputStream(hex2bin("01")); + $input = new CodedInputStream(hex2bin("01")); GPBWire::readBool($input, $value); $this->assertSame(true, $value); } @@ -182,7 +182,7 @@ class ImplementationTest extends TestBase public function testReadDouble() { $value = null; - $input = new InputStream(hex2bin("000000000000F03F")); + $input = new CodedInputStream(hex2bin("000000000000F03F")); GPBWire::readDouble($input, $value); $this->assertSame(1.0, $value); } @@ -190,7 +190,7 @@ class ImplementationTest extends TestBase public function testReadSfixed64() { $value = null; - $input = new InputStream(hex2bin("1234567812345678")); + $input = new CodedInputStream(hex2bin("1234567812345678")); GPBWire::readSfixed64($input, $value); if (PHP_INT_SIZE == 4) { $this->assertSame("8671175386481439762", $value); @@ -207,8 +207,7 @@ class ImplementationTest extends TestBase $this->assertSame(3, GPBWire::zigZagEncode32(-2)); $this->assertSame(0x7FFFFFFE, GPBWire::zigZagEncode32(0x3FFFFFFF)); $this->assertSame(0x7FFFFFFF, GPBWire::zigZagEncode32(0xC0000000)); - $this->assertSame(-2, GPBWire::zigZagEncode32(0x7FFFFFFF)); - $this->assertSame(-1, GPBWire::zigZagEncode32(0x80000000)); + $this->assertSame(0x7FFFFFFF, GPBWire::zigZagEncode32(-1073741824)); $this->assertSame(0, GPBWire::zigZagDecode32(0)); $this->assertSame(-1, GPBWire::zigZagDecode32(1)); @@ -220,6 +219,8 @@ class ImplementationTest extends TestBase $this->assertSame((int)-2147483648,GPBWire::zigZagDecode32(0xFFFFFFFF)); if (PHP_INT_SIZE == 4) { + $this->assertSame(-2, GPBWire::zigZagEncode32(0x7FFFFFFF)); + $this->assertSame(-1, GPBWire::zigZagEncode32(0x80000000)); $this->assertSame('0', GPBWire::zigZagEncode64(0)); $this->assertSame('1', GPBWire::zigZagEncode64(-1)); $this->assertSame('2', GPBWire::zigZagEncode64(1)); @@ -250,6 +251,8 @@ class ImplementationTest extends TestBase $this->assertSame('1', GPBWire::zigZagDecode64(2)); $this->assertSame('-2', GPBWire::zigZagDecode64(3)); } else { + $this->assertSame(4294967294, GPBWire::zigZagEncode32(0x7FFFFFFF)); + $this->assertSame(4294967295, GPBWire::zigZagEncode32(0x80000000)); $this->assertSame(0, GPBWire::zigZagEncode64(0)); $this->assertSame(1, GPBWire::zigZagEncode64(-1)); $this->assertSame(2, GPBWire::zigZagEncode64(1)); @@ -330,19 +333,19 @@ class ImplementationTest extends TestBase $var = 0; // Empty buffer. - $input = new InputStream(hex2bin('')); + $input = new CodedInputStream(hex2bin('')); $this->assertFalse($input->readVarint64($var)); // The largest varint is 10 bytes long. - $input = new InputStream(hex2bin('8080808080808080808001')); + $input = new CodedInputStream(hex2bin('8080808080808080808001')); $this->assertFalse($input->readVarint64($var)); // Corrupted varint. - $input = new InputStream(hex2bin('808080')); + $input = new CodedInputStream(hex2bin('808080')); $this->assertFalse($input->readVarint64($var)); // Normal case. - $input = new InputStream(hex2bin('808001')); + $input = new CodedInputStream(hex2bin('808001')); $this->assertTrue($input->readVarint64($var)); if (PHP_INT_SIZE == 4) { $this->assertSame('16384', $var); @@ -352,7 +355,7 @@ class ImplementationTest extends TestBase $this->assertFalse($input->readVarint64($var)); // Read two varint. - $input = new InputStream(hex2bin('808001808002')); + $input = new CodedInputStream(hex2bin('808001808002')); $this->assertTrue($input->readVarint64($var)); if (PHP_INT_SIZE == 4) { $this->assertSame('16384', $var); @@ -390,7 +393,7 @@ class ImplementationTest extends TestBase ); foreach ($testVals as $original => $encoded) { - $input = new InputStream(hex2bin($encoded)); + $input = new CodedInputStream(hex2bin($encoded)); $this->assertTrue($input->readVarint64($var)); $this->assertEquals($original, $var); } @@ -401,25 +404,25 @@ class ImplementationTest extends TestBase $var = 0; // Empty buffer. - $input = new InputStream(hex2bin('')); + $input = new CodedInputStream(hex2bin('')); $this->assertFalse($input->readVarint32($var)); // The largest varint is 10 bytes long. - $input = new InputStream(hex2bin('8080808080808080808001')); + $input = new CodedInputStream(hex2bin('8080808080808080808001')); $this->assertFalse($input->readVarint32($var)); // Corrupted varint. - $input = new InputStream(hex2bin('808080')); + $input = new CodedInputStream(hex2bin('808080')); $this->assertFalse($input->readVarint32($var)); // Normal case. - $input = new InputStream(hex2bin('808001')); + $input = new CodedInputStream(hex2bin('808001')); $this->assertTrue($input->readVarint32($var)); $this->assertSame(16384, $var); $this->assertFalse($input->readVarint32($var)); // Read two varint. - $input = new InputStream(hex2bin('808001808002')); + $input = new CodedInputStream(hex2bin('808001808002')); $this->assertTrue($input->readVarint32($var)); $this->assertSame(16384, $var); $this->assertTrue($input->readVarint32($var)); @@ -427,7 +430,7 @@ class ImplementationTest extends TestBase $this->assertFalse($input->readVarint32($var)); // Read a 64-bit integer. High-order bits should be discarded. - $input = new InputStream(hex2bin('808081808001')); + $input = new CodedInputStream(hex2bin('808081808001')); $this->assertTrue($input->readVarint32($var)); $this->assertSame(16384, $var); $this->assertFalse($input->readVarint32($var)); @@ -435,7 +438,7 @@ class ImplementationTest extends TestBase public function testReadTag() { - $input = new InputStream(hex2bin('808001')); + $input = new CodedInputStream(hex2bin('808001')); $tag = $input->readTag(); $this->assertSame(16384, $tag); $tag = $input->readTag(); @@ -444,7 +447,7 @@ class ImplementationTest extends TestBase public function testPushPopLimit() { - $input = new InputStream(hex2bin('808001')); + $input = new CodedInputStream(hex2bin('808001')); $old_limit = $input->pushLimit(0); $tag = $input->readTag(); $this->assertSame(0, $tag); @@ -455,7 +458,7 @@ class ImplementationTest extends TestBase public function testReadRaw() { - $input = new InputStream(hex2bin('808001')); + $input = new CodedInputStream(hex2bin('808001')); $buffer = null; $this->assertTrue($input->readRaw(3, $buffer)); @@ -466,33 +469,33 @@ class ImplementationTest extends TestBase public function testWriteVarint32() { - $output = new OutputStream(3); - $output->writeVarint32(16384); + $output = new CodedOutputStream(3); + $output->writeVarint32(16384, true); $this->assertSame(hex2bin('808001'), $output->getData()); // Negative numbers are padded to be compatible with int64. - $output = new OutputStream(10); - $output->writeVarint32(-43); + $output = new CodedOutputStream(10); + $output->writeVarint32(-43, false); $this->assertSame(hex2bin('D5FFFFFFFFFFFFFFFF01'), $output->getData()); } public function testWriteVarint64() { - $output = new OutputStream(10); + $output = new CodedOutputStream(10); $output->writeVarint64(-43); $this->assertSame(hex2bin('D5FFFFFFFFFFFFFFFF01'), $output->getData()); } public function testWriteLittleEndian32() { - $output = new OutputStream(4); + $output = new CodedOutputStream(4); $output->writeLittleEndian32(46); $this->assertSame(hex2bin('2E000000'), $output->getData()); } public function testWriteLittleEndian64() { - $output = new OutputStream(8); + $output = new CodedOutputStream(8); $output->writeLittleEndian64(47); $this->assertSame(hex2bin('2F00000000000000'), $output->getData()); } diff --git a/php/tests/test_base.php b/php/tests/test_base.php index 67048f4c..dc5e73f5 100644 --- a/php/tests/test_base.php +++ b/php/tests/test_base.php @@ -19,6 +19,8 @@ class TestBase extends PHPUnit_Framework_TestCase public function expectFields(TestMessage $m) { + $this->assertSame(-42, $m->getOptionalInt32()); + $this->assertSame(42, $m->getOptionalUint32()); $this->assertSame(-44, $m->getOptionalSint32()); $this->assertSame(46, $m->getOptionalFixed32()); $this->assertSame(-46, $m->getOptionalSfixed32()); @@ -27,6 +29,7 @@ class TestBase extends PHPUnit_Framework_TestCase $this->assertSame(true, $m->getOptionalBool()); $this->assertSame('a', $m->getOptionalString()); $this->assertSame('b', $m->getOptionalBytes()); + $this->assertSame(TestEnum::ONE, $m->getOptionalEnum()); $this->assertSame(33, $m->getOptionalMessage()->getA()); if (PHP_INT_SIZE == 4) { $this->assertSame('-43', $m->getOptionalInt64()); diff --git a/php/tests/undefined_test.php b/php/tests/undefined_test.php new file mode 100644 index 00000000..dc6b7086 --- /dev/null +++ b/php/tests/undefined_test.php @@ -0,0 +1,920 @@ +assertSame(3, count($arr)); + + unset($arr[1]); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testRemoveEmptyFail() + { + $arr = new RepeatedField(GPBType::INT32); + + unset($arr[0]); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageOffsetFail() + { + $arr = new RepeatedField(GPBType::INT32); + $arr[] = 0; + $arr[new TestMessage_Sub()] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testStringOffsetFail() + { + $arr = new RepeatedField(GPBType::INT32); + $arr[] = 0; + $arr['abc'] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testSetNonExistedOffsetFail() + { + $arr = new RepeatedField(GPBType::INT32); + $arr[0] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt32FieldInvalidTypeFail() + { + $m = new TestMessage(); + $m->setOptionalInt32(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt32FieldInvalidStringFail() + { + $m = new TestMessage(); + $m->setOptionalInt32('abc'); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint32FieldInvalidTypeFail() + { + $m = new TestMessage(); + $m->setOptionalUint32(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint32FieldInvalidStringFail() + { + $m = new TestMessage(); + $m->setOptionalUint32('abc'); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt64FieldInvalidTypeFail() + { + $m = new TestMessage(); + $m->setOptionalInt64(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt64FieldInvalidStringFail() + { + $m = new TestMessage(); + $m->setOptionalInt64('abc'); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint64FieldInvalidTypeFail() + { + $m = new TestMessage(); + $m->setOptionalUint64(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint64FieldInvalidStringFail() + { + $m = new TestMessage(); + $m->setOptionalUint64('abc'); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testFloatFieldInvalidTypeFail() + { + $m = new TestMessage(); + $m->setOptionalFloat(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testFloatFieldInvalidStringFail() + { + $m = new TestMessage(); + $m->setOptionalFloat('abc'); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testDoubleFieldInvalidTypeFail() + { + $m = new TestMessage(); + $m->setOptionalDouble(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testDoubleFieldInvalidStringFail() + { + $m = new TestMessage(); + $m->setOptionalDouble('abc'); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testBoolFieldInvalidStringFail() + { + $m = new TestMessage(); + $m->setOptionalBool(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testStringFieldInvalidUTF8Fail() + { + $m = new TestMessage(); + $hex = hex2bin("ff"); + $m->setOptionalString($hex); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageFieldWrongTypeFail() + { + $m = new TestMessage(); + $a = 1; + $m->setOptionalMessage($a); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageFieldWrongClassFail() + { + $m = new TestMessage(); + $m->setOptionalMessage(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testRepeatedFieldWrongTypeFail() + { + $m = new TestMessage(); + $a = 1; + $m->setRepeatedInt32($a); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testRepeatedFieldWrongObjectFail() + { + $m = new TestMessage(); + $m->setRepeatedInt32($m); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testRepeatedFieldWrongRepeatedTypeFail() + { + $m = new TestMessage(); + + $repeated_int32 = new RepeatedField(GPBType::UINT32); + $m->setRepeatedInt32($repeated_int32); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testRepeatedFieldWrongRepeatedMessageClassFail() + { + $m = new TestMessage(); + + $repeated_message = new RepeatedField(GPBType::MESSAGE, + TestMessage::class); + $m->setRepeatedMessage($repeated_message); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMapFieldWrongTypeFail() + { + $m = new TestMessage(); + $a = 1; + $m->setMapInt32Int32($a); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMapFieldWrongObjectFail() + { + $m = new TestMessage(); + $m->setMapInt32Int32($m); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMapFieldWrongRepeatedTypeFail() + { + $m = new TestMessage(); + + $map_uint32_uint32 = new MapField(GPBType::UINT32, GPBType::UINT32); + $m->setMapInt32Int32($map_uint32_uint32); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMapFieldWrongRepeatedMessageClassFail() + { + $m = new TestMessage(); + + $map_int32_message = new MapField(GPBType::INT32, + GPBType::MESSAGE, + TestMessage::class); + $m->setMapInt32Message($map_int32_message); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageMergeFromInvalidTypeFail() + { + $m = new TestMessage(); + $n = new TestMessage_Sub(); + $m->mergeFrom($n); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt32SetStringKeyFail() + { + $arr = new MapField(GPBType::INT32, GPBType::INT32); + $arr['abc'] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt32SetStringValueFail() + { + $arr = new MapField(GPBType::INT32, GPBType::INT32); + $arr[0] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt32SetMessageKeyFail() + { + $arr = new MapField(GPBType::INT32, GPBType::INT32); + $arr[new TestMessage_Sub()] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt32SetMessageValueFail() + { + $arr = new MapField(GPBType::INT32, GPBType::INT32); + $arr[0] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint32SetStringKeyFail() + { + $arr = new MapField(GPBType::UINT32, GPBType::UINT32); + $arr['abc'] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint32SetStringValueFail() + { + $arr = new MapField(GPBType::UINT32, GPBType::UINT32); + $arr[0] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint32SetMessageKeyFail() + { + $arr = new MapField(GPBType::UINT32, GPBType::UINT32); + $arr[new TestMessage_Sub()] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint32SetMessageValueFail() + { + $arr = new MapField(GPBType::UINT32, GPBType::UINT32); + $arr[0] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt64SetStringKeyFail() + { + $arr = new MapField(GPBType::INT64, GPBType::INT64); + $arr['abc'] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt64SetStringValueFail() + { + $arr = new MapField(GPBType::INT64, GPBType::INT64); + $arr[0] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt64SetMessageKeyFail() + { + $arr = new MapField(GPBType::INT64, GPBType::INT64); + $arr[new TestMessage_Sub()] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt64SetMessageValueFail() + { + $arr = new MapField(GPBType::INT64, GPBType::INT64); + $arr[0] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint64SetStringKeyFail() + { + $arr = new MapField(GPBType::UINT64, GPBType::UINT64); + $arr['abc'] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint64SetStringValueFail() + { + $arr = new MapField(GPBType::UINT64, GPBType::UINT64); + $arr[0] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint64SetMessageKeyFail() + { + $arr = new MapField(GPBType::UINT64, GPBType::UINT64); + $arr[new TestMessage_Sub()] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint64SetMessageValueFail() + { + $arr = new MapField(GPBType::UINT64, GPBType::UINT64); + $arr[0] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testDoubleSetStringValueFail() + { + $arr = new MapField(GPBType::INT64, GPBType::DOUBLE); + $arr[0] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testDoubleSetMessageValueFail() + { + $arr = new MapField(GPBType::INT64, GPBType::DOUBLE); + $arr[0] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testBoolSetMessageKeyFail() + { + $arr = new MapField(GPBType::BOOL, GPBType::BOOL); + $arr[new TestMessage_Sub()] = true; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testBoolSetMessageValueFail() + { + $arr = new MapField(GPBType::BOOL, GPBType::BOOL); + $arr[true] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testStringSetInvalidUTF8KeyFail() + { + $arr = new MapField(GPBType::STRING, GPBType::STRING); + $arr[hex2bin("ff")] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testStringSetInvalidUTF8ValueFail() + { + $arr = new MapField(GPBType::STRING, GPBType::STRING); + $arr['abc'] = hex2bin("ff"); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testStringSetMessageKeyFail() + { + $arr = new MapField(GPBType::STRING, GPBType::STRING); + $arr[new TestMessage_Sub()] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testStringSetMessageValueFail() + { + $arr = new MapField(GPBType::STRING, GPBType::STRING); + $arr['abc'] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageSetIntValueFail() + { + $arr = + new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); + $arr[0] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageSetStringValueFail() + { + $arr = + new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); + $arr[0] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageSetOtherMessageValueFail() + { + $arr = + new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); + $arr[0] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageSetNullFail() + { + $arr = + new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); + $null = NULL; + $arr[0] = $null; + } + +} diff --git a/tests.sh b/tests.sh index 5d11c857..b40f0c5d 100755 --- a/tests.sh +++ b/tests.sh @@ -397,27 +397,30 @@ build_php5.5() { phpunit popd pushd conformance - # TODO(teboring): Add it back - # make test_php + make test_php popd } build_php5.5_c() { use_php 5.5 wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit - cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance - # make test_php_c + pushd php/tests + /bin/bash ./test.sh popd + # TODO(teboring): Add it back + # pushd conformance + # make test_php_c + # popd } build_php5.5_zts_c() { use_php_zts 5.5 wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance - # make test_php_c - popd + # TODO(teboring): Add it back + # pushd conformance + # make test_php_zts_c + # popd } build_php5.6() { @@ -429,8 +432,7 @@ build_php5.6() { phpunit popd pushd conformance - # TODO(teboring): Add it back - # make test_php + make test_php popd } @@ -438,18 +440,20 @@ build_php5.6_c() { use_php 5.6 wget https://phar.phpunit.de/phpunit-5.7.0.phar -O /usr/bin/phpunit cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance + # TODO(teboring): Add it back + # pushd conformance # make test_php_c - popd + # popd } build_php5.6_zts_c() { use_php_zts 5.6 wget https://phar.phpunit.de/phpunit-5.7.0.phar -O /usr/bin/phpunit cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance - # make test_php_c - popd + # TODO(teboring): Add it back + # pushd conformance + # make test_php_zts_c + # popd } build_php5.6_mac() { @@ -471,9 +475,10 @@ build_php5.6_mac() { # Test cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance + # TODO(teboring): Add it back + # pushd conformance # make test_php_c - popd + # popd } build_php7.0() { @@ -485,8 +490,7 @@ build_php7.0() { phpunit popd pushd conformance - # TODO(teboring): Add it back - # make test_php + make test_php popd } @@ -494,18 +498,20 @@ build_php7.0_c() { use_php 7.0 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance + # TODO(teboring): Add it back + # pushd conformance # make test_php_c - popd + # popd } build_php7.0_zts_c() { use_php_zts 7.0 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance - # make test_php_c - popd + # TODO(teboring): Add it back. + # pushd conformance + # make test_php_zts_c + # popd } build_php7.0_mac() { @@ -527,9 +533,10 @@ build_php7.0_mac() { # Test cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance + # TODO(teboring): Add it back + # pushd conformance # make test_php_c - popd + # popd } build_php_compatibility() { -- cgit v1.2.3 From 126082c371d2320255ac8ff7d68bef25a919572d Mon Sep 17 00:00:00 2001 From: tanderson-google Date: Sun, 9 Jul 2017 20:31:50 -0700 Subject: Add std:: namespace prefix to set and map (#3332) * Remove using std::{set,map} --- conformance/conformance_test.cc | 6 +++--- conformance/conformance_test.h | 2 +- .../protobuf/compiler/csharp/csharp_field_base.cc | 4 ++-- .../protobuf/compiler/csharp/csharp_field_base.h | 6 +++--- src/google/protobuf/compiler/csharp/csharp_message.cc | 8 ++++---- .../protobuf/compiler/javanano/javanano_enum_field.cc | 2 +- .../protobuf/compiler/javanano/javanano_enum_field.h | 6 +++--- .../protobuf/compiler/javanano/javanano_extension.cc | 2 +- .../protobuf/compiler/javanano/javanano_extension.h | 2 +- .../protobuf/compiler/javanano/javanano_field.cc | 6 +++--- src/google/protobuf/compiler/javanano/javanano_field.h | 6 +++--- .../protobuf/compiler/javanano/javanano_helpers.cc | 2 +- .../protobuf/compiler/javanano/javanano_helpers.h | 2 +- .../protobuf/compiler/javanano/javanano_map_field.cc | 2 +- .../protobuf/compiler/javanano/javanano_map_field.h | 2 +- .../protobuf/compiler/javanano/javanano_message.cc | 2 +- .../compiler/javanano/javanano_message_field.cc | 2 +- .../compiler/javanano/javanano_message_field.h | 6 +++--- .../protobuf/compiler/javanano/javanano_params.h | 4 ++-- .../compiler/javanano/javanano_primitive_field.cc | 2 +- .../compiler/javanano/javanano_primitive_field.h | 8 ++++---- .../compiler/objectivec/objectivec_enum_field.cc | 4 ++-- .../compiler/objectivec/objectivec_enum_field.h | 2 +- .../compiler/objectivec/objectivec_extension.cc | 4 ++-- .../protobuf/compiler/objectivec/objectivec_field.cc | 4 ++-- .../protobuf/compiler/objectivec/objectivec_field.h | 4 ++-- .../protobuf/compiler/objectivec/objectivec_file.cc | 14 +++++++------- .../protobuf/compiler/objectivec/objectivec_helpers.cc | 18 +++++++++--------- .../protobuf/compiler/objectivec/objectivec_helpers.h | 6 +++--- .../compiler/objectivec/objectivec_map_field.cc | 2 +- .../compiler/objectivec/objectivec_map_field.h | 2 +- .../protobuf/compiler/objectivec/objectivec_message.cc | 4 ++-- .../protobuf/compiler/objectivec/objectivec_message.h | 2 +- .../compiler/objectivec/objectivec_message_field.cc | 6 +++--- .../compiler/objectivec/objectivec_message_field.h | 4 ++-- .../protobuf/compiler/objectivec/objectivec_oneof.h | 2 +- .../compiler/objectivec/objectivec_primitive_field.cc | 2 +- src/google/protobuf/stubs/common.h | 2 -- src/google/protobuf/testing/googletest.h | 2 +- 39 files changed, 82 insertions(+), 84 deletions(-) (limited to 'conformance') diff --git a/conformance/conformance_test.cc b/conformance/conformance_test.cc index 67c90397..8fa9f53c 100644 --- a/conformance/conformance_test.cc +++ b/conformance/conformance_test.cc @@ -677,7 +677,7 @@ void ConformanceTestSuite::SetFailureList(const string& filename, std::inserter(expected_to_fail_, expected_to_fail_.end())); } -bool ConformanceTestSuite::CheckSetEmpty(const set& set_to_check, +bool ConformanceTestSuite::CheckSetEmpty(const std::set& set_to_check, const std::string& write_to_file, const std::string& msg) { if (set_to_check.empty()) { @@ -685,7 +685,7 @@ bool ConformanceTestSuite::CheckSetEmpty(const set& set_to_check, } else { StringAppendF(&output_, "\n"); StringAppendF(&output_, "%s\n\n", msg.c_str()); - for (set::const_iterator iter = set_to_check.begin(); + for (std::set::const_iterator iter = set_to_check.begin(); iter != set_to_check.end(); ++iter) { StringAppendF(&output_, " %s\n", iter->c_str()); } @@ -694,7 +694,7 @@ bool ConformanceTestSuite::CheckSetEmpty(const set& set_to_check, if (!write_to_file.empty()) { std::ofstream os(write_to_file); if (os) { - for (set::const_iterator iter = set_to_check.begin(); + for (std::set::const_iterator iter = set_to_check.begin(); iter != set_to_check.end(); ++iter) { os << *iter << "\n"; } diff --git a/conformance/conformance_test.h b/conformance/conformance_test.h index 4e40a6ac..581c7472 100644 --- a/conformance/conformance_test.h +++ b/conformance/conformance_test.h @@ -205,7 +205,7 @@ class ConformanceTestSuite { void TestValidDataForType( google::protobuf::FieldDescriptor::Type, std::vector> values); - bool CheckSetEmpty(const set& set_to_check, + bool CheckSetEmpty(const std::set& set_to_check, const std::string& write_to_file, const std::string& msg); ConformanceTestRunner* runner_; int successes_; diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index ebb8fbc2..ecf29ece 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -54,7 +54,7 @@ namespace compiler { namespace csharp { void FieldGeneratorBase::SetCommonFieldVariables( - map* variables) { + std::map* variables) { // Note: this will be valid even though the tag emitted for packed and unpacked versions of // repeated fields varies by wire format. The wire format is encoded in the bottom 3 bits, which // never effects the tag size. @@ -92,7 +92,7 @@ void FieldGeneratorBase::SetCommonFieldVariables( } void FieldGeneratorBase::SetCommonOneofFieldVariables( - map* variables) { + std::map* variables) { (*variables)["oneof_name"] = oneof_name(); (*variables)["has_property_check"] = oneof_name() + "Case_ == " + oneof_property_name() + diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.h b/src/google/protobuf/compiler/csharp/csharp_field_base.h index 4109f3ca..df26853b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.h @@ -66,14 +66,14 @@ class FieldGeneratorBase : public SourceGeneratorBase { protected: const FieldDescriptor* descriptor_; const int fieldOrdinal_; - map variables_; + std::map variables_; void AddDeprecatedFlag(io::Printer* printer); void AddNullCheck(io::Printer* printer); void AddNullCheck(io::Printer* printer, const std::string& name); void AddPublicMemberAttributes(io::Printer* printer); - void SetCommonOneofFieldVariables(map* variables); + void SetCommonOneofFieldVariables(std::map* variables); std::string oneof_property_name(); std::string oneof_name(); @@ -89,7 +89,7 @@ class FieldGeneratorBase : public SourceGeneratorBase { std::string capitalized_type_name(); private: - void SetCommonFieldVariables(map* variables); + void SetCommonFieldVariables(std::map* variables); std::string GetStringDefaultValueInternal(); std::string GetBytesDefaultValueInternal(); diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 0f00a438..5ef0e4e8 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -105,7 +105,7 @@ void MessageGenerator::AddDeprecatedFlag(io::Printer* printer) { } void MessageGenerator::Generate(io::Printer* printer) { - map vars; + std::map vars; vars["class_name"] = class_name(); vars["access_level"] = class_access_level(); @@ -280,7 +280,7 @@ bool MessageGenerator::HasNestedGeneratedTypes() } void MessageGenerator::GenerateCloningCode(io::Printer* printer) { - map vars; + std::map vars; WriteGeneratedCodeAttributes(printer); vars["class_name"] = class_name(); printer->Print( @@ -333,7 +333,7 @@ void MessageGenerator::GenerateFreezingCode(io::Printer* printer) { } void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) { - map vars; + std::map vars; vars["class_name"] = class_name(); // Equality @@ -432,7 +432,7 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { // Note: These are separate from GenerateMessageSerializationMethods() // because they need to be generated even for messages that are optimized // for code size. - map vars; + std::map vars; vars["class_name"] = class_name(); WriteGeneratedCodeAttributes(printer); diff --git a/src/google/protobuf/compiler/javanano/javanano_enum_field.cc b/src/google/protobuf/compiler/javanano/javanano_enum_field.cc index 7666db38..26bc7f85 100644 --- a/src/google/protobuf/compiler/javanano/javanano_enum_field.cc +++ b/src/google/protobuf/compiler/javanano/javanano_enum_field.cc @@ -52,7 +52,7 @@ namespace { // TODO(kenton): Factor out a "SetCommonFieldVariables()" to get rid of // repeat code between this and the other field types. void SetEnumVariables(const Params& params, - const FieldDescriptor* descriptor, map* variables) { + const FieldDescriptor* descriptor, std::map* variables) { (*variables)["name"] = RenameJavaKeywords(UnderscoresToCamelCase(descriptor)); (*variables)["capitalized_name"] = diff --git a/src/google/protobuf/compiler/javanano/javanano_enum_field.h b/src/google/protobuf/compiler/javanano/javanano_enum_field.h index b94790d6..1be25d10 100644 --- a/src/google/protobuf/compiler/javanano/javanano_enum_field.h +++ b/src/google/protobuf/compiler/javanano/javanano_enum_field.h @@ -62,7 +62,7 @@ class EnumFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map variables_; + std::map variables_; vector canonical_values_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator); @@ -85,7 +85,7 @@ class AccessorEnumFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map variables_; + std::map variables_; vector canonical_values_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(AccessorEnumFieldGenerator); @@ -112,7 +112,7 @@ class RepeatedEnumFieldGenerator : public FieldGenerator { void GenerateRepeatedDataSizeCode(io::Printer* printer) const; const FieldDescriptor* descriptor_; - map variables_; + std::map variables_; vector canonical_values_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator); diff --git a/src/google/protobuf/compiler/javanano/javanano_extension.cc b/src/google/protobuf/compiler/javanano/javanano_extension.cc index 0b9d1d8d..4c61f915 100644 --- a/src/google/protobuf/compiler/javanano/javanano_extension.cc +++ b/src/google/protobuf/compiler/javanano/javanano_extension.cc @@ -78,7 +78,7 @@ const char* GetTypeConstantName(const FieldDescriptor::Type type) { } // namespace void SetVariables(const FieldDescriptor* descriptor, const Params params, - map* variables) { + std::map* variables) { (*variables)["extends"] = ClassName(params, descriptor->containing_type()); (*variables)["name"] = RenameJavaKeywords(UnderscoresToCamelCase(descriptor)); bool repeated = descriptor->is_repeated(); diff --git a/src/google/protobuf/compiler/javanano/javanano_extension.h b/src/google/protobuf/compiler/javanano/javanano_extension.h index 4843e296..f4e9eb2d 100644 --- a/src/google/protobuf/compiler/javanano/javanano_extension.h +++ b/src/google/protobuf/compiler/javanano/javanano_extension.h @@ -61,7 +61,7 @@ class ExtensionGenerator { private: const Params& params_; const FieldDescriptor* descriptor_; - map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); }; diff --git a/src/google/protobuf/compiler/javanano/javanano_field.cc b/src/google/protobuf/compiler/javanano/javanano_field.cc index 85257f3f..e31d1177 100644 --- a/src/google/protobuf/compiler/javanano/javanano_field.cc +++ b/src/google/protobuf/compiler/javanano/javanano_field.cc @@ -151,7 +151,7 @@ const FieldGenerator& FieldGeneratorMap::get( } void SetCommonOneofVariables(const FieldDescriptor* descriptor, - map* variables) { + std::map* variables) { (*variables)["oneof_name"] = UnderscoresToCamelCase(descriptor->containing_oneof()); (*variables)["oneof_capitalized_name"] = @@ -169,7 +169,7 @@ void SetCommonOneofVariables(const FieldDescriptor* descriptor, } void GenerateOneofFieldEquals(const FieldDescriptor* descriptor, - const map& variables, + const std::map& variables, io::Printer* printer) { if (GetJavaType(descriptor) == JAVATYPE_BYTES) { printer->Print(variables, @@ -190,7 +190,7 @@ void GenerateOneofFieldEquals(const FieldDescriptor* descriptor, } void GenerateOneofFieldHashCode(const FieldDescriptor* descriptor, - const map& variables, + const std::map& variables, io::Printer* printer) { if (GetJavaType(descriptor) == JAVATYPE_BYTES) { printer->Print(variables, diff --git a/src/google/protobuf/compiler/javanano/javanano_field.h b/src/google/protobuf/compiler/javanano/javanano_field.h index 57c221f4..347c888c 100644 --- a/src/google/protobuf/compiler/javanano/javanano_field.h +++ b/src/google/protobuf/compiler/javanano/javanano_field.h @@ -114,12 +114,12 @@ class FieldGeneratorMap { }; void SetCommonOneofVariables(const FieldDescriptor* descriptor, - map* variables); + std::map* variables); void GenerateOneofFieldEquals(const FieldDescriptor* descriptor, - const map& variables, + const std::map& variables, io::Printer* printer); void GenerateOneofFieldHashCode(const FieldDescriptor* descriptor, - const map& variables, + const std::map& variables, io::Printer* printer); } // namespace javanano diff --git a/src/google/protobuf/compiler/javanano/javanano_helpers.cc b/src/google/protobuf/compiler/javanano/javanano_helpers.cc index 5018250c..1927ba12 100644 --- a/src/google/protobuf/compiler/javanano/javanano_helpers.cc +++ b/src/google/protobuf/compiler/javanano/javanano_helpers.cc @@ -567,7 +567,7 @@ string GenerateDifferentBit(int bit_index) { } void SetBitOperationVariables(const string name, - int bitIndex, map* variables) { + int bitIndex, std::map* variables) { (*variables)["get_" + name] = GenerateGetBit(bitIndex); (*variables)["set_" + name] = GenerateSetBit(bitIndex); (*variables)["clear_" + name] = GenerateClearBit(bitIndex); diff --git a/src/google/protobuf/compiler/javanano/javanano_helpers.h b/src/google/protobuf/compiler/javanano/javanano_helpers.h index 014c85ae..04b2d633 100644 --- a/src/google/protobuf/compiler/javanano/javanano_helpers.h +++ b/src/google/protobuf/compiler/javanano/javanano_helpers.h @@ -181,7 +181,7 @@ string GenerateDifferentBit(int bit_index); // the given name of the bit, to the appropriate Java expressions for the given // bit index. void SetBitOperationVariables(const string name, - int bitIndex, map* variables); + int bitIndex, std::map* variables); inline bool IsMapEntry(const Descriptor* descriptor) { // TODO(liujisi): Add an option to turn on maps for proto2 syntax as well. diff --git a/src/google/protobuf/compiler/javanano/javanano_map_field.cc b/src/google/protobuf/compiler/javanano/javanano_map_field.cc index 83b2b0ce..a4ab8858 100644 --- a/src/google/protobuf/compiler/javanano/javanano_map_field.cc +++ b/src/google/protobuf/compiler/javanano/javanano_map_field.cc @@ -84,7 +84,7 @@ const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) { } void SetMapVariables(const Params& params, - const FieldDescriptor* descriptor, map* variables) { + const FieldDescriptor* descriptor, std::map* variables) { const FieldDescriptor* key = KeyField(descriptor); const FieldDescriptor* value = ValueField(descriptor); (*variables)["name"] = diff --git a/src/google/protobuf/compiler/javanano/javanano_map_field.h b/src/google/protobuf/compiler/javanano/javanano_map_field.h index c01bde38..81e5915d 100644 --- a/src/google/protobuf/compiler/javanano/javanano_map_field.h +++ b/src/google/protobuf/compiler/javanano/javanano_map_field.h @@ -58,7 +58,7 @@ class MapFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator); }; diff --git a/src/google/protobuf/compiler/javanano/javanano_message.cc b/src/google/protobuf/compiler/javanano/javanano_message.cc index f81f7f9a..78421887 100644 --- a/src/google/protobuf/compiler/javanano/javanano_message.cc +++ b/src/google/protobuf/compiler/javanano/javanano_message.cc @@ -182,7 +182,7 @@ void MessageGenerator::Generate(io::Printer* printer) { } // oneof - map vars; + std::map vars; vars["message_name"] = descriptor_->name(); for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { const OneofDescriptor* oneof_desc = descriptor_->oneof_decl(i); diff --git a/src/google/protobuf/compiler/javanano/javanano_message_field.cc b/src/google/protobuf/compiler/javanano/javanano_message_field.cc index d1d04b52..2ed8a3aa 100644 --- a/src/google/protobuf/compiler/javanano/javanano_message_field.cc +++ b/src/google/protobuf/compiler/javanano/javanano_message_field.cc @@ -54,7 +54,7 @@ namespace { // TODO(kenton): Factor out a "SetCommonFieldVariables()" to get rid of // repeat code between this and the other field types. void SetMessageVariables(const Params& params, - const FieldDescriptor* descriptor, map* variables) { + const FieldDescriptor* descriptor, std::map* variables) { (*variables)["name"] = RenameJavaKeywords(UnderscoresToCamelCase(descriptor)); (*variables)["capitalized_name"] = diff --git a/src/google/protobuf/compiler/javanano/javanano_message_field.h b/src/google/protobuf/compiler/javanano/javanano_message_field.h index e074735c..0ae8879b 100644 --- a/src/google/protobuf/compiler/javanano/javanano_message_field.h +++ b/src/google/protobuf/compiler/javanano/javanano_message_field.h @@ -62,7 +62,7 @@ class MessageFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator); }; @@ -85,7 +85,7 @@ class MessageOneofFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator); }; @@ -108,7 +108,7 @@ class RepeatedMessageFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator); }; diff --git a/src/google/protobuf/compiler/javanano/javanano_params.h b/src/google/protobuf/compiler/javanano/javanano_params.h index e3b4bb93..3594767d 100644 --- a/src/google/protobuf/compiler/javanano/javanano_params.h +++ b/src/google/protobuf/compiler/javanano/javanano_params.h @@ -47,8 +47,8 @@ enum eMultipleFiles { JAVANANO_MUL_UNSET, JAVANANO_MUL_FALSE, JAVANANO_MUL_TRUE // Parameters for used by the generators class Params { public: - typedef map NameMap; - typedef set NameSet; + typedef std::map NameMap; + typedef std::set NameSet; private: string empty_; string base_name_; diff --git a/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc b/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc index 978abf2c..66a0ff05 100644 --- a/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc +++ b/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc @@ -166,7 +166,7 @@ bool AllAscii(const string& text) { void SetPrimitiveVariables(const FieldDescriptor* descriptor, const Params params, - map* variables) { + std::map* variables) { (*variables)["name"] = RenameJavaKeywords(UnderscoresToCamelCase(descriptor)); (*variables)["capitalized_name"] = diff --git a/src/google/protobuf/compiler/javanano/javanano_primitive_field.h b/src/google/protobuf/compiler/javanano/javanano_primitive_field.h index a01981dd..d7d72d57 100644 --- a/src/google/protobuf/compiler/javanano/javanano_primitive_field.h +++ b/src/google/protobuf/compiler/javanano/javanano_primitive_field.h @@ -65,7 +65,7 @@ class PrimitiveFieldGenerator : public FieldGenerator { void GenerateSerializationConditional(io::Printer* printer) const; const FieldDescriptor* descriptor_; - map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator); }; @@ -89,7 +89,7 @@ class AccessorPrimitiveFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(AccessorPrimitiveFieldGenerator); }; @@ -111,7 +111,7 @@ class PrimitiveOneofFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveOneofFieldGenerator); }; @@ -137,7 +137,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator { void GenerateRepeatedDataSizeCode(io::Printer* printer) const; const FieldDescriptor* descriptor_; - map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator); }; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc index 7a774a09..8899a13a 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc @@ -46,7 +46,7 @@ namespace objectivec { namespace { void SetEnumVariables(const FieldDescriptor* descriptor, - map* variables) { + std::map* variables) { string type = EnumName(descriptor->enum_type()); (*variables)["storage_type"] = type; // For non repeated fields, if it was defined in a different file, the @@ -118,7 +118,7 @@ void EnumFieldGenerator::GenerateCFunctionImplementations( } void EnumFieldGenerator::DetermineForwardDeclarations( - set* fwd_decls) const { + std::set* fwd_decls) const { SingleFieldGenerator::DetermineForwardDeclarations(fwd_decls); // If it is an enum defined in a different file, then we'll need a forward // declaration for it. When it is in our file, all the enums are output diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h b/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h index 946faa81..ae56c069 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h @@ -47,7 +47,7 @@ class EnumFieldGenerator : public SingleFieldGenerator { public: virtual void GenerateCFunctionDeclarations(io::Printer* printer) const; virtual void GenerateCFunctionImplementations(io::Printer* printer) const; - virtual void DetermineForwardDeclarations(set* fwd_decls) const; + virtual void DetermineForwardDeclarations(std::set* fwd_decls) const; protected: EnumFieldGenerator(const FieldDescriptor* descriptor, const Options& options); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc index 73e4b86e..b788d0a3 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc @@ -59,7 +59,7 @@ ExtensionGenerator::ExtensionGenerator(const string& root_class_name, ExtensionGenerator::~ExtensionGenerator() {} void ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) { - map vars; + std::map vars; vars["method_name"] = method_name_; SourceLocation location; if (descriptor_->GetSourceLocation(&location)) { @@ -77,7 +77,7 @@ void ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) { void ExtensionGenerator::GenerateStaticVariablesInitialization( io::Printer* printer) { - map vars; + std::map vars; vars["root_class_and_method_name"] = root_class_and_method_name_; vars["extended_type"] = ClassName(descriptor_->containing_type()); vars["number"] = SimpleItoa(descriptor_->number()); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_field.cc index 9f7e84f2..b6123fad 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_field.cc @@ -49,7 +49,7 @@ namespace objectivec { namespace { void SetCommonFieldVariables(const FieldDescriptor* descriptor, - map* variables) { + std::map* variables) { string camel_case_name = FieldName(descriptor); string raw_field_name; if (descriptor->type() == FieldDescriptor::TYPE_GROUP) { @@ -178,7 +178,7 @@ void FieldGenerator::GenerateCFunctionImplementations( } void FieldGenerator::DetermineForwardDeclarations( - set* fwd_decls) const { + std::set* fwd_decls) const { // Nothing } diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.h b/src/google/protobuf/compiler/objectivec/objectivec_field.h index a3a4b1b6..6bd5db2e 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_field.h @@ -67,7 +67,7 @@ class FieldGenerator { virtual void GenerateCFunctionImplementations(io::Printer* printer) const; // Exposed for subclasses, should always call it on the parent class also. - virtual void DetermineForwardDeclarations(set* fwd_decls) const; + virtual void DetermineForwardDeclarations(std::set* fwd_decls) const; // Used during generation, not intended to be extended by subclasses. void GenerateFieldDescription( @@ -100,7 +100,7 @@ class FieldGenerator { virtual bool WantsHasProperty(void) const = 0; const FieldDescriptor* descriptor_; - map variables_; + std::map variables_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/src/google/protobuf/compiler/objectivec/objectivec_file.cc index 7ad127bb..954b2688 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_file.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_file.cc @@ -89,7 +89,7 @@ bool FileContainsExtensions(const FileDescriptor* file) { void PruneFileAndDepsMarkingAsVisited( const FileDescriptor* file, vector* files, - set* files_visited) { + std::set* files_visited) { vector::iterator iter = std::find(files->begin(), files->end(), file); if (iter != files->end()) { @@ -105,7 +105,7 @@ void PruneFileAndDepsMarkingAsVisited( void CollectMinimalFileDepsContainingExtensionsWorker( const FileDescriptor* file, vector* files, - set* files_visited) { + std::set* files_visited) { if (files_visited->find(file) != files_visited->end()) { return; } @@ -138,7 +138,7 @@ void CollectMinimalFileDepsContainingExtensionsWorker( void CollectMinimalFileDepsContainingExtensions( const FileDescriptor* file, vector* files) { - set files_visited; + std::set files_visited; for (int i = 0; i < file->dependency_count(); i++) { const FileDescriptor* dep = file->dependency(i); CollectMinimalFileDepsContainingExtensionsWorker(dep, files, @@ -229,12 +229,12 @@ void FileGenerator::GenerateHeader(io::Printer *printer) { "CF_EXTERN_C_BEGIN\n" "\n"); - set fwd_decls; + std::set fwd_decls; for (vector::iterator iter = message_generators_.begin(); iter != message_generators_.end(); ++iter) { (*iter)->DetermineForwardDeclarations(&fwd_decls); } - for (set::const_iterator i(fwd_decls.begin()); + for (std::set::const_iterator i(fwd_decls.begin()); i != fwd_decls.end(); ++i) { printer->Print("$value$;\n", "value", *i); } @@ -325,7 +325,7 @@ void FileGenerator::GenerateSource(io::Printer *printer) { // #import the headers for anything that a plain dependency of this proto // file (that means they were just an include, not a "public" include). - set public_import_names; + std::set public_import_names; for (int i = 0; i < file_->public_dependency_count(); i++) { public_import_names.insert(file_->public_dependency(i)->name()); } @@ -468,7 +468,7 @@ void FileGenerator::GenerateSource(io::Printer *printer) { // File descriptor only needed if there are messages to use it. if (message_generators_.size() > 0) { - map vars; + std::map vars; vars["root_class_name"] = root_class_name_; vars["package"] = file_->package(); vars["objc_prefix"] = FileClassPrefix(file_); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc index bb8170a9..e347ef1e 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc @@ -980,13 +980,13 @@ namespace { class ExpectedPrefixesCollector : public LineConsumer { public: - ExpectedPrefixesCollector(map* inout_package_to_prefix_map) + ExpectedPrefixesCollector(std::map* inout_package_to_prefix_map) : prefix_map_(inout_package_to_prefix_map) {} virtual bool ConsumeLine(const StringPiece& line, string* out_error); private: - map* prefix_map_; + std::map* prefix_map_; }; bool ExpectedPrefixesCollector::ConsumeLine( @@ -1009,7 +1009,7 @@ bool ExpectedPrefixesCollector::ConsumeLine( } bool LoadExpectedPackagePrefixes(const Options &generation_options, - map* prefix_map, + std::map* prefix_map, string* out_error) { if (generation_options.expected_prefixes_path.empty()) { return true; @@ -1023,7 +1023,7 @@ bool LoadExpectedPackagePrefixes(const Options &generation_options, bool ValidateObjCClassPrefix( const FileDescriptor* file, const string& expected_prefixes_path, - const map& expected_package_prefixes, + const std::map& expected_package_prefixes, string* out_error) { const string prefix = file->options().objc_class_prefix(); const string package = file->package(); @@ -1033,7 +1033,7 @@ bool ValidateObjCClassPrefix( // Check: Error - See if there was an expected prefix for the package and // report if it doesn't match (wrong or missing). - map::const_iterator package_match = + std::map::const_iterator package_match = expected_package_prefixes.find(package); if (package_match != expected_package_prefixes.end()) { // There was an entry, and... @@ -1082,7 +1082,7 @@ bool ValidateObjCClassPrefix( // Look for any other package that uses the same prefix. string other_package_for_prefix; - for (map::const_iterator i = expected_package_prefixes.begin(); + for (std::map::const_iterator i = expected_package_prefixes.begin(); i != expected_package_prefixes.end(); ++i) { if (i->second == prefix) { other_package_for_prefix = i->first; @@ -1150,7 +1150,7 @@ bool ValidateObjCClassPrefixes(const vector& files, const Options& generation_options, string* out_error) { // Load the expected package prefixes, if available, to validate against. - map expected_package_prefixes; + std::map expected_package_prefixes; if (!LoadExpectedPackagePrefixes(generation_options, &expected_package_prefixes, out_error)) { @@ -1519,7 +1519,7 @@ void ImportWriter::AddFile(const FileDescriptor* file, ParseFrameworkMappings(); } - map::iterator proto_lookup = + std::map::iterator proto_lookup = proto_file_to_framework_name_.find(file->name()); if (proto_lookup != proto_file_to_framework_name_.end()) { other_framework_imports_.push_back( @@ -1640,7 +1640,7 @@ bool ImportWriter::ProtoFrameworkCollector::ConsumeLine( StringPiece proto_file(proto_file_list, start, offset - start); StringPieceTrimWhitespace(&proto_file); if (proto_file.size() != 0) { - map::iterator existing_entry = + std::map::iterator existing_entry = map_->find(proto_file.ToString()); if (existing_entry != map_->end()) { std::cerr << "warning: duplicate proto file reference, replacing framework entry for '" diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h index c99262a1..daea7609 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h @@ -262,20 +262,20 @@ class LIBPROTOC_EXPORT ImportWriter { private: class ProtoFrameworkCollector : public LineConsumer { public: - ProtoFrameworkCollector(map* inout_proto_file_to_framework_name) + ProtoFrameworkCollector(std::map* inout_proto_file_to_framework_name) : map_(inout_proto_file_to_framework_name) {} virtual bool ConsumeLine(const StringPiece& line, string* out_error); private: - map* map_; + std::map* map_; }; void ParseFrameworkMappings(); const string generate_for_named_framework_; const string named_framework_to_proto_path_mappings_path_; - map proto_file_to_framework_name_; + std::map proto_file_to_framework_name_; bool need_to_parse_mapping_file_; vector protobuf_framework_imports_; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc index 0bc9dc10..bcaf5709 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc @@ -162,7 +162,7 @@ void MapFieldGenerator::FinishInitialization(void) { } void MapFieldGenerator::DetermineForwardDeclarations( - set* fwd_decls) const { + std::set* fwd_decls) const { RepeatedFieldGenerator::DetermineForwardDeclarations(fwd_decls); const FieldDescriptor* value_descriptor = descriptor_->message_type()->FindFieldByName("value"); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_map_field.h b/src/google/protobuf/compiler/objectivec/objectivec_map_field.h index bc68a682..6664d849 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_map_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_map_field.h @@ -51,7 +51,7 @@ class MapFieldGenerator : public RepeatedFieldGenerator { MapFieldGenerator(const FieldDescriptor* descriptor, const Options& options); virtual ~MapFieldGenerator(); - virtual void DetermineForwardDeclarations(set* fwd_decls) const; + virtual void DetermineForwardDeclarations(std::set* fwd_decls) const; private: scoped_ptr value_field_generator_; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.cc b/src/google/protobuf/compiler/objectivec/objectivec_message.cc index 0a554a83..4f22e290 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_message.cc @@ -233,7 +233,7 @@ void MessageGenerator::GenerateStaticVariablesInitialization( } } -void MessageGenerator::DetermineForwardDeclarations(set* fwd_decls) { +void MessageGenerator::DetermineForwardDeclarations(std::set* fwd_decls) { if (!IsMapEntryMessage(descriptor_)) { for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* fieldDescriptor = descriptor_->field(i); @@ -514,7 +514,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { " };\n"); } - map vars; + std::map vars; vars["classname"] = class_name_; vars["rootclassname"] = root_classname_; vars["fields"] = has_fields ? "fields" : "NULL"; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.h b/src/google/protobuf/compiler/objectivec/objectivec_message.h index 0fb78bc0..8f317ac0 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_message.h @@ -64,7 +64,7 @@ class MessageGenerator { void GenerateMessageHeader(io::Printer* printer); void GenerateSource(io::Printer* printer); void GenerateExtensionRegistrationSource(io::Printer* printer); - void DetermineForwardDeclarations(set* fwd_decls); + void DetermineForwardDeclarations(std::set* fwd_decls); // Checks if the message or a nested message includes a oneof definition. bool IncludesOneOfDefinition() const; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc index d6ccd6d1..699d25b3 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc @@ -45,7 +45,7 @@ namespace objectivec { namespace { void SetMessageVariables(const FieldDescriptor* descriptor, - map* variables) { + std::map* variables) { const string& message_type = ClassName(descriptor->message_type()); (*variables)["type"] = message_type; (*variables)["containing_class"] = ClassName(descriptor->containing_type()); @@ -67,7 +67,7 @@ MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor, MessageFieldGenerator::~MessageFieldGenerator() {} void MessageFieldGenerator::DetermineForwardDeclarations( - set* fwd_decls) const { + std::set* fwd_decls) const { ObjCObjFieldGenerator::DetermineForwardDeclarations(fwd_decls); // Class name is already in "storage_type". fwd_decls->insert("@class " + variable("storage_type")); @@ -95,7 +95,7 @@ RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator( RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {} void RepeatedMessageFieldGenerator::DetermineForwardDeclarations( - set* fwd_decls) const { + std::set* fwd_decls) const { RepeatedFieldGenerator::DetermineForwardDeclarations(fwd_decls); // Class name is already in "storage_type". fwd_decls->insert("@class " + variable("storage_type")); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message_field.h b/src/google/protobuf/compiler/objectivec/objectivec_message_field.h index d2dba153..50f4b6d4 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_message_field.h @@ -51,7 +51,7 @@ class MessageFieldGenerator : public ObjCObjFieldGenerator { virtual bool WantsHasProperty(void) const; public: - virtual void DetermineForwardDeclarations(set* fwd_decls) const; + virtual void DetermineForwardDeclarations(std::set* fwd_decls) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator); @@ -67,7 +67,7 @@ class RepeatedMessageFieldGenerator : public RepeatedFieldGenerator { virtual ~RepeatedMessageFieldGenerator(); public: - virtual void DetermineForwardDeclarations(set* fwd_decls) const; + virtual void DetermineForwardDeclarations(std::set* fwd_decls) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_oneof.h b/src/google/protobuf/compiler/objectivec/objectivec_oneof.h index 3d9df4db..ff353a6c 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_oneof.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_oneof.h @@ -67,7 +67,7 @@ class OneofGenerator { private: const OneofDescriptor* descriptor_; - map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OneofGenerator); }; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc index d49350f4..aa8ac324 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc @@ -118,7 +118,7 @@ const char* PrimitiveArrayTypeName(const FieldDescriptor* descriptor) { } void SetPrimitiveVariables(const FieldDescriptor* descriptor, - map* variables) { + std::map* variables) { std::string primitive_name = PrimitiveTypeName(descriptor); (*variables)["type"] = primitive_name; (*variables)["storage_type"] = primitive_name; diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 60874e09..19d59843 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -227,10 +227,8 @@ class FatalException : public std::exception { // in some versions of MSVC. // TODO(acozzette): remove these using statements using std::istream; -using std::map; using std::ostream; using std::pair; -using std::set; using std::string; using std::vector; diff --git a/src/google/protobuf/testing/googletest.h b/src/google/protobuf/testing/googletest.h index c0d99e69..bf8bf282 100644 --- a/src/google/protobuf/testing/googletest.h +++ b/src/google/protobuf/testing/googletest.h @@ -85,7 +85,7 @@ class ScopedMemoryLog { const vector& GetMessages(LogLevel error); private: - map > messages_; + std::map > messages_; LogHandler* old_handler_; static void HandleLog(LogLevel level, const char* filename, int line, -- cgit v1.2.3