enumcustomname.proto 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. syntax = "proto2";
  29. // Package enumcustomname tests the behavior of enum_customname and
  30. // enumvalue_customname extensions.
  31. package enumcustomname;
  32. import "github.com/gogo/protobuf/gogoproto/gogo.proto";
  33. import "github.com/gogo/protobuf/test/thetest.proto";
  34. enum MyEnum {
  35. option (gogoproto.enum_customname) = "MyCustomEnum";
  36. // The following field will take on the custom name and the prefix, joined
  37. // by an underscore.
  38. A = 0 [(gogoproto.enumvalue_customname) = "MyBetterNameA"];
  39. B = 1; // Should be MyCustomEnum_B
  40. }
  41. enum MyUnprefixedEnum {
  42. option (gogoproto.goproto_enum_prefix) = false;
  43. option (gogoproto.goproto_enum_stringer) = false; // ensure it behaves correctly without stringer.
  44. option (gogoproto.enum_customname) = "MyCustomUnprefixedEnum"; // no prefix added but type gets name
  45. UNPREFIXED_A = 0 [(gogoproto.enumvalue_customname) = "MyBetterNameUnprefixedA"];
  46. UNPREFIXED_B = 1 ; // Should not pick up prefix above
  47. }
  48. enum MyEnumWithEnumStringer {
  49. option (gogoproto.goproto_enum_stringer) = false; // ensure it behaves correctly without stringer.
  50. option (gogoproto.enum_stringer) = true; // ensure it behaves correctly without stringer.
  51. STRINGER_A = 0 [(gogoproto.enumvalue_customname) = "EnumValueStringerA"];
  52. STRINGER_B = 1;
  53. }
  54. message OnlyEnums {
  55. optional MyEnum my_enum = 1;
  56. optional MyEnum my_enum_default_a = 2 [default=A];
  57. optional MyEnum my_enum_default_b = 3 [default=B];
  58. optional MyUnprefixedEnum my_unprefixed_enum = 4;
  59. optional MyUnprefixedEnum my_unprefixed_enum_default_a = 5 [default=UNPREFIXED_A];
  60. optional MyUnprefixedEnum my_unprefixed_enum_default_b = 6 [default=UNPREFIXED_B];
  61. optional test.YetAnotherTestEnum yet_another_test_enum = 7;
  62. optional test.YetAnotherTestEnum yet_another_test_enum_default_aa = 8 [default=AA];
  63. optional test.YetAnotherTestEnum yet_another_test_enum_default_bb = 9 [default=BB];
  64. optional test.YetYetAnotherTestEnum yet_yet_another_test_enum = 10;
  65. optional test.YetYetAnotherTestEnum yet_yet_another_test_enum_default_cc = 11 [default=CC];
  66. optional test.YetYetAnotherTestEnum yet_yet_another_test_enum_default_dd = 12 [default=DD];
  67. }