mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-17 01:12:51 +00:00
6238696abc
Given: package foo extend proto2.bridge.MessageSet { optional Message message_set_extension = 100; } Register the extension as a message set extension and give it the name "foo.". We really shouldn't do this in this case; the special-case treatment of extensions to MessageSet is only for extensions nested in a parent message. However, this is consistent with the behavior of the v1 generator. Match that for now. Change-Id: I919c409605a197904fd3227efc920192d484f431 Reviewed-on: https://go-review.googlesource.com/c/145957 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
109 lines
3.5 KiB
Protocol Buffer
109 lines
3.5 KiB
Protocol Buffer
// Copyright 2018 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
syntax = "proto2";
|
|
|
|
import "extensions/base/base.proto";
|
|
import "extensions/extra/extra.proto";
|
|
|
|
package goproto.protoc.extension.ext;
|
|
|
|
option go_package = "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/ext";
|
|
|
|
message Message {
|
|
optional bytes data = 1;
|
|
|
|
message M {}
|
|
}
|
|
|
|
enum Enum {
|
|
ZERO = 0;
|
|
}
|
|
|
|
// Extend with various types.
|
|
extend goproto.protoc.extension.base.BaseMessage {
|
|
optional bool extension_bool = 101;
|
|
optional Enum extension_enum = 102;
|
|
optional int32 extension_int32 = 103;
|
|
optional sint32 extension_sint32 = 104;
|
|
optional uint32 extension_uint32 = 105;
|
|
optional int64 extension_int64 = 106;
|
|
optional sint64 extension_sint64 = 107;
|
|
optional uint64 extension_uint64 = 108;
|
|
optional sfixed32 extension_sfixed32 = 109;
|
|
optional fixed32 extension_fixed32 = 110;
|
|
optional float extension_float = 111;
|
|
optional sfixed64 extension_sfixed64 = 112;
|
|
optional fixed64 extension_fixed64 = 113;
|
|
optional double extension_double = 114;
|
|
optional string extension_string = 115;
|
|
optional bytes extension_bytes = 116;
|
|
optional Message extension_Message = 117;
|
|
optional Message.M extension_MessageM = 118;
|
|
optional group ExtensionGroup = 119 {
|
|
optional string extension_group = 120;
|
|
}
|
|
}
|
|
|
|
// Extend with a foreign message.
|
|
extend goproto.protoc.extension.base.BaseMessage {
|
|
optional goproto.protoc.extension.extra.ExtraMessage extra_message = 9;
|
|
}
|
|
|
|
// Extend in the scope of another type.
|
|
message ExtendingMessage {
|
|
extend goproto.protoc.extension.base.BaseMessage {
|
|
optional string extending_message_string = 200;
|
|
optional ExtendingMessageSubmessage extending_message_submessage = 201;
|
|
}
|
|
message ExtendingMessageSubmessage {}
|
|
}
|
|
|
|
// Extend with repeated fields.
|
|
extend goproto.protoc.extension.base.BaseMessage {
|
|
repeated bool repeated_x_bool = 301;
|
|
repeated Enum repeated_x_enum = 302;
|
|
repeated int32 repeated_x_int32 = 303;
|
|
repeated sint32 repeated_x_sint32 = 304;
|
|
repeated uint32 repeated_x_uint32 = 305;
|
|
repeated int64 repeated_x_int64 = 306;
|
|
repeated sint64 repeated_x_sint64 = 307;
|
|
repeated uint64 repeated_x_uint64 = 308;
|
|
repeated sfixed32 repeated_x_sfixed32 = 309;
|
|
repeated fixed32 repeated_x_fixed32 = 310;
|
|
repeated float repeated_x_float = 311;
|
|
repeated sfixed64 repeated_x_sfixed64 = 312;
|
|
repeated fixed64 repeated_x_fixed64 = 313;
|
|
repeated double repeated_x_double = 314;
|
|
repeated string repeated_x_string = 315;
|
|
repeated bytes repeated_x_bytes = 316;
|
|
repeated Message repeated_x_Message = 317;
|
|
repeated group RepeatedGroup = 318 {
|
|
repeated string repeated_x_group = 319;
|
|
}
|
|
}
|
|
|
|
// An extension of an extension.
|
|
message Extendable {
|
|
extensions 1 to max;
|
|
}
|
|
extend goproto.protoc.extension.base.BaseMessage {
|
|
optional Extendable extendable_field = 400;
|
|
}
|
|
extend Extendable {
|
|
optional string extendable_string_field = 1;
|
|
}
|
|
|
|
// Message set wire format.
|
|
message MessageSetWireFormatExtension {
|
|
extend goproto.protoc.extension.base.MessageSetWireFormatMessage {
|
|
optional MessageSetWireFormatExtension message_set_extension = 100;
|
|
}
|
|
}
|
|
|
|
// Message set extension, not nested in a message.
|
|
extend goproto.protoc.extension.base.MessageSetWireFormatMessage {
|
|
optional MessageSetWireFormatExtension message_set_extension = 101;
|
|
}
|