protobuf-core 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +18 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +23 -0
  8. data/Rakefile +5 -0
  9. data/bin/protoc-gen-ruby +16 -0
  10. data/lib/protobuf.rb +27 -0
  11. data/lib/protobuf/code_generator.rb +44 -0
  12. data/lib/protobuf/core.rb +2 -0
  13. data/lib/protobuf/core/version.rb +5 -0
  14. data/lib/protobuf/decoder.rb +73 -0
  15. data/lib/protobuf/deprecation.rb +112 -0
  16. data/lib/protobuf/descriptors.rb +3 -0
  17. data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +54 -0
  18. data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +251 -0
  19. data/lib/protobuf/encoder.rb +67 -0
  20. data/lib/protobuf/enum.rb +303 -0
  21. data/lib/protobuf/exceptions.rb +9 -0
  22. data/lib/protobuf/field.rb +74 -0
  23. data/lib/protobuf/field/base_field.rb +267 -0
  24. data/lib/protobuf/field/bool_field.rb +59 -0
  25. data/lib/protobuf/field/bytes_field.rb +82 -0
  26. data/lib/protobuf/field/double_field.rb +25 -0
  27. data/lib/protobuf/field/enum_field.rb +68 -0
  28. data/lib/protobuf/field/field_array.rb +87 -0
  29. data/lib/protobuf/field/fixed32_field.rb +25 -0
  30. data/lib/protobuf/field/fixed64_field.rb +28 -0
  31. data/lib/protobuf/field/float_field.rb +41 -0
  32. data/lib/protobuf/field/int32_field.rb +21 -0
  33. data/lib/protobuf/field/int64_field.rb +21 -0
  34. data/lib/protobuf/field/integer_field.rb +23 -0
  35. data/lib/protobuf/field/message_field.rb +65 -0
  36. data/lib/protobuf/field/sfixed32_field.rb +27 -0
  37. data/lib/protobuf/field/sfixed64_field.rb +28 -0
  38. data/lib/protobuf/field/signed_integer_field.rb +29 -0
  39. data/lib/protobuf/field/sint32_field.rb +21 -0
  40. data/lib/protobuf/field/sint64_field.rb +21 -0
  41. data/lib/protobuf/field/string_field.rb +34 -0
  42. data/lib/protobuf/field/uint32_field.rb +21 -0
  43. data/lib/protobuf/field/uint64_field.rb +21 -0
  44. data/lib/protobuf/field/varint_field.rb +73 -0
  45. data/lib/protobuf/generators/base.rb +70 -0
  46. data/lib/protobuf/generators/enum_generator.rb +41 -0
  47. data/lib/protobuf/generators/extension_generator.rb +27 -0
  48. data/lib/protobuf/generators/field_generator.rb +131 -0
  49. data/lib/protobuf/generators/file_generator.rb +132 -0
  50. data/lib/protobuf/generators/group_generator.rb +105 -0
  51. data/lib/protobuf/generators/message_generator.rb +98 -0
  52. data/lib/protobuf/generators/printable.rb +160 -0
  53. data/lib/protobuf/logging.rb +39 -0
  54. data/lib/protobuf/message.rb +193 -0
  55. data/lib/protobuf/message/fields.rb +133 -0
  56. data/lib/protobuf/message/serialization.rb +89 -0
  57. data/lib/protobuf/optionable.rb +23 -0
  58. data/lib/protobuf/wire_type.rb +10 -0
  59. data/proto/dynamic_discovery.proto +44 -0
  60. data/proto/google/protobuf/compiler/plugin.proto +147 -0
  61. data/proto/google/protobuf/descriptor.proto +620 -0
  62. data/proto/rpc.proto +62 -0
  63. data/protobuf-core.gemspec +31 -0
  64. data/spec/bin/protoc-gen-ruby_spec.rb +23 -0
  65. data/spec/data/data.bin +3 -0
  66. data/spec/data/types.bin +0 -0
  67. data/spec/encoding/all_types_spec.rb +105 -0
  68. data/spec/encoding/extreme_values_spec.rb +0 -0
  69. data/spec/functional/class_inheritance_spec.rb +52 -0
  70. data/spec/functional/compile_and_require_spec.rb +29 -0
  71. data/spec/lib/protobuf/base_spec.rb +84 -0
  72. data/spec/lib/protobuf/code_generator_spec.rb +60 -0
  73. data/spec/lib/protobuf/enum_generator_spec.rb +73 -0
  74. data/spec/lib/protobuf/enum_spec.rb +265 -0
  75. data/spec/lib/protobuf/extension_generator_spec.rb +42 -0
  76. data/spec/lib/protobuf/field/bool_field_spec.rb +51 -0
  77. data/spec/lib/protobuf/field/field_array_spec.rb +69 -0
  78. data/spec/lib/protobuf/field/float_field_spec.rb +55 -0
  79. data/spec/lib/protobuf/field/int32_field_spec.rb +90 -0
  80. data/spec/lib/protobuf/field/string_field_spec.rb +45 -0
  81. data/spec/lib/protobuf/field_generator_spec.rb +102 -0
  82. data/spec/lib/protobuf/field_spec.rb +191 -0
  83. data/spec/lib/protobuf/file_generator_spec.rb +32 -0
  84. data/spec/lib/protobuf/message_generator_spec.rb +0 -0
  85. data/spec/lib/protobuf/message_spec.rb +526 -0
  86. data/spec/lib/protobuf/optionable_spec.rb +46 -0
  87. data/spec/lib/protobuf_spec.rb +45 -0
  88. data/spec/spec_helper.rb +9 -0
  89. data/spec/support/packed_field.rb +22 -0
  90. data/spec/support/test/all_types.data.bin +0 -0
  91. data/spec/support/test/all_types.data.txt +119 -0
  92. data/spec/support/test/bacon.proto +14 -0
  93. data/spec/support/test/defaults.pb.rb +27 -0
  94. data/spec/support/test/defaults.proto +9 -0
  95. data/spec/support/test/enum.pb.rb +61 -0
  96. data/spec/support/test/enum.proto +34 -0
  97. data/spec/support/test/extended.pb.rb +24 -0
  98. data/spec/support/test/extended.proto +10 -0
  99. data/spec/support/test/extreme_values.data.bin +0 -0
  100. data/spec/support/test/google_unittest.pb.rb +530 -0
  101. data/spec/support/test/google_unittest.proto +713 -0
  102. data/spec/support/test/google_unittest_import.pb.rb +39 -0
  103. data/spec/support/test/google_unittest_import.proto +64 -0
  104. data/spec/support/test/google_unittest_import_public.pb.rb +10 -0
  105. data/spec/support/test/google_unittest_import_public.proto +38 -0
  106. data/spec/support/test/multi_field_extensions.pb.rb +58 -0
  107. data/spec/support/test/multi_field_extensions.proto +33 -0
  108. data/spec/support/test/resource.pb.rb +106 -0
  109. data/spec/support/test/resource.proto +94 -0
  110. metadata +306 -0
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf/message'
7
+
8
+ module GoogleUnittestImport
9
+
10
+ ##
11
+ # Enum Classes
12
+ #
13
+ class ImportEnum < ::Protobuf::Enum
14
+ define :IMPORT_FOO, 7
15
+ define :IMPORT_BAR, 8
16
+ define :IMPORT_BAZ, 9
17
+ end
18
+
19
+
20
+ ##
21
+ # Message Classes
22
+ #
23
+ class PublicImportMessage < ::Protobuf::Message; end
24
+ class ImportMessage < ::Protobuf::Message; end
25
+
26
+
27
+ ##
28
+ # Message Fields
29
+ #
30
+ class PublicImportMessage
31
+ optional :int32, :e, 1
32
+ end
33
+
34
+ class ImportMessage
35
+ optional :int32, :d, 1
36
+ end
37
+
38
+ end
39
+
@@ -0,0 +1,64 @@
1
+ // Protocol Buffers - Google's data interchange format
2
+ // Copyright 2008 Google Inc. All rights reserved.
3
+ // http://code.google.com/p/protobuf/
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
+
31
+ // Author: kenton@google.com (Kenton Varda)
32
+ // Based on original Protocol Buffers design by
33
+ // Sanjay Ghemawat, Jeff Dean, and others.
34
+ //
35
+ // A proto file which is imported by unittest.proto to test importing.
36
+
37
+
38
+ // We don't put this in a package within proto2 because we need to make sure
39
+ // that the generated code doesn't depend on being in the proto2 namespace.
40
+ // In test_util.h we do
41
+ // "using namespace unittest_import = protobuf_unittest_import".
42
+ package googleUnittestImport;
43
+
44
+ //############################## Test public import
45
+ // TODO: This will be supported in the next release of the
46
+ // compiler
47
+ // import public "test/google_unittest_import_public.proto";
48
+
49
+ message PublicImportMessage {
50
+ optional int32 e = 1;
51
+ }
52
+
53
+ //###############################
54
+
55
+ message ImportMessage {
56
+ optional int32 d = 1;
57
+ }
58
+
59
+ enum ImportEnum {
60
+ IMPORT_FOO = 7;
61
+ IMPORT_BAR = 8;
62
+ IMPORT_BAZ = 9;
63
+ }
64
+
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf/message'
7
+
8
+ module GoogleUnittestImport
9
+ end
10
+
@@ -0,0 +1,38 @@
1
+ // Protocol Buffers - Google's data interchange format
2
+ // Copyright 2008 Google Inc. All rights reserved.
3
+ // http://code.google.com/p/protobuf/
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
+
31
+ // Author: liujisi@google.com (Pherl Liu)
32
+
33
+
34
+ package googleUnittestImport;
35
+
36
+ //message PublicImportMessage {
37
+ // optional int32 e = 1;
38
+ //}
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf/message'
7
+
8
+ module Test
9
+
10
+ ##
11
+ # Message Classes
12
+ #
13
+ class Header < ::Protobuf::Message
14
+ class Type < ::Protobuf::Enum
15
+ define :PayloadTypeA, 1
16
+ define :PayloadTypeB, 2
17
+ end
18
+
19
+ end
20
+
21
+ class PayloadA < ::Protobuf::Message
22
+ class Foo < ::Protobuf::Message; end
23
+
24
+ end
25
+
26
+ class PayloadB < ::Protobuf::Message
27
+ class Foo < ::Protobuf::Message; end
28
+
29
+ end
30
+
31
+
32
+
33
+ ##
34
+ # Message Fields
35
+ #
36
+ class Header
37
+ required ::Test::Header::Type, :type, 1
38
+ # Extension Fields
39
+ extensions 100...536870912
40
+ optional ::Test::PayloadA, :payload, 100, :extension => true
41
+ end
42
+
43
+ class PayloadA
44
+ class Foo
45
+ optional :string, :foo_a, 1
46
+ end
47
+
48
+ end
49
+
50
+ class PayloadB
51
+ class Foo
52
+ optional :string, :foo_b, 1
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+
@@ -0,0 +1,33 @@
1
+ package test;
2
+
3
+ message Header {
4
+ extensions 100 to max;
5
+
6
+ enum Type {
7
+ PayloadTypeA = 1;
8
+ PayloadTypeB = 2;
9
+ }
10
+
11
+ required Type type = 1;
12
+ }
13
+
14
+ message PayloadA {
15
+ message Foo {
16
+ optional string foo_a = 1;
17
+ }
18
+
19
+ extend Header {
20
+ optional PayloadA payload = 100;
21
+ }
22
+ }
23
+
24
+ message PayloadB {
25
+ message Foo {
26
+ optional string foo_b = 1;
27
+ }
28
+
29
+ // UNCOMMENT TO TEST RUNTIME FAILING WITH MULTIPLE FIELDS
30
+ // extend Header {
31
+ // optional PayloadB payload = 101;
32
+ //}
33
+ }
@@ -0,0 +1,106 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf/message'
7
+
8
+ module Test
9
+
10
+ ##
11
+ # Enum Classes
12
+ #
13
+ class StatusType < ::Protobuf::Enum
14
+ define :PENDING, 0
15
+ define :ENABLED, 1
16
+ define :DISABLED, 2
17
+ define :DELETED, 3
18
+ end
19
+
20
+
21
+ ##
22
+ # Message Classes
23
+ #
24
+ class ResourceFindRequest < ::Protobuf::Message; end
25
+ class ResourceSleepRequest < ::Protobuf::Message; end
26
+ class Resource < ::Protobuf::Message; end
27
+ class ResourceWithRequiredField < ::Protobuf::Message; end
28
+ class Searchable < ::Protobuf::Message
29
+ class SearchType < ::Protobuf::Enum
30
+ define :FLAT, 1
31
+ define :NESTED, 2
32
+ end
33
+
34
+ end
35
+
36
+ class MessageParent < ::Protobuf::Message
37
+ class MessageChild < ::Protobuf::Message; end
38
+
39
+ end
40
+
41
+ class Nested < ::Protobuf::Message
42
+ class NestedLevelOne < ::Protobuf::Message; end
43
+
44
+ end
45
+
46
+
47
+
48
+ ##
49
+ # Message Fields
50
+ #
51
+ class ResourceFindRequest
52
+ required :string, :name, 1
53
+ optional :bool, :active, 2
54
+ repeated :string, :widgets, 3
55
+ repeated :bytes, :widget_bytes, 4
56
+ end
57
+
58
+ class ResourceSleepRequest
59
+ optional :int32, :sleep, 1
60
+ end
61
+
62
+ class Resource
63
+ required :string, :name, 1
64
+ optional :int64, :date_created, 2
65
+ optional ::Test::StatusType, :status, 3
66
+ repeated ::Test::StatusType, :repeated_enum, 4
67
+ # Extension Fields
68
+ extensions 100...536870912
69
+ optional :bool, :ext_is_searchable, 100, :extension => true
70
+ optional :bool, :ext_is_hidden, 101, :extension => true
71
+ optional ::Test::Searchable::SearchType, :ext_search_type, 102, :default => ::Test::Searchable::SearchType::FLAT, :extension => true
72
+ optional :bool, :ext_nested_in_level_one, 105, :extension => true
73
+ optional :bool, :ext_dup_field, 106, :extension => true
74
+ end
75
+
76
+ class ResourceWithRequiredField
77
+ required :string, :foo_is_required, 1
78
+ end
79
+
80
+ class MessageParent
81
+ class MessageChild
82
+ optional :string, :child1, 1
83
+ end
84
+
85
+ end
86
+
87
+ class Nested
88
+ class NestedLevelOne
89
+ optional :bool, :level_one, 1, :default => true
90
+ # Extension Fields
91
+ extensions 100...102
92
+ optional :bool, :ext_nested_level_one_outer, 101, :extension => true
93
+ optional :bool, :ext_nested_level_one, 100, :extension => true
94
+ end
95
+
96
+ optional :string, :name, 1
97
+ optional ::Test::Resource, :resource, 2
98
+ repeated ::Test::Resource, :multiple_resources, 3
99
+ optional ::Test::StatusType, :status, 4
100
+ # Extension Fields
101
+ extensions 100...111
102
+ optional :string, :foo, 100, :extension => true
103
+ optional :int64, :bar, 101, :extension => true
104
+ end
105
+ end
106
+
@@ -0,0 +1,94 @@
1
+ package test;
2
+
3
+ enum StatusType {
4
+ PENDING = 0;
5
+ ENABLED = 1;
6
+ DISABLED = 2;
7
+ DELETED = 3;
8
+ }
9
+
10
+ message ResourceFindRequest {
11
+ required string name = 1;
12
+ optional bool active = 2;
13
+ repeated string widgets = 3;
14
+ repeated bytes widget_bytes = 4;
15
+ }
16
+
17
+ message ResourceSleepRequest {
18
+ optional int32 sleep = 1;
19
+ }
20
+
21
+ message Resource {
22
+ extensions 100 to max;
23
+
24
+ required string name = 1;
25
+ optional int64 date_created = 2;
26
+ optional StatusType status = 3;
27
+ repeated StatusType repeated_enum = 4;
28
+ }
29
+
30
+ message ResourceWithRequiredField {
31
+ required string foo_is_required = 1;
32
+ }
33
+
34
+ message Searchable {
35
+ enum SearchType {
36
+ FLAT = 1;
37
+ NESTED = 2;
38
+ }
39
+
40
+ extend test.Resource {
41
+ optional bool ext_is_searchable = 100;
42
+ optional bool ext_is_hidden = 101;
43
+ optional Searchable.SearchType ext_search_type = 102 [default=FLAT];
44
+ }
45
+ }
46
+
47
+ message MessageParent {
48
+ message MessageChild {
49
+ optional string child1 = 1;
50
+ }
51
+ }
52
+
53
+ message Nested {
54
+ extensions 100 to 110;
55
+
56
+ optional string name = 1;
57
+ optional Resource resource = 2;
58
+ repeated Resource multiple_resources = 3;
59
+ optional StatusType status = 4;
60
+
61
+ message NestedLevelOne {
62
+ extensions 100 to 101;
63
+ optional bool level_one = 1 [default=true];
64
+
65
+ extend Resource {
66
+ optional bool ext_nested_in_level_one = 105;
67
+ optional bool ext_dup_field = 106;
68
+ }
69
+ }
70
+
71
+ extend NestedLevelOne {
72
+ optional bool ext_nested_level_one = 100;
73
+ }
74
+
75
+ // extend Resource {
76
+ // optional bool ext_dup_field = 107;
77
+ // }
78
+ }
79
+
80
+ extend Nested {
81
+ optional string foo = 100;
82
+ optional int64 bar = 101;
83
+ }
84
+
85
+ extend Nested.NestedLevelOne {
86
+ optional bool ext_nested_level_one_outer = 101;
87
+ }
88
+
89
+ service ResourceService {
90
+ rpc Find (ResourceFindRequest) returns (Resource);
91
+ rpc FindWithRpcFailed (ResourceFindRequest) returns (Resource);
92
+ rpc FindWithSleep (ResourceSleepRequest) returns (Resource);
93
+ rpc FindNotImplemented (ResourceFindRequest) returns (Resource);
94
+ }