Method: IcAgent::Candid.leb128i_decode

Defined in:
lib/ic_agent/candid.rb

.leb128i_decode(pipe) ⇒ Object



1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
# File 'lib/ic_agent/candid.rb', line 1358

def self.leb128i_decode(pipe)
  length = pipe.buffer.length
  count = 0
  (0...length).each do |i|
    count = i
    if pipe.buffer[i] < '80'   # 0x80
      if pipe.buffer[i] < '40' # 0x40
        return leb128u_decode(pipe)
      end

      break
    end
  end
  res = StringIO.new
  res.putc(safe_read(pipe, count + 1).hex)
  LEB128.decode_signed(res)
end