...
1// Protocol Buffers for Go with Gadgets
2//
3// Copyright (c) 2013, The GoGo Authors. All rights reserved.
4// http://github.com/gogo/protobuf
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met:
9//
10// * Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12// * Redistributions in binary form must reproduce the above
13// copyright notice, this list of conditions and the following disclaimer
14// in the documentation and/or other materials provided with the
15// distribution.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29syntax = "proto2";
30
31// Package enumcustomname tests the behavior of enum_customname and
32// enumvalue_customname extensions.
33package enumcustomname;
34
35import "github.com/gogo/protobuf/gogoproto/gogo.proto";
36import "github.com/gogo/protobuf/test/thetest.proto";
37
38enum MyEnum {
39 option (gogoproto.enum_customname) = "MyCustomEnum";
40
41 // The following field will take on the custom name and the prefix, joined
42 // by an underscore.
43 A = 0 [(gogoproto.enumvalue_customname) = "MyBetterNameA"];
44 B = 1; // Should be MyCustomEnum_B
45}
46
47enum MyUnprefixedEnum {
48 option (gogoproto.goproto_enum_prefix) = false;
49 option (gogoproto.goproto_enum_stringer) = false; // ensure it behaves correctly without stringer.
50 option (gogoproto.enum_customname) = "MyCustomUnprefixedEnum"; // no prefix added but type gets name
51 UNPREFIXED_A = 0 [(gogoproto.enumvalue_customname) = "MyBetterNameUnprefixedA"];
52 UNPREFIXED_B = 1 ; // Should not pick up prefix above
53}
54
55enum MyEnumWithEnumStringer {
56 option (gogoproto.goproto_enum_stringer) = false; // ensure it behaves correctly without stringer.
57 option (gogoproto.enum_stringer) = true; // ensure it behaves correctly without stringer.
58 STRINGER_A = 0 [(gogoproto.enumvalue_customname) = "EnumValueStringerA"];
59 STRINGER_B = 1;
60}
61
62message OnlyEnums {
63 optional MyEnum my_enum = 1;
64 optional MyEnum my_enum_default_a = 2 [default=A];
65 optional MyEnum my_enum_default_b = 3 [default=B];
66 optional MyUnprefixedEnum my_unprefixed_enum = 4;
67 optional MyUnprefixedEnum my_unprefixed_enum_default_a = 5 [default=UNPREFIXED_A];
68 optional MyUnprefixedEnum my_unprefixed_enum_default_b = 6 [default=UNPREFIXED_B];
69 optional test.YetAnotherTestEnum yet_another_test_enum = 7;
70 optional test.YetAnotherTestEnum yet_another_test_enum_default_aa = 8 [default=AA];
71 optional test.YetAnotherTestEnum yet_another_test_enum_default_bb = 9 [default=BB];
72 optional test.YetYetAnotherTestEnum yet_yet_another_test_enum = 10;
73 optional test.YetYetAnotherTestEnum yet_yet_another_test_enum_default_cc = 11 [default=CC];
74 optional test.YetYetAnotherTestEnum yet_yet_another_test_enum_default_dd = 12 [default=DD];
75}
View as plain text