google-protobuf 3.0.2-x86-linux → 3.1.0-x86-linux

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6d3dbf927f8695f787e15287da51530470ce2ea
4
- data.tar.gz: 16b9088041fec9738c35570f8e90fa4833bbb905
3
+ metadata.gz: b1fe3ba19b2182a739dcd6327a98cbffdd752205
4
+ data.tar.gz: da118c5b8e7f9b4fae014f63abb187d0ea960e1f
5
5
  SHA512:
6
- metadata.gz: 2102b82a430588a00c26795ac438b458cd87e5eb8e887de9d04735cb5734ed5dbc47e0dbb0274af702589289b9c41391f5b86fd3fc98898c900825c1f0b75118
7
- data.tar.gz: f6278515cb9ea1c8745ece9558334e67be149027230b0d9bdb99215cfe9a7bf2216777431b6dae0b27c4bf3514c2e67890fa978c140c2dab78a32f395bd7dbe9
6
+ metadata.gz: 5865c7176651756871d86c4ed8152e37558354c5ce9d17ff0c18eaa9668673dc2479fb1dee9b26d93d27972b2d886a8ac4d6260673c1c12cf98549fc2757293f
7
+ data.tar.gz: 90a41ecc9d17fae365cff2737fccbadce4679d630873062b2a7b0a6ff1f1620bdf71506f04f56636e646e271fd2481e301011a9b5e54606a09ddd4fd26ad36f6
@@ -447,9 +447,8 @@ VALUE RepeatedField_eq(VALUE _self, VALUE _other) {
447
447
  */
448
448
  VALUE RepeatedField_hash(VALUE _self) {
449
449
  RepeatedField* self = ruby_to_RepeatedField(_self);
450
-
451
- VALUE hash = LL2NUM(0);
452
-
450
+ st_index_t h = rb_hash_start(0);
451
+ VALUE hash_sym = rb_intern("hash");
453
452
  upb_fieldtype_t field_type = self->field_type;
454
453
  VALUE field_type_class = self->field_type_class;
455
454
  size_t elem_size = native_slot_size(field_type);
@@ -457,12 +456,11 @@ VALUE RepeatedField_hash(VALUE _self) {
457
456
  for (int i = 0; i < self->size; i++, off += elem_size) {
458
457
  void* mem = ((uint8_t *)self->elements) + off;
459
458
  VALUE elem = native_slot_get(field_type, field_type_class, mem);
460
- hash = rb_funcall(hash, rb_intern("<<"), 1, INT2NUM(2));
461
- hash = rb_funcall(hash, rb_intern("^"), 1,
462
- rb_funcall(elem, rb_intern("hash"), 0));
459
+ h = rb_hash_uint(h, NUM2LONG(rb_funcall(elem, hash_sym, 0)));
463
460
  }
461
+ h = rb_hash_end(h);
464
462
 
465
- return hash;
463
+ return INT2FIX(h);
466
464
  }
467
465
 
468
466
  /*
Binary file
Binary file
Binary file
Binary file
@@ -45,7 +45,7 @@ if RUBY_PLATFORM == "java"
45
45
  require 'google/protobuf_java'
46
46
  else
47
47
  begin
48
- require "google/#{RUBY_VERSION.sub(/\.\d$/, '')}/protobuf_c"
48
+ require "google/#{RUBY_VERSION.sub(/\.\d+$/, '')}/protobuf_c"
49
49
  rescue LoadError
50
50
  require 'google/protobuf_c'
51
51
  end
@@ -0,0 +1,212 @@
1
+ #!/usr/bin/ruby
2
+ # Protocol Buffers - Google's data interchange format
3
+ # Copyright 2008 Google Inc. All rights reserved.
4
+ # https://developers.google.com/protocol-buffers/
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
+
32
+ require 'google/protobuf/any_pb'
33
+ require 'google/protobuf/duration_pb'
34
+ require 'google/protobuf/field_mask_pb'
35
+ require 'google/protobuf/struct_pb'
36
+ require 'google/protobuf/timestamp_pb'
37
+
38
+ module Google
39
+ module Protobuf
40
+
41
+ Any.class_eval do
42
+ def pack(msg, type_url_prefix='type.googleapis.com/')
43
+ if type_url_prefix.empty? or type_url_prefix[-1] != '/' then
44
+ self.type_url = "#{type_url_prefix}/#{msg.class.descriptor.name}"
45
+ else
46
+ self.type_url = "#{type_url_prefix}#{msg.class.descriptor.name}"
47
+ end
48
+ self.value = msg.to_proto
49
+ end
50
+
51
+ def unpack(klass)
52
+ if self.is(klass) then
53
+ klass.decode(self.value)
54
+ else
55
+ nil
56
+ end
57
+ end
58
+
59
+ def type_name
60
+ return self.type_url.split("/")[-1]
61
+ end
62
+
63
+ def is(klass)
64
+ return self.type_name == klass.descriptor.name
65
+ end
66
+ end
67
+
68
+ Timestamp.class_eval do
69
+ def to_time
70
+ Time.at(self.to_f)
71
+ end
72
+
73
+ def from_time(time)
74
+ self.seconds = time.to_i
75
+ self.nanos = time.nsec
76
+ end
77
+
78
+ def to_i
79
+ self.seconds
80
+ end
81
+
82
+ def to_f
83
+ self.seconds + (self.nanos.to_f / 1_000_000_000)
84
+ end
85
+ end
86
+
87
+ Duration.class_eval do
88
+ def to_f
89
+ self.seconds + (self.nanos.to_f / 1_000_000_000)
90
+ end
91
+ end
92
+
93
+ class UnexpectedStructType < Google::Protobuf::Error; end
94
+
95
+ Value.class_eval do
96
+ def to_ruby(recursive = false)
97
+ case self.kind
98
+ when :struct_value
99
+ if recursive
100
+ self.struct_value.to_h
101
+ else
102
+ self.struct_value
103
+ end
104
+ when :list_value
105
+ if recursive
106
+ self.list_value.to_a
107
+ else
108
+ self.list_value
109
+ end
110
+ when :null_value
111
+ nil
112
+ when :number_value
113
+ self.number_value
114
+ when :string_value
115
+ self.string_value
116
+ when :bool_value
117
+ self.bool_value
118
+ else
119
+ raise UnexpectedStructType
120
+ end
121
+ end
122
+
123
+ def from_ruby(value)
124
+ case value
125
+ when NilClass
126
+ self.null_value = 0
127
+ when Numeric
128
+ self.number_value = value
129
+ when String
130
+ self.string_value = value
131
+ when TrueClass
132
+ self.bool_value = true
133
+ when FalseClass
134
+ self.bool_value = false
135
+ when Struct
136
+ self.struct_value = value
137
+ when Hash
138
+ self.struct_value = Struct.from_hash(value)
139
+ when ListValue
140
+ self.list_value = value
141
+ when Array
142
+ self.list_value = ListValue.from_a(value)
143
+ else
144
+ raise UnexpectedStructType
145
+ end
146
+ end
147
+ end
148
+
149
+ Struct.class_eval do
150
+ def [](key)
151
+ self.fields[key].to_ruby
152
+ end
153
+
154
+ def []=(key, value)
155
+ unless key.is_a?(String)
156
+ raise UnexpectedStructType, "Struct keys must be strings."
157
+ end
158
+ self.fields[key] ||= Google::Protobuf::Value.new
159
+ self.fields[key].from_ruby(value)
160
+ end
161
+
162
+ def to_h
163
+ ret = {}
164
+ self.fields.each { |key, val| ret[key] = val.to_ruby(true) }
165
+ ret
166
+ end
167
+
168
+ def self.from_hash(hash)
169
+ ret = Struct.new
170
+ hash.each { |key, val| ret[key] = val }
171
+ ret
172
+ end
173
+ end
174
+
175
+ ListValue.class_eval do
176
+ include Enumerable
177
+
178
+ def length
179
+ self.values.length
180
+ end
181
+
182
+ def [](index)
183
+ self.values[index].to_ruby
184
+ end
185
+
186
+ def []=(index, value)
187
+ self.values[index].from_ruby(value)
188
+ end
189
+
190
+ def <<(value)
191
+ wrapper = Google::Protobuf::Value.new
192
+ wrapper.from_ruby(value)
193
+ self.values << wrapper
194
+ end
195
+
196
+ def each
197
+ self.values.each { |x| yield(x.to_ruby) }
198
+ end
199
+
200
+ def to_a
201
+ self.values.map { |x| x.to_ruby(true) }
202
+ end
203
+
204
+ def self.from_a(arr)
205
+ ret = ListValue.new
206
+ arr.each { |val| ret << val }
207
+ ret
208
+ end
209
+ end
210
+
211
+ end
212
+ end
data/tests/basic.rb CHANGED
@@ -183,12 +183,15 @@ module BasicTest
183
183
 
184
184
  def test_hash
185
185
  m1 = TestMessage.new(:optional_int32 => 42)
186
- m2 = TestMessage.new(:optional_int32 => 102)
186
+ m2 = TestMessage.new(:optional_int32 => 102, repeated_string: ['please', 'work', 'ok?'])
187
+ m3 = TestMessage.new(:optional_int32 => 102, repeated_string: ['please', 'work', 'ok?'])
187
188
  assert m1.hash != 0
188
189
  assert m2.hash != 0
190
+ assert m3.hash != 0
189
191
  # relying on the randomness here -- if hash function changes and we are
190
192
  # unlucky enough to get a collision, then change the values above.
191
193
  assert m1.hash != m2.hash
194
+ assert_equal m2.hash, m3.hash
192
195
  end
193
196
 
194
197
  def test_unknown_field_errors
@@ -468,9 +471,9 @@ module BasicTest
468
471
  assert m.length == 2
469
472
 
470
473
  m2 = m.dup
471
- assert m == m2
474
+ assert_equal m, m2
472
475
  assert m.hash != 0
473
- assert m.hash == m2.hash
476
+ assert_equal m.hash, m2.hash
474
477
 
475
478
  collected = {}
476
479
  m.each { |k,v| collected[v] = k }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.1.0
5
5
  platform: x86-linux
6
6
  authors:
7
7
  - Protobuf Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-14 00:00:00.000000000 Z
11
+ date: 2016-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler-dock
@@ -99,6 +99,7 @@ files:
99
99
  - lib/google/protobuf/struct_pb.rb
100
100
  - lib/google/protobuf/timestamp_pb.rb
101
101
  - lib/google/protobuf/type_pb.rb
102
+ - lib/google/protobuf/well_known_types.rb
102
103
  - lib/google/protobuf/wrappers_pb.rb
103
104
  - tests/basic.rb
104
105
  - tests/generated_code_test.rb