Unverified Commit affe9c20 authored by Hao Nguyen's avatar Hao Nguyen Committed by GitHub

Merge pull request #6161 from haon4/201905211601

Down integrate to GitHub
parents 0c3f43a6 582927ae
...@@ -18,7 +18,7 @@ def __get_data_size(filename): ...@@ -18,7 +18,7 @@ def __get_data_size(filename):
return __file_size_map[filename] return __file_size_map[filename]
benchmark_dataset = benchmarks_pb2.BenchmarkDataset() benchmark_dataset = benchmarks_pb2.BenchmarkDataset()
benchmark_dataset.ParseFromString( benchmark_dataset.ParseFromString(
open(filename).read()) open(filename, "rb").read())
size = 0 size = 0
count = 0 count = 0
for payload in benchmark_dataset.payload: for payload in benchmark_dataset.payload:
...@@ -60,7 +60,7 @@ def __parse_cpp_result(filename): ...@@ -60,7 +60,7 @@ def __parse_cpp_result(filename):
return return
if filename[0] != '/': if filename[0] != '/':
filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename
with open(filename) as f: with open(filename, "rb") as f:
results = json.loads(f.read()) results = json.loads(f.read())
for benchmark in results["benchmarks"]: for benchmark in results["benchmarks"]:
data_filename = "".join( data_filename = "".join(
...@@ -95,7 +95,7 @@ def __parse_synthetic_result(filename): ...@@ -95,7 +95,7 @@ def __parse_synthetic_result(filename):
return return
if filename[0] != "/": if filename[0] != "/":
filename = os.path.dirname(os.path.abspath(__file__)) + "/" + filename filename = os.path.dirname(os.path.abspath(__file__)) + "/" + filename
with open(filename) as f: with open(filename, "rb") as f:
results = json.loads(f.read()) results = json.loads(f.read())
for benchmark in results["benchmarks"]: for benchmark in results["benchmarks"]:
__results.append({ __results.append({
...@@ -125,7 +125,7 @@ def __parse_python_result(filename): ...@@ -125,7 +125,7 @@ def __parse_python_result(filename):
return return
if filename[0] != '/': if filename[0] != '/':
filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename
with open(filename) as f: with open(filename, "rb") as f:
results_list = json.loads(f.read()) results_list = json.loads(f.read())
for results in results_list: for results in results_list:
for result in results: for result in results:
...@@ -175,7 +175,7 @@ def __parse_java_result(filename): ...@@ -175,7 +175,7 @@ def __parse_java_result(filename):
return return
if filename[0] != '/': if filename[0] != '/':
filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename
with open(filename) as f: with open(filename, "rb") as f:
results = json.loads(f.read()) results = json.loads(f.read())
for result in results: for result in results:
total_weight = 0 total_weight = 0
...@@ -211,7 +211,7 @@ def __parse_go_result(filename): ...@@ -211,7 +211,7 @@ def __parse_go_result(filename):
return return
if filename[0] != '/': if filename[0] != '/':
filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename
with open(filename) as f: with open(filename, "rb") as f:
for line in f: for line in f:
result_list = re.split(r"[\ \t]+", line) result_list = re.split(r"[\ \t]+", line)
if result_list[0][:9] != "Benchmark": if result_list[0][:9] != "Benchmark":
...@@ -251,7 +251,7 @@ def __parse_custom_result(filename, language): ...@@ -251,7 +251,7 @@ def __parse_custom_result(filename, language):
return return
if filename[0] != '/': if filename[0] != '/':
filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename filename = os.path.dirname(os.path.abspath(__file__)) + '/' + filename
with open(filename) as f: with open(filename, "rb") as f:
results = json.loads(f.read()) results = json.loads(f.read())
for result in results: for result in results:
_, avg_size = __get_data_size(result["filename"]) _, avg_size = __get_data_size(result["filename"])
......
...@@ -1194,6 +1194,9 @@ namespace Google.Protobuf.Reflection { ...@@ -1194,6 +1194,9 @@ namespace Google.Protobuf.Reflection {
private readonly static int StartDefaultValue = 0; private readonly static int StartDefaultValue = 0;
private int start_; private int start_;
/// <summary>
/// Inclusive.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int Start { public int Start {
get { if ((_hasBits0 & 1) != 0) { return start_; } else { return StartDefaultValue; } } get { if ((_hasBits0 & 1) != 0) { return start_; } else { return StartDefaultValue; } }
...@@ -1218,6 +1221,9 @@ namespace Google.Protobuf.Reflection { ...@@ -1218,6 +1221,9 @@ namespace Google.Protobuf.Reflection {
private readonly static int EndDefaultValue = 0; private readonly static int EndDefaultValue = 0;
private int end_; private int end_;
/// <summary>
/// Exclusive.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int End { public int End {
get { if ((_hasBits0 & 2) != 0) { return end_; } else { return EndDefaultValue; } } get { if ((_hasBits0 & 2) != 0) { return end_; } else { return EndDefaultValue; } }
......
...@@ -51,6 +51,7 @@ public abstract class AbstractMessageLite< ...@@ -51,6 +51,7 @@ public abstract class AbstractMessageLite<
BuilderType extends AbstractMessageLite.Builder<MessageType, BuilderType>> BuilderType extends AbstractMessageLite.Builder<MessageType, BuilderType>>
implements MessageLite { implements MessageLite {
protected int memoizedHashCode = 0; protected int memoizedHashCode = 0;
@Override @Override
public ByteString toByteString() { public ByteString toByteString() {
try { try {
...@@ -106,16 +107,6 @@ public abstract class AbstractMessageLite< ...@@ -106,16 +107,6 @@ public abstract class AbstractMessageLite<
} }
@ExperimentalApi
protected final boolean isInitializedInternal() {
return Protobuf.getInstance().schemaFor(this).isInitialized(this);
}
@ExperimentalApi
protected final int getSerializedSizeInternal() {
return Protobuf.getInstance().schemaFor(this).getSerializedSize(this);
}
int getSerializedSize(Schema schema) { int getSerializedSize(Schema schema) {
int memoizedSerializedSize = getMemoizedSerializedSize(); int memoizedSerializedSize = getMemoizedSerializedSize();
if (memoizedSerializedSize == -1) { if (memoizedSerializedSize == -1) {
...@@ -125,37 +116,6 @@ public abstract class AbstractMessageLite< ...@@ -125,37 +116,6 @@ public abstract class AbstractMessageLite<
return memoizedSerializedSize; return memoizedSerializedSize;
} }
@ExperimentalApi
protected final void writeToInternal(CodedOutputStream output) throws IOException {
Protobuf.getInstance()
.schemaFor(getClassInternal())
.writeTo(this, CodedOutputStreamWriter.forCodedOutput(output));
}
@ExperimentalApi
protected void mergeFromInternal(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
throws InvalidProtocolBufferException {
try {
Protobuf.getInstance()
.schemaFor(getClassInternal())
.mergeFrom(this, CodedInputStreamReader.forCodedInput(input), extensionRegistry);
} catch (InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (IOException e) {
throw new InvalidProtocolBufferException(e).setUnfinishedMessage(this);
}
}
@ExperimentalApi
protected void makeImmutableInternal() {
Protobuf.getInstance().schemaFor(getClassInternal()).makeImmutable(this);
}
@SuppressWarnings("unchecked")
private Class<AbstractMessageLite<MessageType, BuilderType>> getClassInternal() {
return (Class<AbstractMessageLite<MessageType, BuilderType>>) getClass();
}
/** Package private helper method for AbstractParser to create UninitializedMessageException. */ /** Package private helper method for AbstractParser to create UninitializedMessageException. */
UninitializedMessageException newUninitializedMessageException() { UninitializedMessageException newUninitializedMessageException() {
return new UninitializedMessageException(this); return new UninitializedMessageException(this);
......
...@@ -262,12 +262,14 @@ public abstract class GeneratedMessageLite< ...@@ -262,12 +262,14 @@ public abstract class GeneratedMessageLite<
} }
public void writeTo(CodedOutputStream output) throws IOException { public void writeTo(CodedOutputStream output) throws IOException {
writeToInternal(output); Protobuf.getInstance()
.schemaFor(this)
.writeTo(this, CodedOutputStreamWriter.forCodedOutput(output));
} }
public int getSerializedSize() { public int getSerializedSize() {
if (memoizedSerializedSize == -1) { if (memoizedSerializedSize == -1) {
memoizedSerializedSize = getSerializedSizeInternal(); memoizedSerializedSize = Protobuf.getInstance().schemaFor(this).getSerializedSize(this);
} }
return memoizedSerializedSize; return memoizedSerializedSize;
} }
......
...@@ -126,6 +126,21 @@ public abstract class GeneratedMessageV3 extends AbstractMessage ...@@ -126,6 +126,21 @@ public abstract class GeneratedMessageV3 extends AbstractMessage
return internalGetFieldAccessorTable().descriptor; return internalGetFieldAccessorTable().descriptor;
} }
protected void mergeFromAndMakeImmutableInternal(
CodedInputStream input, ExtensionRegistryLite extensionRegistry)
throws InvalidProtocolBufferException {
Schema<GeneratedMessageV3> schema =
(Schema<GeneratedMessageV3>) Protobuf.getInstance().schemaFor(this);
try {
schema.mergeFrom(this, CodedInputStreamReader.forCodedInput(input), extensionRegistry);
} catch (InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (IOException e) {
throw new InvalidProtocolBufferException(e).setUnfinishedMessage(this);
}
schema.makeImmutable(this);
}
/** /**
* Internal helper to return a modifiable map containing all the fields. * Internal helper to return a modifiable map containing all the fields.
* The returned Map is modifialbe so that the caller can add additional * The returned Map is modifialbe so that the caller can add additional
...@@ -439,6 +454,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage ...@@ -439,6 +454,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage
size == 0 ? AbstractProtobufList.DEFAULT_CAPACITY : size * 2); size == 0 ? AbstractProtobufList.DEFAULT_CAPACITY : size * 2);
} }
@Override @Override
public void writeTo(final CodedOutputStream output) throws IOException { public void writeTo(final CodedOutputStream output) throws IOException {
MessageReflection.writeMessageTo(this, getAllFieldsRaw(), output, false); MessageReflection.writeMessageTo(this, getAllFieldsRaw(), output, false);
......
...@@ -99,7 +99,7 @@ public class LiteTest extends TestCase { ...@@ -99,7 +99,7 @@ public class LiteTest extends TestCase {
TestAllTypesLite.newBuilder() TestAllTypesLite.newBuilder()
.setOptionalInt32(123) .setOptionalInt32(123)
.addRepeatedString("hello") .addRepeatedString("hello")
.setOptionalNestedMessage(TestAllTypesLite.NestedMessage.newBuilder().setBb(7)) .setOptionalNestedMessage(NestedMessage.newBuilder().setBb(7))
.build(); .build();
ByteString data = message.toByteString(); ByteString data = message.toByteString();
...@@ -135,11 +135,10 @@ public class LiteTest extends TestCase { ...@@ -135,11 +135,10 @@ public class LiteTest extends TestCase {
TestAllExtensionsLite.newBuilder() TestAllExtensionsLite.newBuilder()
.setExtension(UnittestLite.optionalInt32ExtensionLite, 123) .setExtension(UnittestLite.optionalInt32ExtensionLite, 123)
.addExtension(UnittestLite.repeatedStringExtensionLite, "hello") .addExtension(UnittestLite.repeatedStringExtensionLite, "hello")
.setExtension( .setExtension(UnittestLite.optionalNestedEnumExtensionLite, NestedEnum.BAZ)
UnittestLite.optionalNestedEnumExtensionLite, TestAllTypesLite.NestedEnum.BAZ)
.setExtension( .setExtension(
UnittestLite.optionalNestedMessageExtensionLite, UnittestLite.optionalNestedMessageExtensionLite,
TestAllTypesLite.NestedMessage.newBuilder().setBb(7).build()) NestedMessage.newBuilder().setBb(7).build())
.build(); .build();
// Test copying a message, since coping extensions actually does use a // Test copying a message, since coping extensions actually does use a
...@@ -152,8 +151,7 @@ public class LiteTest extends TestCase { ...@@ -152,8 +151,7 @@ public class LiteTest extends TestCase {
assertEquals(1, message2.getExtension(UnittestLite.repeatedStringExtensionLite).size()); assertEquals(1, message2.getExtension(UnittestLite.repeatedStringExtensionLite).size());
assertEquals("hello", message2.getExtension(UnittestLite.repeatedStringExtensionLite, 0)); assertEquals("hello", message2.getExtension(UnittestLite.repeatedStringExtensionLite, 0));
assertEquals( assertEquals(
TestAllTypesLite.NestedEnum.BAZ, NestedEnum.BAZ, message2.getExtension(UnittestLite.optionalNestedEnumExtensionLite));
message2.getExtension(UnittestLite.optionalNestedEnumExtensionLite));
assertEquals(7, message2.getExtension(UnittestLite.optionalNestedMessageExtensionLite).getBb()); assertEquals(7, message2.getExtension(UnittestLite.optionalNestedMessageExtensionLite).getBb());
} }
...@@ -1377,14 +1375,16 @@ public class LiteTest extends TestCase { ...@@ -1377,14 +1375,16 @@ public class LiteTest extends TestCase {
proto = proto =
TestAllTypesLite.newBuilder() TestAllTypesLite.newBuilder()
.setOptionalBool(true) .setOptionalBool(true)
.setOptionalNestedEnum(TestAllTypesLite.NestedEnum.BAZ) .setOptionalNestedEnum(NestedEnum.BAZ)
.build(); .build();
assertToStringEquals("optional_bool: true\noptional_nested_enum: BAZ", proto); assertToStringEquals(
"optional_bool: true\noptional_nested_enum: " + NestedEnum.BAZ.toString(), proto);
proto = TestAllTypesLite.newBuilder().setOptionalFloat(2.72f).setOptionalDouble(3.14).build(); proto = TestAllTypesLite.newBuilder().setOptionalFloat(2.72f).setOptionalDouble(3.14).build();
assertToStringEquals("optional_double: 3.14\noptional_float: 2.72", proto); assertToStringEquals("optional_double: 3.14\noptional_float: 2.72", proto);
} }
public void testToStringStringFields() throws Exception { public void testToStringStringFields() throws Exception {
TestAllTypesLite proto = TestAllTypesLite proto =
TestAllTypesLite.newBuilder().setOptionalString("foo\"bar\nbaz\\").build(); TestAllTypesLite.newBuilder().setOptionalString("foo\"bar\nbaz\\").build();
...@@ -1397,13 +1397,13 @@ public class LiteTest extends TestCase { ...@@ -1397,13 +1397,13 @@ public class LiteTest extends TestCase {
public void testToStringNestedMessage() throws Exception { public void testToStringNestedMessage() throws Exception {
TestAllTypesLite proto = TestAllTypesLite proto =
TestAllTypesLite.newBuilder() TestAllTypesLite.newBuilder()
.setOptionalNestedMessage(TestAllTypesLite.NestedMessage.getDefaultInstance()) .setOptionalNestedMessage(NestedMessage.getDefaultInstance())
.build(); .build();
assertToStringEquals("optional_nested_message {\n}", proto); assertToStringEquals("optional_nested_message {\n}", proto);
proto = proto =
TestAllTypesLite.newBuilder() TestAllTypesLite.newBuilder()
.setOptionalNestedMessage(TestAllTypesLite.NestedMessage.newBuilder().setBb(7)) .setOptionalNestedMessage(NestedMessage.newBuilder().setBb(7))
.build(); .build();
assertToStringEquals("optional_nested_message {\n bb: 7\n}", proto); assertToStringEquals("optional_nested_message {\n bb: 7\n}", proto);
} }
...@@ -1419,8 +1419,8 @@ public class LiteTest extends TestCase { ...@@ -1419,8 +1419,8 @@ public class LiteTest extends TestCase {
proto = proto =
TestAllTypesLite.newBuilder() TestAllTypesLite.newBuilder()
.addRepeatedLazyMessage(TestAllTypesLite.NestedMessage.newBuilder().setBb(7)) .addRepeatedLazyMessage(NestedMessage.newBuilder().setBb(7))
.addRepeatedLazyMessage(TestAllTypesLite.NestedMessage.newBuilder().setBb(8)) .addRepeatedLazyMessage(NestedMessage.newBuilder().setBb(8))
.build(); .build();
assertToStringEquals( assertToStringEquals(
"repeated_lazy_message {\n bb: 7\n}\nrepeated_lazy_message {\n bb: 8\n}", proto); "repeated_lazy_message {\n bb: 7\n}\nrepeated_lazy_message {\n bb: 8\n}", proto);
...@@ -1433,7 +1433,10 @@ public class LiteTest extends TestCase { ...@@ -1433,7 +1433,10 @@ public class LiteTest extends TestCase {
.setOptionalForeignMessage(ForeignMessageLite.newBuilder().setC(3)) .setOptionalForeignMessage(ForeignMessageLite.newBuilder().setC(3))
.build(); .build();
assertToStringEquals( assertToStringEquals(
"optional_foreign_enum: FOREIGN_LITE_BAR\noptional_foreign_message {\n c: 3\n}", proto); "optional_foreign_enum: "
+ ForeignEnumLite.FOREIGN_LITE_BAR
+ "\noptional_foreign_message {\n c: 3\n}",
proto);
} }
public void testToStringExtensions() throws Exception { public void testToStringExtensions() throws Exception {
...@@ -1442,11 +1445,10 @@ public class LiteTest extends TestCase { ...@@ -1442,11 +1445,10 @@ public class LiteTest extends TestCase {
.setExtension(UnittestLite.optionalInt32ExtensionLite, 123) .setExtension(UnittestLite.optionalInt32ExtensionLite, 123)
.addExtension(UnittestLite.repeatedStringExtensionLite, "spam") .addExtension(UnittestLite.repeatedStringExtensionLite, "spam")
.addExtension(UnittestLite.repeatedStringExtensionLite, "eggs") .addExtension(UnittestLite.repeatedStringExtensionLite, "eggs")
.setExtension( .setExtension(UnittestLite.optionalNestedEnumExtensionLite, NestedEnum.BAZ)
UnittestLite.optionalNestedEnumExtensionLite, TestAllTypesLite.NestedEnum.BAZ)
.setExtension( .setExtension(
UnittestLite.optionalNestedMessageExtensionLite, UnittestLite.optionalNestedMessageExtensionLite,
TestAllTypesLite.NestedMessage.newBuilder().setBb(7).build()) NestedMessage.newBuilder().setBb(7).build())
.build(); .build();
assertToStringEquals( assertToStringEquals(
"[1]: 123\n[18] {\n bb: 7\n}\n[21]: 3\n[44]: \"spam\"\n[44]: \"eggs\"", message); "[1]: 123\n[18] {\n bb: 7\n}\n[21]: 3\n[44]: \"spam\"\n[44]: \"eggs\"", message);
...@@ -1458,11 +1460,10 @@ public class LiteTest extends TestCase { ...@@ -1458,11 +1460,10 @@ public class LiteTest extends TestCase {
.setExtension(UnittestLite.optionalInt32ExtensionLite, 123) .setExtension(UnittestLite.optionalInt32ExtensionLite, 123)
.addExtension(UnittestLite.repeatedStringExtensionLite, "spam") .addExtension(UnittestLite.repeatedStringExtensionLite, "spam")
.addExtension(UnittestLite.repeatedStringExtensionLite, "eggs") .addExtension(UnittestLite.repeatedStringExtensionLite, "eggs")
.setExtension( .setExtension(UnittestLite.optionalNestedEnumExtensionLite, NestedEnum.BAZ)
UnittestLite.optionalNestedEnumExtensionLite, TestAllTypesLite.NestedEnum.BAZ)
.setExtension( .setExtension(
UnittestLite.optionalNestedMessageExtensionLite, UnittestLite.optionalNestedMessageExtensionLite,
TestAllTypesLite.NestedMessage.newBuilder().setBb(7).build()) NestedMessage.newBuilder().setBb(7).build())
.build(); .build();
TestAllExtensionsLite messageWithUnknownFields = TestAllExtensionsLite messageWithUnknownFields =
TestAllExtensionsLite.parseFrom(messageWithExtensions.toByteArray()); TestAllExtensionsLite.parseFrom(messageWithExtensions.toByteArray());
...@@ -1611,13 +1612,12 @@ public class LiteTest extends TestCase { ...@@ -1611,13 +1612,12 @@ public class LiteTest extends TestCase {
public void testMergeFromNoLazyFieldSharing() throws Exception { public void testMergeFromNoLazyFieldSharing() throws Exception {
TestAllTypesLite.Builder sourceBuilder = TestAllTypesLite.Builder sourceBuilder =
TestAllTypesLite.newBuilder() TestAllTypesLite.newBuilder().setOptionalLazyMessage(NestedMessage.newBuilder().setBb(1));
.setOptionalLazyMessage(TestAllTypesLite.NestedMessage.newBuilder().setBb(1));
TestAllTypesLite.Builder targetBuilder = TestAllTypesLite.Builder targetBuilder =
TestAllTypesLite.newBuilder().mergeFrom(sourceBuilder.build()); TestAllTypesLite.newBuilder().mergeFrom(sourceBuilder.build());
assertEquals(1, sourceBuilder.getOptionalLazyMessage().getBb()); assertEquals(1, sourceBuilder.getOptionalLazyMessage().getBb());
// now change the sourceBuilder, and target value shouldn't be affected. // now change the sourceBuilder, and target value shouldn't be affected.
sourceBuilder.setOptionalLazyMessage(TestAllTypesLite.NestedMessage.newBuilder().setBb(2)); sourceBuilder.setOptionalLazyMessage(NestedMessage.newBuilder().setBb(2));
assertEquals(1, targetBuilder.getOptionalLazyMessage().getBb()); assertEquals(1, targetBuilder.getOptionalLazyMessage().getBb());
} }
...@@ -2115,7 +2115,7 @@ public class LiteTest extends TestCase { ...@@ -2115,7 +2115,7 @@ public class LiteTest extends TestCase {
TestAllTypesLite.newBuilder() TestAllTypesLite.newBuilder()
.setOptionalInt32(123) .setOptionalInt32(123)
.addRepeatedString("hello") .addRepeatedString("hello")
.setOptionalNestedMessage(TestAllTypesLite.NestedMessage.newBuilder().setBb(7)) .setOptionalNestedMessage(NestedMessage.newBuilder().setBb(7))
.build(); .build();
TestAllTypesLite copy = TestAllTypesLite copy =
...@@ -2150,11 +2150,10 @@ public class LiteTest extends TestCase { ...@@ -2150,11 +2150,10 @@ public class LiteTest extends TestCase {
TestAllExtensionsLite.newBuilder() TestAllExtensionsLite.newBuilder()
.setExtension(UnittestLite.optionalInt32ExtensionLite, 123) .setExtension(UnittestLite.optionalInt32ExtensionLite, 123)
.addExtension(UnittestLite.repeatedStringExtensionLite, "hello") .addExtension(UnittestLite.repeatedStringExtensionLite, "hello")
.setExtension( .setExtension(UnittestLite.optionalNestedEnumExtensionLite, NestedEnum.BAZ)
UnittestLite.optionalNestedEnumExtensionLite, TestAllTypesLite.NestedEnum.BAZ)
.setExtension( .setExtension(
UnittestLite.optionalNestedMessageExtensionLite, UnittestLite.optionalNestedMessageExtensionLite,
TestAllTypesLite.NestedMessage.newBuilder().setBb(7).build()) NestedMessage.newBuilder().setBb(7).build())
.build(); .build();
ExtensionRegistryLite registry = ExtensionRegistryLite.newInstance(); ExtensionRegistryLite registry = ExtensionRegistryLite.newInstance();
......
...@@ -16,11 +16,15 @@ use Google\Protobuf\Internal\GPBUtil; ...@@ -16,11 +16,15 @@ use Google\Protobuf\Internal\GPBUtil;
class ExtensionRange extends \Google\Protobuf\Internal\Message class ExtensionRange extends \Google\Protobuf\Internal\Message
{ {
/** /**
* Inclusive.
*
* Generated from protobuf field <code>optional int32 start = 1;</code> * Generated from protobuf field <code>optional int32 start = 1;</code>
*/ */
private $start = 0; private $start = 0;
private $has_start = false; private $has_start = false;
/** /**
* Exclusive.
*
* Generated from protobuf field <code>optional int32 end = 2;</code> * Generated from protobuf field <code>optional int32 end = 2;</code>
*/ */
private $end = 0; private $end = 0;
...@@ -38,7 +42,9 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message ...@@ -38,7 +42,9 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message
* Optional. Data for populating the Message object. * Optional. Data for populating the Message object.
* *
* @type int $start * @type int $start
* Inclusive.
* @type int $end * @type int $end
* Exclusive.
* @type \Google\Protobuf\Internal\ExtensionRangeOptions $options * @type \Google\Protobuf\Internal\ExtensionRangeOptions $options
* } * }
*/ */
...@@ -48,6 +54,8 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message ...@@ -48,6 +54,8 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message
} }
/** /**
* Inclusive.
*
* Generated from protobuf field <code>optional int32 start = 1;</code> * Generated from protobuf field <code>optional int32 start = 1;</code>
* @return int * @return int
*/ */
...@@ -57,6 +65,8 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message ...@@ -57,6 +65,8 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message
} }
/** /**
* Inclusive.
*
* Generated from protobuf field <code>optional int32 start = 1;</code> * Generated from protobuf field <code>optional int32 start = 1;</code>
* @param int $var * @param int $var
* @return $this * @return $this
...@@ -76,6 +86,8 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message ...@@ -76,6 +86,8 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message
} }
/** /**
* Exclusive.
*
* Generated from protobuf field <code>optional int32 end = 2;</code> * Generated from protobuf field <code>optional int32 end = 2;</code>
* @return int * @return int
*/ */
...@@ -85,6 +97,8 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message ...@@ -85,6 +97,8 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message
} }
/** /**
* Exclusive.
*
* Generated from protobuf field <code>optional int32 end = 2;</code> * Generated from protobuf field <code>optional int32 end = 2;</code>
* @param int $var * @param int $var
* @return $this * @return $this
......
...@@ -3731,7 +3731,12 @@ bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files, ...@@ -3731,7 +3731,12 @@ bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files,
options.GetFileNameExtension(); options.GetFileNameExtension();
std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename)); std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
GOOGLE_CHECK(output.get()); GOOGLE_CHECK(output.get());
io::Printer printer(output.get(), '$'); GeneratedCodeInfo annotations;
io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
&annotations);
io::Printer printer(
output.get(), '$',
options.annotate_code ? &annotation_collector : nullptr);
// Pull out all extensions -- we need these to generate all // Pull out all extensions -- we need these to generate all
// provides/requires. // provides/requires.
...@@ -3763,6 +3768,9 @@ bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files, ...@@ -3763,6 +3768,9 @@ bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files,
if (printer.failed()) { if (printer.failed()) {
return false; return false;
} }
if (options.annotate_code) {
EmbedCodeAnnotations(annotations, &printer);
}
} else if (options.output_mode() == GeneratorOptions::kOneOutputFilePerSCC) { } else if (options.output_mode() == GeneratorOptions::kOneOutputFilePerSCC) {
std::set<const Descriptor*> have_printed; std::set<const Descriptor*> have_printed;
SCCAnalyzer<DepsGenerator> analyzer; SCCAnalyzer<DepsGenerator> analyzer;
......
...@@ -101,8 +101,8 @@ message DescriptorProto { ...@@ -101,8 +101,8 @@ message DescriptorProto {
repeated EnumDescriptorProto enum_type = 4; repeated EnumDescriptorProto enum_type = 4;
message ExtensionRange { message ExtensionRange {
optional int32 start = 1; optional int32 start = 1; // Inclusive.
optional int32 end = 2; optional int32 end = 2; // Exclusive.
optional ExtensionRangeOptions options = 3; optional ExtensionRangeOptions options = 3;
} }
......
...@@ -246,6 +246,9 @@ class PROTOBUF_EXPORT MessageLite { ...@@ -246,6 +246,9 @@ class PROTOBUF_EXPORT MessageLite {
// assume it will remain stable over time. // assume it will remain stable over time.
std::string DebugString() const; std::string DebugString() const;
std::string ShortDebugString() const { return DebugString(); } std::string ShortDebugString() const { return DebugString(); }
// MessageLite::DebugString is already Utf8 Safe. This is to add compatibility
// with Message.
std::string Utf8DebugString() const { return DebugString(); }
// Parsing --------------------------------------------------------- // Parsing ---------------------------------------------------------
// Methods for parsing in protocol buffer format. Most of these are // Methods for parsing in protocol buffer format. Most of these are
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment