google-protobuf 3.17.3 → 3.19.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of google-protobuf might be problematic. Click here for more details.

@@ -0,0 +1,268 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/protobuf/descriptor.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ descriptor_data = File.binread(__FILE__).split("\n__END__\n", 2)[1]
7
+ Google::Protobuf::DescriptorPool.generated_pool.add_serialized_file(descriptor_data)
8
+
9
+ module Google
10
+ module Protobuf
11
+ FileDescriptorSet = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FileDescriptorSet").msgclass
12
+ FileDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FileDescriptorProto").msgclass
13
+ DescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DescriptorProto").msgclass
14
+ DescriptorProto::ExtensionRange = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DescriptorProto.ExtensionRange").msgclass
15
+ DescriptorProto::ReservedRange = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DescriptorProto.ReservedRange").msgclass
16
+ ExtensionRangeOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ExtensionRangeOptions").msgclass
17
+ FieldDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldDescriptorProto").msgclass
18
+ FieldDescriptorProto::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldDescriptorProto.Type").enummodule
19
+ FieldDescriptorProto::Label = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldDescriptorProto.Label").enummodule
20
+ OneofDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.OneofDescriptorProto").msgclass
21
+ EnumDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumDescriptorProto").msgclass
22
+ EnumDescriptorProto::EnumReservedRange = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumDescriptorProto.EnumReservedRange").msgclass
23
+ EnumValueDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumValueDescriptorProto").msgclass
24
+ ServiceDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ServiceDescriptorProto").msgclass
25
+ MethodDescriptorProto = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.MethodDescriptorProto").msgclass
26
+ FileOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FileOptions").msgclass
27
+ FileOptions::OptimizeMode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FileOptions.OptimizeMode").enummodule
28
+ MessageOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.MessageOptions").msgclass
29
+ FieldOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions").msgclass
30
+ FieldOptions::CType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.CType").enummodule
31
+ FieldOptions::JSType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldOptions.JSType").enummodule
32
+ OneofOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.OneofOptions").msgclass
33
+ EnumOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumOptions").msgclass
34
+ EnumValueOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumValueOptions").msgclass
35
+ ServiceOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ServiceOptions").msgclass
36
+ MethodOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.MethodOptions").msgclass
37
+ MethodOptions::IdempotencyLevel = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.MethodOptions.IdempotencyLevel").enummodule
38
+ UninterpretedOption = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UninterpretedOption").msgclass
39
+ UninterpretedOption::NamePart = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UninterpretedOption.NamePart").msgclass
40
+ SourceCodeInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.SourceCodeInfo").msgclass
41
+ SourceCodeInfo::Location = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.SourceCodeInfo.Location").msgclass
42
+ GeneratedCodeInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.GeneratedCodeInfo").msgclass
43
+ GeneratedCodeInfo::Annotation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.GeneratedCodeInfo.Annotation").msgclass
44
+ end
45
+ end
46
+
47
+ __END__
48
+
49
+ google/protobuf/descriptor.protogoogle.protobuf"G
50
+ FileDescriptorSet2
51
+ file ( 2$.google.protobuf.FileDescriptorProto"�
52
+ FileDescriptorProto
53
+ name ( 
54
+ package ( 
55
+
56
+ dependency ( 
57
+ public_dependency
58
+ (
59
+ weak_dependency (6
60
+ message_type ( 2 .google.protobuf.DescriptorProto7
61
+ enum_type ( 2$.google.protobuf.EnumDescriptorProto8
62
+ service ( 2'.google.protobuf.ServiceDescriptorProto8
63
+ extension ( 2%.google.protobuf.FieldDescriptorProto-
64
+ options ( 2.google.protobuf.FileOptions9
65
+ source_code_info ( 2.google.protobuf.SourceCodeInfo
66
+ syntax ( "�
67
+ DescriptorProto
68
+ name ( 4
69
+ field ( 2%.google.protobuf.FieldDescriptorProto8
70
+ extension ( 2%.google.protobuf.FieldDescriptorProto5
71
+ nested_type ( 2 .google.protobuf.DescriptorProto7
72
+ enum_type ( 2$.google.protobuf.EnumDescriptorProtoH
73
+ extension_range ( 2/.google.protobuf.DescriptorProto.ExtensionRange9
74
+
75
+ oneof_decl ( 2%.google.protobuf.OneofDescriptorProto0
76
+ options ( 2.google.protobuf.MessageOptionsF
77
+ reserved_range ( 2..google.protobuf.DescriptorProto.ReservedRange
78
+
79
+ ( e
80
+ ExtensionRange
81
+ start (
82
+ end (7
83
+ options ( 2&.google.protobuf.ExtensionRangeOptions+
84
+
85
+ start (
86
+ end ("g
87
+ ExtensionRangeOptionsC
88
+ uninterpreted_option� ( 2$.google.protobuf.UninterpretedOption* �����"�
89
+ FieldDescriptorProto
90
+ name ( 
91
+ number (:
92
+ label (2+.google.protobuf.FieldDescriptorProto.Label8
93
+ type (2*.google.protobuf.FieldDescriptorProto.Type
94
+ type_name ( 
95
+ extendee ( 
96
+
97
+ oneof_index (
98
+ json_name
99
+ ( .
100
+ options ( 2.google.protobuf.FieldOptions
101
+ proto3_optional ("�
102
+ Type
103
+ TYPE_DOUBLE
104
+
105
+ TYPE_FLOAT
106
+
107
+ TYPE_INT64
108
+ TYPE_UINT64
109
+
110
+ TYPE_INT32
111
+ TYPE_FIXED64
112
+ TYPE_FIXED32
113
+ TYPE_BOOL
114
+ TYPE_STRING 
115
+
116
+ TYPE_GROUP
117
+ 
118
+ TYPE_MESSAGE 
119
+
120
+ TYPE_BYTES 
121
+ TYPE_UINT32
122
+ TYPE_ENUM
123
+
124
+
125
+ TYPE_SINT32
126
+ TYPE_SINT64"C
127
+ Label
128
+ LABEL_OPTIONAL
129
+ LABEL_REQUIRED
130
+ LABEL_REPEATED"T
131
+ OneofDescriptorProto
132
+ name ( .
133
+ options ( 2.google.protobuf.OneofOptions"�
134
+ EnumDescriptorProto
135
+ name ( 8
136
+ value ( 2).google.protobuf.EnumValueDescriptorProto-
137
+ options ( 2.google.protobuf.EnumOptionsN
138
+ reserved_range ( 26.google.protobuf.EnumDescriptorProto.EnumReservedRange
139
+
140
+ EnumReservedRange
141
+ start (
142
+ end ("l
143
+ EnumValueDescriptorProto
144
+ name ( 
145
+ number (2
146
+ options ( 2!.google.protobuf.EnumValueOptions"�
147
+ ServiceDescriptorProto
148
+ name ( 6
149
+ method ( 2&.google.protobuf.MethodDescriptorProto0
150
+ options ( 2.google.protobuf.ServiceOptions"�
151
+ MethodDescriptorProto
152
+ name ( 
153
+
154
+ input_type ( 
155
+ output_type ( /
156
+ options ( 2.google.protobuf.MethodOptions
157
+ client_streaming (:false
158
+ server_streaming (:false"�
159
+ FileOptions
160
+ java_package ( 
161
+ java_outer_classname ( "
162
+ java_multiple_files
163
+ (:false)
164
+ java_generate_equals_and_hash (B%
165
+ java_string_check_utf8 (:falseF
166
+ optimize_for (2).google.protobuf.FileOptions.OptimizeMode:SPEED
167
+
168
+ go_package ( "
169
+ cc_generic_services (:false$
170
+ java_generic_services (:false"
171
+ py_generic_services (:false#
172
+ php_generic_services* (:false
173
+
174
+ deprecated (:false
175
+ cc_enable_arenas (:true
176
+ objc_class_prefix$ ( 
177
+ csharp_namespace% ( 
178
+ swift_prefix' ( 
179
+ php_class_prefix( ( 
180
+
181
+ php_metadata_namespace, ( 
182
+ ruby_package- ( C
183
+ uninterpreted_option� ( 2$.google.protobuf.UninterpretedOption":
184
+ OptimizeMode
185
+ SPEED
186
+ CODE_SIZE
187
+ LITE_RUNTIME* �����J&'"�
188
+ MessageOptions&
189
+ message_set_wire_format (:false.
190
+ no_standard_descriptor_accessor (:false
191
+
192
+ deprecated (:false
193
+ map_entry (C
194
+ uninterpreted_option� ( 2$.google.protobuf.UninterpretedOption* �����JJJJ J 
195
+ "�
196
+ FieldOptions:
197
+ ctype (2#.google.protobuf.FieldOptions.CType:STRING
198
+ packed (?
199
+ jstype (2$.google.protobuf.FieldOptions.JSType: JS_NORMAL
200
+ lazy (:false
201
+
202
+ deprecated (:false
203
+ weak
204
+ (:falseC
205
+ uninterpreted_option� ( 2$.google.protobuf.UninterpretedOption"/
206
+ CType
207
+
208
+ STRING
209
+ CORD
210
+ STRING_PIECE"5
211
+ JSType
212
+ JS_NORMAL
213
+ JS_STRING
214
+ JS_NUMBER* �����J"^
215
+ OneofOptionsC
216
+ uninterpreted_option� ( 2$.google.protobuf.UninterpretedOption* �����"�
217
+ EnumOptions
218
+ allow_alias (
219
+
220
+ deprecated (:falseC
221
+ uninterpreted_option� ( 2$.google.protobuf.UninterpretedOption* �����J"}
222
+ EnumValueOptions
223
+
224
+ deprecated (:falseC
225
+ uninterpreted_option� ( 2$.google.protobuf.UninterpretedOption* �����"{
226
+ ServiceOptions
227
+
228
+ deprecated! (:falseC
229
+ uninterpreted_option� ( 2$.google.protobuf.UninterpretedOption* �����"�
230
+
231
+
232
+ deprecated! (:false_
233
+ idempotency_level" (2/.google.protobuf.MethodOptions.IdempotencyLevel:IDEMPOTENCY_UNKNOWNC
234
+ uninterpreted_option� ( 2$.google.protobuf.UninterpretedOption"P
235
+ IdempotencyLevel
236
+ IDEMPOTENCY_UNKNOWN
237
+ NO_SIDE_EFFECTS
238
+
239
+ IDEMPOTENT* �����"�
240
+ UninterpretedOption;
241
+ name ( 2-.google.protobuf.UninterpretedOption.NamePart
242
+ identifier_value ( 
243
+ positive_int_value (
244
+ negative_int_value (
245
+ double_value (
246
+ string_value ( 
247
+ aggregate_value ( 3
248
+ NamePart
249
+ name_part ( 
250
+ is_extension ("�
251
+ SourceCodeInfo:
252
+ location ( 2(.google.protobuf.SourceCodeInfo.Location�
253
+ Location
254
+ path (B
255
+ span (B
256
+ leading_comments ( 
257
+ trailing_comments ( !
258
+ leading_detached_comments ( "�
259
+ GeneratedCodeInfoA
260
+
261
+ annotation ( 2-.google.protobuf.GeneratedCodeInfo.AnnotationO
262
+
263
+ Annotation
264
+ path (B
265
+ source_file ( 
266
+ begin (
267
+ end (B~
268
+ com.google.protobufBDescriptorProtosHZ-google.golang.org/protobuf/types/descriptorpb��GPB�Google.Protobuf.Reflection
@@ -5,6 +5,7 @@ require 'google/protobuf'
5
5
 
6
6
  require 'google/protobuf/any_pb'
7
7
  require 'google/protobuf/source_context_pb'
8
+
8
9
  Google::Protobuf::DescriptorPool.generated_pool.build do
9
10
  add_file("google/protobuf/type.proto", :syntax => :proto3) do
10
11
  add_message "google.protobuf.Type" do
@@ -85,6 +85,11 @@ module Google
85
85
  def from_time(time)
86
86
  self.seconds = time.to_i
87
87
  self.nanos = time.nsec
88
+ self
89
+ end
90
+
91
+ def self.from_time(time)
92
+ new.from_time(time)
88
93
  end
89
94
 
90
95
  def to_i
@@ -51,77 +51,9 @@ else
51
51
  require 'google/protobuf_c'
52
52
  end
53
53
 
54
- module Google
55
- module Protobuf
56
- module Internal
57
- def self.infer_package(names)
58
- # Package is longest common prefix ending in '.', if any.
59
- if not names.empty?
60
- min, max = names.minmax
61
- last_common_dot = nil
62
- min.size.times { |i|
63
- if min[i] != max[i] then break end
64
- if min[i] == ?. then last_common_dot = i end
65
- }
66
- if last_common_dot
67
- return min.slice(0, last_common_dot)
68
- end
69
- end
70
-
71
- nil
72
- end
73
-
74
- class NestingBuilder
75
- def initialize(msg_names, enum_names)
76
- @to_pos = {nil=>nil}
77
- @msg_children = Hash.new { |hash, key| hash[key] = [] }
78
- @enum_children = Hash.new { |hash, key| hash[key] = [] }
79
-
80
- msg_names.each_with_index { |name, idx| @to_pos[name] = idx }
81
- enum_names.each_with_index { |name, idx| @to_pos[name] = idx }
82
-
83
- msg_names.each { |name| @msg_children[parent(name)] << name }
84
- enum_names.each { |name| @enum_children[parent(name)] << name }
85
- end
86
-
87
- def build(package)
88
- return build_msg(package)
89
- end
90
-
91
- private
92
- def build_msg(msg)
93
- return {
94
- :pos => @to_pos[msg],
95
- :msgs => @msg_children[msg].map { |child| build_msg(child) },
96
- :enums => @enum_children[msg].map { |child| @to_pos[child] },
97
- }
98
- end
99
-
100
- private
101
- def parent(name)
102
- idx = name.rindex(?.)
103
- if idx
104
- return name.slice(0, idx)
105
- else
106
- return nil
107
- end
108
- end
109
- end
110
-
111
- def self.fixup_descriptor(package, msg_names, enum_names)
112
- if package.nil?
113
- package = self.infer_package(msg_names + enum_names)
114
- end
115
-
116
- nesting = NestingBuilder.new(msg_names, enum_names).build(package)
117
-
118
- return package, nesting
119
- end
120
- end
121
- end
122
- end
123
54
  end
124
55
 
56
+ require 'google/protobuf/descriptor_dsl'
125
57
  require 'google/protobuf/repeated_field'
126
58
 
127
59
  module Google
data/tests/basic.rb CHANGED
@@ -66,10 +66,19 @@ module BasicTest
66
66
  def test_issue_8559_crash
67
67
  msg = TestMessage.new
68
68
  msg.repeated_int32 = ::Google::Protobuf::RepeatedField.new(:int32, [1, 2, 3])
69
- GC.start(full_mark: true, immediate_sweep: true)
69
+ # TODO: Remove the platform check once https://github.com/jruby/jruby/issues/6818 is released in JRuby 9.3.0.0
70
+ GC.start(full_mark: true, immediate_sweep: true) unless RUBY_PLATFORM == "java"
70
71
  TestMessage.encode(msg)
71
72
  end
72
73
 
74
+ def test_issue_9440
75
+ msg = HelloRequest.new
76
+ msg.id = 8
77
+ assert_equal 8, msg.id
78
+ msg.version = '1'
79
+ assert_equal 8, msg.id
80
+ end
81
+
73
82
  def test_has_field
74
83
  m = TestSingularFields.new
75
84
  assert !m.has_singular_msg?
@@ -168,6 +177,17 @@ module BasicTest
168
177
  assert_equal nil, m.singular_msg
169
178
  end
170
179
 
180
+ def test_import_proto2
181
+ m = TestMessage.new
182
+ assert !m.has_optional_proto2_submessage?
183
+ m.optional_proto2_submessage = ::FooBar::Proto2::TestImportedMessage.new
184
+ assert m.has_optional_proto2_submessage?
185
+ assert TestMessage.descriptor.lookup('optional_proto2_submessage').has?(m)
186
+
187
+ m.clear_optional_proto2_submessage
188
+ assert !m.has_optional_proto2_submessage?
189
+ end
190
+
171
191
  def test_clear_repeated_fields
172
192
  m = TestMessage.new
173
193
 
@@ -487,6 +507,7 @@ module BasicTest
487
507
  :optional_int64=>0,
488
508
  :optional_msg=>nil,
489
509
  :optional_msg2=>nil,
510
+ :optional_proto2_submessage=>nil,
490
511
  :optional_string=>"foo",
491
512
  :optional_uint32=>0,
492
513
  :optional_uint64=>0,
@@ -607,5 +628,21 @@ module BasicTest
607
628
  assert_raise(FrozenErrorType) { m.map_string_int32.delete('a') }
608
629
  assert_raise(FrozenErrorType) { m.map_string_int32.clear }
609
630
  end
631
+
632
+ def test_map_length
633
+ m = proto_module::MapMessage.new
634
+ assert_equal 0, m.map_string_int32.length
635
+ assert_equal 0, m.map_string_msg.length
636
+ assert_equal 0, m.map_string_int32.size
637
+ assert_equal 0, m.map_string_msg.size
638
+
639
+ m.map_string_int32['a'] = 1
640
+ m.map_string_int32['b'] = 2
641
+ m.map_string_msg['a'] = proto_module::TestMessage2.new
642
+ assert_equal 2, m.map_string_int32.length
643
+ assert_equal 1, m.map_string_msg.length
644
+ assert_equal 2, m.map_string_int32.size
645
+ assert_equal 1, m.map_string_msg.size
646
+ end
610
647
  end
611
648
  end
data/tests/stress.rb CHANGED
@@ -30,7 +30,7 @@ module StressTest
30
30
  100_000.times do
31
31
  mnew = TestMessage.decode(data)
32
32
  mnew = mnew.dup
33
- assert_equal mnew.inspect, m.inspect
33
+ assert_equal m.inspect, mnew.inspect
34
34
  assert TestMessage.encode(mnew) == data
35
35
  end
36
36
  end
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.17.3
4
+ version: 3.19.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Protobuf Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-08 00:00:00.000000000 Z
11
+ date: 2022-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler-dock
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.1.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '2.0'
23
20
  type: :development
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
24
+ - - '='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.1.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '2.0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rake-compiler
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -64,20 +58,6 @@ dependencies:
64
58
  - - ">="
65
59
  - !ruby/object:Gem::Version
66
60
  version: 3.0.9
67
- - !ruby/object:Gem::Dependency
68
- name: rubygems-tasks
69
- requirement: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - "~>"
72
- - !ruby/object:Gem::Version
73
- version: 0.2.4
74
- type: :development
75
- prerelease: false
76
- version_requirements: !ruby/object:Gem::Requirement
77
- requirements:
78
- - - "~>"
79
- - !ruby/object:Gem::Version
80
- version: 0.2.4
81
61
  description: Protocol Buffers are Google's data interchange format.
82
62
  email: protobuf@googlegroups.com
83
63
  executables: []
@@ -100,11 +80,12 @@ files:
100
80
  - ext/google/protobuf_c/repeated_field.h
101
81
  - ext/google/protobuf_c/ruby-upb.c
102
82
  - ext/google/protobuf_c/ruby-upb.h
103
- - ext/google/protobuf_c/third_party/wyhash/wyhash.h
104
83
  - ext/google/protobuf_c/wrap_memcpy.c
105
84
  - lib/google/protobuf.rb
106
85
  - lib/google/protobuf/any_pb.rb
107
86
  - lib/google/protobuf/api_pb.rb
87
+ - lib/google/protobuf/descriptor_dsl.rb
88
+ - lib/google/protobuf/descriptor_pb.rb
108
89
  - lib/google/protobuf/duration_pb.rb
109
90
  - lib/google/protobuf/empty_pb.rb
110
91
  - lib/google/protobuf/field_mask_pb.rb
@@ -123,7 +104,7 @@ homepage: https://developers.google.com/protocol-buffers
123
104
  licenses:
124
105
  - BSD-3-Clause
125
106
  metadata:
126
- source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.17.3/ruby
107
+ source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.19.6/ruby
127
108
  post_install_message:
128
109
  rdoc_options: []
129
110
  require_paths:
@@ -139,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
120
  - !ruby/object:Gem::Version
140
121
  version: '0'
141
122
  requirements: []
142
- rubygems_version: 3.2.19
123
+ rubygems_version: 3.0.3.1
143
124
  signing_key:
144
125
  specification_version: 4
145
126
  summary: Protocol Buffers
@@ -1,145 +0,0 @@
1
- /* Copyright 2020 王一 Wang Yi <godspeed_china@yeah.net>
2
- This is free and unencumbered software released into the public domain. http://unlicense.org/
3
- See github.com/wangyi-fudan/wyhash/ LICENSE
4
- */
5
- #ifndef wyhash_final_version
6
- #define wyhash_final_version
7
- //defines that change behavior
8
- #ifndef WYHASH_CONDOM
9
- #define WYHASH_CONDOM 1 //0: read 8 bytes before and after boundaries, dangerous but fastest. 1: normal valid behavior 2: extra protection against entropy loss (probability=2^-63), aka. "blind multiplication"
10
- #endif
11
- #define WYHASH_32BIT_MUM 0 //faster on 32 bit system
12
- //includes
13
- #include <stdint.h>
14
- #include <string.h>
15
- #if defined(_MSC_VER) && defined(_M_X64)
16
- #include <intrin.h>
17
- #pragma intrinsic(_umul128)
18
- #endif
19
- #if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)
20
- #define _likely_(x) __builtin_expect(x,1)
21
- #define _unlikely_(x) __builtin_expect(x,0)
22
- #else
23
- #define _likely_(x) (x)
24
- #define _unlikely_(x) (x)
25
- #endif
26
- //mum function
27
- static inline uint64_t _wyrot(uint64_t x) { return (x>>32)|(x<<32); }
28
- static inline void _wymum(uint64_t *A, uint64_t *B){
29
- #if(WYHASH_32BIT_MUM)
30
- uint64_t hh=(*A>>32)*(*B>>32), hl=(*A>>32)*(unsigned)*B, lh=(unsigned)*A*(*B>>32), ll=(uint64_t)(unsigned)*A*(unsigned)*B;
31
- #if(WYHASH_CONDOM>1)
32
- *A^=_wyrot(hl)^hh; *B^=_wyrot(lh)^ll;
33
- #else
34
- *A=_wyrot(hl)^hh; *B=_wyrot(lh)^ll;
35
- #endif
36
- #elif defined(__SIZEOF_INT128__)
37
- __uint128_t r=*A; r*=*B;
38
- #if(WYHASH_CONDOM>1)
39
- *A^=(uint64_t)r; *B^=(uint64_t)(r>>64);
40
- #else
41
- *A=(uint64_t)r; *B=(uint64_t)(r>>64);
42
- #endif
43
- #elif defined(_MSC_VER) && defined(_M_X64)
44
- #if(WYHASH_CONDOM>1)
45
- uint64_t a, b;
46
- a=_umul128(*A,*B,&b);
47
- *A^=a; *B^=b;
48
- #else
49
- *A=_umul128(*A,*B,B);
50
- #endif
51
- #else
52
- uint64_t ha=*A>>32, hb=*B>>32, la=(uint32_t)*A, lb=(uint32_t)*B, hi, lo;
53
- uint64_t rh=ha*hb, rm0=ha*lb, rm1=hb*la, rl=la*lb, t=rl+(rm0<<32), c=t<rl;
54
- lo=t+(rm1<<32); c+=lo<t; hi=rh+(rm0>>32)+(rm1>>32)+c;
55
- #if(WYHASH_CONDOM>1)
56
- *A^=lo; *B^=hi;
57
- #else
58
- *A=lo; *B=hi;
59
- #endif
60
- #endif
61
- }
62
- static inline uint64_t _wymix(uint64_t A, uint64_t B){ _wymum(&A,&B); return A^B; }
63
- //read functions
64
- #ifndef WYHASH_LITTLE_ENDIAN
65
- #if defined(_WIN32) || defined(__LITTLE_ENDIAN__) || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
66
- #define WYHASH_LITTLE_ENDIAN 1
67
- #elif defined(__BIG_ENDIAN__) || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
68
- #define WYHASH_LITTLE_ENDIAN 0
69
- #endif
70
- #endif
71
- #if (WYHASH_LITTLE_ENDIAN)
72
- static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return v;}
73
- static inline uint64_t _wyr4(const uint8_t *p) { unsigned v; memcpy(&v, p, 4); return v;}
74
- #elif defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)
75
- static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return __builtin_bswap64(v);}
76
- static inline uint64_t _wyr4(const uint8_t *p) { unsigned v; memcpy(&v, p, 4); return __builtin_bswap32(v);}
77
- #elif defined(_MSC_VER)
78
- static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return _byteswap_uint64(v);}
79
- static inline uint64_t _wyr4(const uint8_t *p) { unsigned v; memcpy(&v, p, 4); return _byteswap_ulong(v);}
80
- #endif
81
- static inline uint64_t _wyr3(const uint8_t *p, unsigned k) { return (((uint64_t)p[0])<<16)|(((uint64_t)p[k>>1])<<8)|p[k-1];}
82
- //wyhash function
83
- static inline uint64_t _wyfinish16(const uint8_t *p, uint64_t len, uint64_t seed, const uint64_t *secret, uint64_t i){
84
- #if(WYHASH_CONDOM>0)
85
- uint64_t a, b;
86
- if(_likely_(i<=8)){
87
- if(_likely_(i>=4)){ a=_wyr4(p); b=_wyr4(p+i-4); }
88
- else if (_likely_(i)){ a=_wyr3(p,i); b=0; }
89
- else a=b=0;
90
- }
91
- else{ a=_wyr8(p); b=_wyr8(p+i-8); }
92
- return _wymix(secret[1]^len,_wymix(a^secret[1], b^seed));
93
- #else
94
- #define oneshot_shift ((i<8)*((8-i)<<3))
95
- return _wymix(secret[1]^len,_wymix((_wyr8(p)<<oneshot_shift)^secret[1],(_wyr8(p+i-8)>>oneshot_shift)^seed));
96
- #endif
97
- }
98
-
99
- static inline uint64_t _wyfinish(const uint8_t *p, uint64_t len, uint64_t seed, const uint64_t *secret, uint64_t i){
100
- if(_likely_(i<=16)) return _wyfinish16(p,len,seed,secret,i);
101
- return _wyfinish(p+16,len,_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed),secret,i-16);
102
- }
103
-
104
- static inline uint64_t wyhash(const void *key, uint64_t len, uint64_t seed, const uint64_t *secret){
105
- const uint8_t *p=(const uint8_t *)key;
106
- uint64_t i=len; seed^=*secret;
107
- if(_unlikely_(i>64)){
108
- uint64_t see1=seed;
109
- do{
110
- seed=_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed)^_wymix(_wyr8(p+16)^secret[2],_wyr8(p+24)^seed);
111
- see1=_wymix(_wyr8(p+32)^secret[3],_wyr8(p+40)^see1)^_wymix(_wyr8(p+48)^secret[4],_wyr8(p+56)^see1);
112
- p+=64; i-=64;
113
- }while(i>64);
114
- seed^=see1;
115
- }
116
- return _wyfinish(p,len,seed,secret,i);
117
- }
118
- //utility functions
119
- static const uint64_t _wyp[5] = {0xa0761d6478bd642full, 0xe7037ed1a0b428dbull, 0x8ebc6af09c88c6e3ull, 0x589965cc75374cc3ull, 0x1d8e4e27c47d124full};
120
- static inline uint64_t wyhash64(uint64_t A, uint64_t B){ A^=_wyp[0]; B^=_wyp[1]; _wymum(&A,&B); return _wymix(A^_wyp[0],B^_wyp[1]);}
121
- static inline uint64_t wyrand(uint64_t *seed){ *seed+=_wyp[0]; return _wymix(*seed,*seed^_wyp[1]);}
122
- static inline double wy2u01(uint64_t r){ const double _wynorm=1.0/(1ull<<52); return (r>>12)*_wynorm;}
123
- static inline double wy2gau(uint64_t r){ const double _wynorm=1.0/(1ull<<20); return ((r&0x1fffff)+((r>>21)&0x1fffff)+((r>>42)&0x1fffff))*_wynorm-3.0;}
124
- static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; }
125
-
126
- static inline void make_secret(uint64_t seed, uint64_t *secret){
127
- uint8_t c[] = {15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58, 60, 71, 75, 77, 78, 83, 85, 86, 89, 90, 92, 99, 101, 102, 105, 106, 108, 113, 114, 116, 120, 135, 139, 141, 142, 147, 149, 150, 153, 154, 156, 163, 165, 166, 169, 170, 172, 177, 178, 180, 184, 195, 197, 198, 201, 202, 204, 209, 210, 212, 216, 225, 226, 228, 232, 240 };
128
- for(size_t i=0;i<5;i++){
129
- uint8_t ok;
130
- do{
131
- ok=1; secret[i]=0;
132
- for(size_t j=0;j<64;j+=8) secret[i]|=((uint64_t)c[wyrand(&seed)%sizeof(c)])<<j;
133
- if(secret[i]%2==0){ ok=0; continue; }
134
- for(size_t j=0;j<i;j++)
135
- #if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)
136
- if(__builtin_popcountll(secret[j]^secret[i])!=32){ ok=0; break; }
137
- #elif defined(_MSC_VER) && defined(_M_X64)
138
- if(_mm_popcnt_u64(secret[j]^secret[i])!=32){ ok=0; break; }
139
- #endif
140
- if(!ok)continue;
141
- for(uint64_t j=3;j<0x100000000ull;j+=2) if(secret[i]%j==0){ ok=0; break; }
142
- }while(!ok);
143
- }
144
- }
145
- #endif