extension_user.proto 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Go support for Protocol Buffers - Google's data interchange format
  2. //
  3. // Copyright 2010 The Go Authors. All rights reserved.
  4. // https://github.com/golang/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. // * Neither the name of Google Inc. nor the names of its
  17. // contributors may be used to endorse or promote products derived from
  18. // this software without specific prior written permission.
  19. //
  20. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. syntax = "proto2";
  32. import "extension_base.proto";
  33. import "extension_extra.proto";
  34. package extension_user;
  35. message UserMessage {
  36. optional string name = 1;
  37. optional string rank = 2;
  38. }
  39. // Extend with a message
  40. extend extension_base.BaseMessage {
  41. optional UserMessage user_message = 5;
  42. }
  43. // Extend with a foreign message
  44. extend extension_base.BaseMessage {
  45. optional extension_extra.ExtraMessage extra_message = 9;
  46. }
  47. // Extend with some primitive types
  48. extend extension_base.BaseMessage {
  49. optional int32 width = 6;
  50. optional int64 area = 7;
  51. }
  52. // Extend inside the scope of another type
  53. message LoudMessage {
  54. extend extension_base.BaseMessage {
  55. optional uint32 volume = 8;
  56. }
  57. extensions 100 to max;
  58. }
  59. // Extend inside the scope of another type, using a message.
  60. message LoginMessage {
  61. extend extension_base.BaseMessage {
  62. optional UserMessage user_message = 16;
  63. }
  64. }
  65. // Extend with a repeated field
  66. extend extension_base.BaseMessage {
  67. repeated Detail detail = 17;
  68. }
  69. message Detail {
  70. optional string color = 1;
  71. }
  72. // An extension of an extension
  73. message Announcement {
  74. optional string words = 1;
  75. extend LoudMessage {
  76. optional Announcement loud_ext = 100;
  77. }
  78. }
  79. // Something that can be put in a message set.
  80. message OldStyleParcel {
  81. extend extension_base.OldStyleMessage {
  82. optional OldStyleParcel message_set_extension = 2001;
  83. }
  84. required string name = 1;
  85. optional int32 height = 2;
  86. }