Skip to content

Commit

Permalink
Code fixes for the original unit test.
Browse files Browse the repository at this point in the history
Credit goes to @mercret for the fix.
  • Loading branch information
brandoncole committed Aug 30, 2018
1 parent d83a9f6 commit 3d32de9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/google/protobuf/util/internal/protostream_objectwriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ ProtoStreamObjectWriter::ProtoStreamObjectWriter(
set_use_lower_camel_for_enums(options_.use_lower_camel_for_enums);
}

ProtoStreamObjectWriter::ProtoStreamObjectWriter(
const TypeInfo* typeinfo, const google::protobuf::Type& type,
strings::ByteSink* output, ErrorListener* listener,
const ProtoStreamObjectWriter::Options& options)
: ProtoWriter(typeinfo, type, output, listener),
master_type_(type),
current_(nullptr),
options_(options) {
set_ignore_unknown_fields(options_.ignore_unknown_fields);
set_use_lower_camel_for_enums(options.use_lower_camel_for_enums);
}

ProtoStreamObjectWriter::ProtoStreamObjectWriter(
const TypeInfo* typeinfo, const google::protobuf::Type& type,
strings::ByteSink* output, ErrorListener* listener)
Expand Down Expand Up @@ -342,7 +354,7 @@ void ProtoStreamObjectWriter::AnyWriter::StartAny(const DataPiece& value) {
// Create our object writer and initialize it with the first StartObject
// call.
ow_.reset(new ProtoStreamObjectWriter(parent_->typeinfo(), *type, &output_,
parent_->listener()));
parent_->listener(), parent_->options_));

// Don't call StartObject() for well-known types yet. Depending on the
// type of actual data, we may not need to call StartObject(). For
Expand Down
5 changes: 5 additions & 0 deletions src/google/protobuf/util/internal/protostream_objectwriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
const google::protobuf::Type& type,
strings::ByteSink* output, ErrorListener* listener);

ProtoStreamObjectWriter(const TypeInfo* typeinfo,
const google::protobuf::Type& type,
strings::ByteSink* output, ErrorListener* listener,
const ProtoStreamObjectWriter::Options& options);

// Returns true if the field is a map.
inline bool IsMap(const google::protobuf::Field& field);

Expand Down

0 comments on commit 3d32de9

Please sign in to comment.