protobuf-generate 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5d33ecf2d7d77a5e6683308ae910c137103c6e2
4
- data.tar.gz: 3b9bcae4f9cb5a4b0f8a6345a41d005fa281ca80
3
+ metadata.gz: 4dfc74f7688e44e7b50a3ce841ac809205633097
4
+ data.tar.gz: 9ba9103b05c1a65409d0b9503838f575158be164
5
5
  SHA512:
6
- metadata.gz: 7f8f7ed76f4b78ccb68c64aaeb8d4f7866d90b6741cecc06856a83bfdfea1fab9a52a88f2f1eeb1e2fddeec7bf81a47a0ecf23039cb4170c3f4636c21c288fdc
7
- data.tar.gz: 46bd074d37993af2b63f7ba3deb5bf4105a167f736e8b1af6d5d5cb172f0e819c8594fbf84ad8a0f9b08e707d5b69043a479c27436a3c25c7ecdf948acd57778
6
+ metadata.gz: 505001be4621794ff21a622971c6c6a1de00c094cffed065572fc34c3c55f62e8c88c9f8cf8370abe79a10c27363ee4398e44be9ad35c7ced92cf216eb737575
7
+ data.tar.gz: 0fe4e63e11eca9882642e30ca3a401fcd5b772b7e3d20b11b7b8f5c109ba3d9a2e95cbd512b8b16cdeddcd93e77d7135c64771a947749cbdacd264e1d0f6c5c8
@@ -176,63 +176,70 @@ static int read_raw_double(double *value, const uint8_t *buffer, int offset) {
176
176
  <% end %>
177
177
 
178
178
  static int read_raw_varint32(uint32_t *tag, const uint8_t *buffer, int offset) {
179
- uint8_t result;
179
+ *tag = 0;
180
180
 
181
- offset = read_raw_byte(&result, buffer, offset);
182
- if (result >= 0) {
183
- *tag = result;
184
- return offset;
185
- }
186
- *tag = result & 0x7f;
187
- offset = read_raw_byte(&result, buffer, offset);
188
- if (result >= 0) {
189
- *tag |= result << 7;
190
- } else {
191
- *tag |= (result & 0x7f) << 7;
192
- offset = read_raw_byte(&result, buffer, offset);
193
- if (result >= 0) {
194
- *tag |= result << 14;
195
- } else {
196
- *tag |= (result & 0x7f) << 14;
197
- offset = read_raw_byte(&result, buffer, offset);
198
- if (result >= 0) {
199
- *tag |= ((uint32_t)result) << 21;
200
- } else {
201
- *tag |= (((uint32_t)result) & 0x7f) << 21;
202
- offset = read_raw_byte(&result, buffer, offset);
203
- *tag |= ((uint32_t)result) << 28;
204
- if (result < 0) {
205
- /* Discard upper 32 bits. */
206
- int i;
207
- for (i = 0; i < 5; ++ i) {
208
- offset = read_raw_byte(&result, buffer, offset);
209
- if (result >= 0) {
210
- return offset;
211
- }
212
- }
213
- /* Invalid state. */
214
- }
215
- }
216
- }
217
- }
181
+ uint8_t b;
182
+ offset = read_raw_byte(&b, buffer, offset);
183
+ *tag |= (uint32_t)(b & 0x7f) << 0;
184
+ if ((b & 0x80) == 0) return offset;
185
+
186
+ offset = read_raw_byte(&b, buffer, offset);
187
+ *tag |= (uint32_t)(b & 0x7f) << 7;
188
+ if ((b & 0x80) == 0) return offset;
189
+
190
+ offset = read_raw_byte(&b, buffer, offset);
191
+ *tag |= (uint32_t)(b & 0x7f) << 14;
192
+ if ((b & 0x80) == 0) return offset;
193
+
194
+ offset = read_raw_byte(&b, buffer, offset);
195
+ *tag |= (uint32_t)(b & 0x7f) << 21;
196
+ if ((b & 0x80) == 0) return offset;
197
+
198
+ offset = read_raw_byte(&b, buffer, offset);
199
+ *tag |= (uint32_t)(b & 0x7f) << 28;
218
200
  return offset;
219
201
  }
220
202
 
221
203
  <% if type_count(:int64, :sint64, :uint64) > 0 %>
222
204
  static int read_raw_varint64(uint64_t *tag, const uint8_t *buffer, int offset) {
223
- short shift = 0;
224
- uint8_t b;
225
205
  *tag = 0;
226
- while (shift < 64) {
227
- offset = read_raw_byte(&b, buffer, offset);
228
- *tag |= (uint64_t)(b & 0x7F) << shift;
229
- if ((b & 0x80) == 0) {
230
- return offset;
231
- }
232
- shift += 7;
233
- }
234
- /* return error code. */
235
- return -1;
206
+
207
+ uint8_t b;
208
+ offset = read_raw_byte(&b, buffer, offset);
209
+ *tag |= (uint64_t)(b & 0x7f) << 0;
210
+ if ((b & 0x80) == 0) return offset;
211
+
212
+ offset = read_raw_byte(&b, buffer, offset);
213
+ *tag |= (uint64_t)(b & 0x7f) << 7;
214
+ if ((b & 0x80) == 0) return offset;
215
+
216
+ offset = read_raw_byte(&b, buffer, offset);
217
+ *tag |= (uint64_t)(b & 0x7f) << 14;
218
+ if ((b & 0x80) == 0) return offset;
219
+
220
+ offset = read_raw_byte(&b, buffer, offset);
221
+ *tag |= (uint64_t)(b & 0x7f) << 21;
222
+ if ((b & 0x80) == 0) return offset;
223
+
224
+ offset = read_raw_byte(&b, buffer, offset);
225
+ *tag |= (uint64_t)(b & 0x7f) << 28;
226
+ if ((b & 0x80) == 0) return offset;
227
+
228
+ offset = read_raw_byte(&b, buffer, offset);
229
+ *tag |= (uint64_t)(b & 0x7f) << 35;
230
+ if ((b & 0x80) == 0) return offset;
231
+
232
+ offset = read_raw_byte(&b, buffer, offset);
233
+ *tag |= (uint64_t)(b & 0x7f) << 42;
234
+ if ((b & 0x80) == 0) return offset;
235
+
236
+ offset = read_raw_byte(&b, buffer, offset);
237
+ *tag |= (uint64_t)(b & 0x7f) << 49;
238
+ if ((b & 0x80) == 0) return offset;
239
+
240
+ offset = read_raw_byte(&b, buffer, offset);
241
+ *tag |= (uint64_t)(b & 0x7f) << 56;
242
+ return offset;
236
243
  }
237
244
  <% end %>
238
245
 
@@ -2,7 +2,7 @@ $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
2
2
 
3
3
  spec = Gem::Specification.new do |s|
4
4
  s.name = 'protobuf-generate'
5
- s.version = '0.2.1'
5
+ s.version = '0.2.2'
6
6
  s.summary = 'A multi-language concrete protobuf code generator.'
7
7
  s.description = 'A simple PEG parser, AST and template based approach to code generation.'
8
8
  s.authors = ['Shane Hanna']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf-generate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Hanna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-26 00:00:00.000000000 Z
11
+ date: 2013-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parslet