sc2ai 0.4.1 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -178,20 +178,38 @@ module Api
178
178
  # unexpected, so discard it and continue.
179
179
  if !found
180
180
  wire_type = tag & 0x7
181
+
182
+ unknown_bytes = +"".b
183
+ val = tag
184
+ while val != 0
185
+ byte = val & 0x7F
186
+
187
+ val >>= 7
188
+ # This drops the top bits,
189
+ # Otherwise, with a signed right shift,
190
+ # we get infinity one bits at the top
191
+ val &= (1 << 57) - 1
192
+
193
+ byte |= 0x80 if val != 0
194
+ unknown_bytes << byte
195
+ end
196
+
181
197
  case wire_type
182
198
  when 0
183
199
  i = 0
184
200
  while true
185
201
  newbyte = buff.getbyte(index)
186
202
  index += 1
187
- break if newbyte.nil? || newbyte < 0x80
203
+ break if newbyte.nil?
204
+ unknown_bytes << newbyte
205
+ break if newbyte < 0x80
188
206
  i += 1
189
207
  break if i > 9
190
208
  end
191
209
  when 1
210
+ unknown_bytes << buff.byteslice(index, 8)
192
211
  index += 8
193
212
  when 2
194
- ## PULL_BYTES
195
213
  value =
196
214
  if (byte0 = buff.getbyte(index)) < 0x80
197
215
  index += 1
@@ -247,15 +265,29 @@ module Api
247
265
  raise "integer decoding error"
248
266
  end
249
267
 
250
- buff.byteslice(index, value)
251
- index += value
268
+ val = value
269
+ while val != 0
270
+ byte = val & 0x7F
252
271
 
253
- ## END PULL_BYTES
272
+ val >>= 7
273
+ # This drops the top bits,
274
+ # Otherwise, with a signed right shift,
275
+ # we get infinity one bits at the top
276
+ val &= (1 << 57) - 1
277
+
278
+ byte |= 0x80 if val != 0
279
+ unknown_bytes << byte
280
+ end
281
+
282
+ unknown_bytes << buff.byteslice(index, value)
283
+ index += value
254
284
  when 5
285
+ unknown_bytes << buff.byteslice(index, 4)
255
286
  index += 4
256
287
  else
257
288
  raise "unknown wire type #{wire_type}"
258
289
  end
290
+ (@_unknown_fields ||= +"".b) << unknown_bytes
259
291
  return self if index >= len
260
292
  ## PULL_UINT64
261
293
  tag =
@@ -756,7 +788,7 @@ module Api
756
788
 
757
789
  buff
758
790
  end
759
-
791
+ buff << @_unknown_fields if @_unknown_fields
760
792
  buff
761
793
  end
762
794
 
@@ -955,20 +987,38 @@ module Api
955
987
  # unexpected, so discard it and continue.
956
988
  if !found
957
989
  wire_type = tag & 0x7
990
+
991
+ unknown_bytes = +"".b
992
+ val = tag
993
+ while val != 0
994
+ byte = val & 0x7F
995
+
996
+ val >>= 7
997
+ # This drops the top bits,
998
+ # Otherwise, with a signed right shift,
999
+ # we get infinity one bits at the top
1000
+ val &= (1 << 57) - 1
1001
+
1002
+ byte |= 0x80 if val != 0
1003
+ unknown_bytes << byte
1004
+ end
1005
+
958
1006
  case wire_type
959
1007
  when 0
960
1008
  i = 0
961
1009
  while true
962
1010
  newbyte = buff.getbyte(index)
963
1011
  index += 1
964
- break if newbyte.nil? || newbyte < 0x80
1012
+ break if newbyte.nil?
1013
+ unknown_bytes << newbyte
1014
+ break if newbyte < 0x80
965
1015
  i += 1
966
1016
  break if i > 9
967
1017
  end
968
1018
  when 1
1019
+ unknown_bytes << buff.byteslice(index, 8)
969
1020
  index += 8
970
1021
  when 2
971
- ## PULL_BYTES
972
1022
  value =
973
1023
  if (byte0 = buff.getbyte(index)) < 0x80
974
1024
  index += 1
@@ -1024,15 +1074,29 @@ module Api
1024
1074
  raise "integer decoding error"
1025
1075
  end
1026
1076
 
1027
- buff.byteslice(index, value)
1028
- index += value
1077
+ val = value
1078
+ while val != 0
1079
+ byte = val & 0x7F
1029
1080
 
1030
- ## END PULL_BYTES
1081
+ val >>= 7
1082
+ # This drops the top bits,
1083
+ # Otherwise, with a signed right shift,
1084
+ # we get infinity one bits at the top
1085
+ val &= (1 << 57) - 1
1086
+
1087
+ byte |= 0x80 if val != 0
1088
+ unknown_bytes << byte
1089
+ end
1090
+
1091
+ unknown_bytes << buff.byteslice(index, value)
1092
+ index += value
1031
1093
  when 5
1094
+ unknown_bytes << buff.byteslice(index, 4)
1032
1095
  index += 4
1033
1096
  else
1034
1097
  raise "unknown wire type #{wire_type}"
1035
1098
  end
1099
+ (@_unknown_fields ||= +"".b) << unknown_bytes
1036
1100
  return self if index >= len
1037
1101
  ## PULL_UINT64
1038
1102
  tag =
@@ -1417,7 +1481,7 @@ module Api
1417
1481
 
1418
1482
  [val].pack("e", buffer: buff)
1419
1483
  end
1420
-
1484
+ buff << @_unknown_fields if @_unknown_fields
1421
1485
  buff
1422
1486
  end
1423
1487
 
@@ -1574,20 +1638,38 @@ module Api
1574
1638
  # unexpected, so discard it and continue.
1575
1639
  if !found
1576
1640
  wire_type = tag & 0x7
1641
+
1642
+ unknown_bytes = +"".b
1643
+ val = tag
1644
+ while val != 0
1645
+ byte = val & 0x7F
1646
+
1647
+ val >>= 7
1648
+ # This drops the top bits,
1649
+ # Otherwise, with a signed right shift,
1650
+ # we get infinity one bits at the top
1651
+ val &= (1 << 57) - 1
1652
+
1653
+ byte |= 0x80 if val != 0
1654
+ unknown_bytes << byte
1655
+ end
1656
+
1577
1657
  case wire_type
1578
1658
  when 0
1579
1659
  i = 0
1580
1660
  while true
1581
1661
  newbyte = buff.getbyte(index)
1582
1662
  index += 1
1583
- break if newbyte.nil? || newbyte < 0x80
1663
+ break if newbyte.nil?
1664
+ unknown_bytes << newbyte
1665
+ break if newbyte < 0x80
1584
1666
  i += 1
1585
1667
  break if i > 9
1586
1668
  end
1587
1669
  when 1
1670
+ unknown_bytes << buff.byteslice(index, 8)
1588
1671
  index += 8
1589
1672
  when 2
1590
- ## PULL_BYTES
1591
1673
  value =
1592
1674
  if (byte0 = buff.getbyte(index)) < 0x80
1593
1675
  index += 1
@@ -1643,15 +1725,29 @@ module Api
1643
1725
  raise "integer decoding error"
1644
1726
  end
1645
1727
 
1646
- buff.byteslice(index, value)
1647
- index += value
1728
+ val = value
1729
+ while val != 0
1730
+ byte = val & 0x7F
1648
1731
 
1649
- ## END PULL_BYTES
1732
+ val >>= 7
1733
+ # This drops the top bits,
1734
+ # Otherwise, with a signed right shift,
1735
+ # we get infinity one bits at the top
1736
+ val &= (1 << 57) - 1
1737
+
1738
+ byte |= 0x80 if val != 0
1739
+ unknown_bytes << byte
1740
+ end
1741
+
1742
+ unknown_bytes << buff.byteslice(index, value)
1743
+ index += value
1650
1744
  when 5
1745
+ unknown_bytes << buff.byteslice(index, 4)
1651
1746
  index += 4
1652
1747
  else
1653
1748
  raise "unknown wire type #{wire_type}"
1654
1749
  end
1750
+ (@_unknown_fields ||= +"".b) << unknown_bytes
1655
1751
  return self if index >= len
1656
1752
  ## PULL_UINT64
1657
1753
  tag =
@@ -1906,7 +2002,7 @@ module Api
1906
2002
 
1907
2003
  [val].pack("e", buffer: buff)
1908
2004
  end
1909
-
2005
+ buff << @_unknown_fields if @_unknown_fields
1910
2006
  buff
1911
2007
  end
1912
2008
 
@@ -2565,20 +2661,38 @@ module Api
2565
2661
  # unexpected, so discard it and continue.
2566
2662
  if !found
2567
2663
  wire_type = tag & 0x7
2664
+
2665
+ unknown_bytes = +"".b
2666
+ val = tag
2667
+ while val != 0
2668
+ byte = val & 0x7F
2669
+
2670
+ val >>= 7
2671
+ # This drops the top bits,
2672
+ # Otherwise, with a signed right shift,
2673
+ # we get infinity one bits at the top
2674
+ val &= (1 << 57) - 1
2675
+
2676
+ byte |= 0x80 if val != 0
2677
+ unknown_bytes << byte
2678
+ end
2679
+
2568
2680
  case wire_type
2569
2681
  when 0
2570
2682
  i = 0
2571
2683
  while true
2572
2684
  newbyte = buff.getbyte(index)
2573
2685
  index += 1
2574
- break if newbyte.nil? || newbyte < 0x80
2686
+ break if newbyte.nil?
2687
+ unknown_bytes << newbyte
2688
+ break if newbyte < 0x80
2575
2689
  i += 1
2576
2690
  break if i > 9
2577
2691
  end
2578
2692
  when 1
2693
+ unknown_bytes << buff.byteslice(index, 8)
2579
2694
  index += 8
2580
2695
  when 2
2581
- ## PULL_BYTES
2582
2696
  value =
2583
2697
  if (byte0 = buff.getbyte(index)) < 0x80
2584
2698
  index += 1
@@ -2634,15 +2748,29 @@ module Api
2634
2748
  raise "integer decoding error"
2635
2749
  end
2636
2750
 
2637
- buff.byteslice(index, value)
2638
- index += value
2751
+ val = value
2752
+ while val != 0
2753
+ byte = val & 0x7F
2639
2754
 
2640
- ## END PULL_BYTES
2755
+ val >>= 7
2756
+ # This drops the top bits,
2757
+ # Otherwise, with a signed right shift,
2758
+ # we get infinity one bits at the top
2759
+ val &= (1 << 57) - 1
2760
+
2761
+ byte |= 0x80 if val != 0
2762
+ unknown_bytes << byte
2763
+ end
2764
+
2765
+ unknown_bytes << buff.byteslice(index, value)
2766
+ index += value
2641
2767
  when 5
2768
+ unknown_bytes << buff.byteslice(index, 4)
2642
2769
  index += 4
2643
2770
  else
2644
2771
  raise "unknown wire type #{wire_type}"
2645
2772
  end
2773
+ (@_unknown_fields ||= +"".b) << unknown_bytes
2646
2774
  return self if index >= len
2647
2775
  ## PULL_UINT64
2648
2776
  tag =
@@ -5935,7 +6063,7 @@ module Api
5935
6063
 
5936
6064
  [val].pack("e", buffer: buff)
5937
6065
  end
5938
-
6066
+ buff << @_unknown_fields if @_unknown_fields
5939
6067
  buff
5940
6068
  end
5941
6069