...
1// Copyright 2018 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5syntax = "proto2";
6
7import "cmd/protoc-gen-go/testdata/extensions/base/base.proto";
8import "cmd/protoc-gen-go/testdata/extensions/extra/extra.proto";
9
10package goproto.protoc.extension.ext;
11
12option go_package = "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/extensions/ext";
13
14message Message {
15 optional bytes data = 1;
16
17 message M {}
18}
19
20enum Enum {
21 ZERO = 0;
22}
23
24// Extend with various types.
25extend goproto.protoc.extension.base.BaseMessage {
26 optional bool extension_bool = 101;
27 optional Enum extension_enum = 102;
28 optional int32 extension_int32 = 103;
29 optional sint32 extension_sint32 = 104;
30 optional uint32 extension_uint32 = 105;
31 optional int64 extension_int64 = 106;
32 optional sint64 extension_sint64 = 107;
33 optional uint64 extension_uint64 = 108;
34 optional sfixed32 extension_sfixed32 = 109;
35 optional fixed32 extension_fixed32 = 110;
36 optional float extension_float = 111;
37 optional sfixed64 extension_sfixed64 = 112;
38 optional fixed64 extension_fixed64 = 113;
39 optional double extension_double = 114;
40 optional string extension_string = 115;
41 optional bytes extension_bytes = 116;
42 optional Message extension_Message = 117;
43 optional Message.M extension_MessageM = 118;
44 optional group ExtensionGroup = 119 {
45 optional string extension_group = 120;
46 }
47}
48
49// Extend with a foreign message.
50extend goproto.protoc.extension.base.BaseMessage {
51 optional goproto.protoc.extension.extra.ExtraMessage extra_message = 9;
52}
53
54// Extend in the scope of another type.
55message ExtendingMessage {
56 extend goproto.protoc.extension.base.BaseMessage {
57 optional string extending_message_string = 200;
58 optional ExtendingMessageSubmessage extending_message_submessage = 201;
59 }
60 message ExtendingMessageSubmessage {}
61}
62
63// Extend with repeated fields.
64extend goproto.protoc.extension.base.BaseMessage {
65 repeated bool repeated_x_bool = 301;
66 repeated Enum repeated_x_enum = 302;
67 repeated int32 repeated_x_int32 = 303;
68 repeated sint32 repeated_x_sint32 = 304;
69 repeated uint32 repeated_x_uint32 = 305;
70 repeated int64 repeated_x_int64 = 306;
71 repeated sint64 repeated_x_sint64 = 307;
72 repeated uint64 repeated_x_uint64 = 308;
73 repeated sfixed32 repeated_x_sfixed32 = 309;
74 repeated fixed32 repeated_x_fixed32 = 310;
75 repeated float repeated_x_float = 311;
76 repeated sfixed64 repeated_x_sfixed64 = 312;
77 repeated fixed64 repeated_x_fixed64 = 313;
78 repeated double repeated_x_double = 314;
79 repeated string repeated_x_string = 315;
80 repeated bytes repeated_x_bytes = 316;
81 repeated Message repeated_x_Message = 317;
82 repeated group RepeatedGroup = 318 {
83 repeated string repeated_x_group = 319;
84 }
85}
86
87// An extension of an extension.
88message Extendable {
89 extensions 1 to max;
90}
91extend goproto.protoc.extension.base.BaseMessage {
92 optional Extendable extendable_field = 400;
93}
94extend Extendable {
95 optional string extendable_string_field = 1;
96}
97
98// Message set wire format.
99message MessageSetWireFormatExtension {
100 extend goproto.protoc.extension.base.MessageSetWireFormatMessage {
101 optional MessageSetWireFormatExtension message_set_extension = 100;
102 }
103}
104
105// Message set extension, not nested in a message.
106extend goproto.protoc.extension.base.MessageSetWireFormatMessage {
107 optional MessageSetWireFormatExtension message_set_extension = 101;
108}
View as plain text