map_unittest_proto3.proto 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. // This file is mostly equivalent to map_unittest.proto, but imports
  31. // unittest_proto3.proto instead of unittest.proto, so that it only
  32. // uses proto3 messages. This makes it suitable for testing
  33. // implementations which only support proto3.
  34. // The TestRequiredMessageMap message has been removed as there are no
  35. // required fields in proto3.
  36. syntax = "proto3";
  37. option csharp_namespace = "Google.Protobuf.TestProtos";
  38. import "unittest_proto3.proto";
  39. package protobuf_unittest3;
  40. // Tests maps.
  41. message TestMap {
  42. map<int32 , int32 > map_int32_int32 = 1;
  43. map<int64 , int64 > map_int64_int64 = 2;
  44. map<uint32 , uint32 > map_uint32_uint32 = 3;
  45. map<uint64 , uint64 > map_uint64_uint64 = 4;
  46. map<sint32 , sint32 > map_sint32_sint32 = 5;
  47. map<sint64 , sint64 > map_sint64_sint64 = 6;
  48. map<fixed32 , fixed32 > map_fixed32_fixed32 = 7;
  49. map<fixed64 , fixed64 > map_fixed64_fixed64 = 8;
  50. map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
  51. map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
  52. map<int32 , float > map_int32_float = 11;
  53. map<int32 , double > map_int32_double = 12;
  54. map<bool , bool > map_bool_bool = 13;
  55. map<string , string > map_string_string = 14;
  56. map<int32 , bytes > map_int32_bytes = 15;
  57. map<int32 , MapEnum > map_int32_enum = 16;
  58. map<int32 , ForeignMessage> map_int32_foreign_message = 17;
  59. }
  60. message TestMapSubmessage {
  61. TestMap test_map = 1;
  62. }
  63. message TestMessageMap {
  64. map<int32, TestAllTypes> map_int32_message = 1;
  65. }
  66. // Two map fields share the same entry default instance.
  67. message TestSameTypeMap {
  68. map<int32, int32> map1 = 1;
  69. map<int32, int32> map2 = 2;
  70. }
  71. enum MapEnum {
  72. MAP_ENUM_FOO = 0;
  73. MAP_ENUM_BAR = 1;
  74. MAP_ENUM_BAZ = 2;
  75. }
  76. message TestArenaMap {
  77. map<int32 , int32 > map_int32_int32 = 1;
  78. map<int64 , int64 > map_int64_int64 = 2;
  79. map<uint32 , uint32 > map_uint32_uint32 = 3;
  80. map<uint64 , uint64 > map_uint64_uint64 = 4;
  81. map<sint32 , sint32 > map_sint32_sint32 = 5;
  82. map<sint64 , sint64 > map_sint64_sint64 = 6;
  83. map<fixed32 , fixed32 > map_fixed32_fixed32 = 7;
  84. map<fixed64 , fixed64 > map_fixed64_fixed64 = 8;
  85. map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
  86. map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
  87. map<int32 , float > map_int32_float = 11;
  88. map<int32 , double > map_int32_double = 12;
  89. map<bool , bool > map_bool_bool = 13;
  90. map<int32 , MapEnum > map_int32_enum = 14;
  91. map<int32 , ForeignMessage> map_int32_foreign_message = 15;
  92. }
  93. // Previously, message containing enum called Type cannot be used as value of
  94. // map field.
  95. message MessageContainingEnumCalledType {
  96. enum Type {
  97. TYPE_FOO = 0;
  98. }
  99. map<int32, MessageContainingEnumCalledType> type = 1;
  100. }
  101. // Previously, message cannot contain map field called "entry".
  102. message MessageContainingMapCalledEntry {
  103. map<int32, int32> entry = 1;
  104. }