erlang_rb 1.7.5 → 1.8.0

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: ba7347aefac6e4656ee2c2bdb09b4331e8d918e2
4
- data.tar.gz: 10faf3c7ae747c865232bdc8faf17345efcce6d7
3
+ metadata.gz: 01a38d9f79736ca6e186d862077fd3ab6deceab4
4
+ data.tar.gz: 96988c81914130f61694678f3bb743ce0f96204d
5
5
  SHA512:
6
- metadata.gz: deacc5353c6e26cb2812150de8546bf5c4c7c30efaec730afe97e471feabd6bbcca50e4435e974675674cd9f7263ea77791b5fdfb1fada3d40d9aa419a744114
7
- data.tar.gz: 7f023589a206ee8eef60d94c52098c3953a2b37a9e2afd9343e3d5201720feac666005bd178d499b7e7557306b5c803eda1ef6236a00829e266ee087aefe22ba
6
+ metadata.gz: 1ab24b9f6106407798ff282a88c1e7463a4c3d00f5dec4dd9543a349b642d5c371311709f573be265b6f8d876b4f153492a47dee1d5e184d76b611f6fd494095
7
+ data.tar.gz: 7cf34813dd0dc5a0c722aadd2d8b45fe7dfd4a8b1d10283d19400bc8b424678397999f7375d0ee4b192a82e3c99c4449742de86c38f92ae9ef97f967ab730ffc
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # MIT License
5
5
  #
6
- # Copyright (c) 2011-2018 Michael Truog <mjtruog at protonmail dot com>
6
+ # Copyright (c) 2011-2019 Michael Truog <mjtruog at protonmail dot com>
7
7
  #
8
8
  # Permission is hereby granted, free of charge, to any person obtaining a
9
9
  # copy of this software and associated documentation files (the "Software"),
@@ -192,8 +192,16 @@ module Erlang
192
192
  attr_reader :serial
193
193
  attr_reader :creation
194
194
  def binary
195
- return "#{TAG_PID_EXT.chr}" \
196
- "#{@node.binary}#{@id}#{@serial}#{@creation}"
195
+ creation_size = @creation.bytesize
196
+ if creation_size == 1
197
+ return "#{TAG_PID_EXT.chr}" \
198
+ "#{@node.binary}#{@id}#{@serial}#{@creation}"
199
+ elsif creation_size == 4
200
+ return "#{TAG_NEW_PID_EXT.chr}" \
201
+ "#{@node.binary}#{@id}#{@serial}#{@creation}"
202
+ else
203
+ raise OutputException, 'unknown pid type', caller
204
+ end
197
205
  end
198
206
  def to_s
199
207
  return "#{self.class.name}" \
@@ -219,7 +227,16 @@ module Erlang
219
227
  attr_reader :id
220
228
  attr_reader :creation
221
229
  def binary
222
- return "#{TAG_PORT_EXT.chr}#{@node.binary}#{@id}#{@creation}"
230
+ creation_size = @creation.bytesize
231
+ if creation_size == 1
232
+ return "#{TAG_PORT_EXT.chr}" \
233
+ "#{@node.binary}#{@id}#{@creation}"
234
+ elsif creation_size == 4
235
+ return "#{TAG_NEW_PORT_EXT.chr}" \
236
+ "#{@node.binary}#{@id}#{@creation}"
237
+ else
238
+ raise OutputException, 'unknown port type', caller
239
+ end
223
240
  end
224
241
  def to_s
225
242
  return "#{self.class.name}" \
@@ -250,8 +267,16 @@ module Erlang
250
267
  "#{@node.binary}#{@id}#{@creation}"
251
268
  elsif length <= 65535
252
269
  length_packed = [length].pack('n')
253
- return "#{TAG_NEW_REFERENCE_EXT.chr}#{length_packed}" \
254
- "#{@node.binary}#{@creation}#{@id}"
270
+ creation_size = @creation.bytesize
271
+ if creation_size == 1
272
+ return "#{TAG_NEW_REFERENCE_EXT.chr}#{length_packed}" \
273
+ "#{@node.binary}#{@creation}#{@id}"
274
+ elsif creation_size == 4
275
+ return "#{TAG_NEWER_REFERENCE_EXT.chr}#{length_packed}" \
276
+ "#{@node.binary}#{@creation}#{@id}"
277
+ else
278
+ raise OutputException, 'unknown reference type', caller
279
+ end
255
280
  else
256
281
  raise OutputException, 'uint16 overflow', caller
257
282
  end
@@ -354,27 +379,38 @@ module Erlang
354
379
  else
355
380
  raise ParseException, 'invalid atom_name latin1', caller
356
381
  end
357
- elsif tag == TAG_REFERENCE_EXT or tag == TAG_PORT_EXT
382
+ elsif tag == TAG_NEW_PORT_EXT or \
383
+ tag == TAG_REFERENCE_EXT or tag == TAG_PORT_EXT
358
384
  result = binary_to_atom(i, data)
359
385
  i = result[0]; node = result[1]
360
386
  id = data[i,4]
361
387
  i += 4
362
- creation = data[i]
363
- i += 1
364
- if tag == TAG_REFERENCE_EXT
365
- return [i, OtpErlangReference.new(node, id, creation)]
366
- elsif tag == TAG_PORT_EXT
367
- return [i, OtpErlangPort.new(node, id, creation)]
388
+ if tag == TAG_NEW_PORT_EXT
389
+ creation = data[i,4]
390
+ i += 4
391
+ else
392
+ creation = data[i]
393
+ i += 1
394
+ if tag == TAG_REFERENCE_EXT
395
+ return [i, OtpErlangReference.new(node, id, creation)]
396
+ end
368
397
  end
369
- elsif tag == TAG_PID_EXT
398
+ # tag == TAG_NEW_PORT_EXT or tag == TAG_PORT_EXT
399
+ return [i, OtpErlangPort.new(node, id, creation)]
400
+ elsif tag == TAG_NEW_PID_EXT or tag == TAG_PID_EXT
370
401
  result = binary_to_atom(i, data)
371
402
  i = result[0]; node = result[1]
372
403
  id = data[i,4]
373
404
  i += 4
374
405
  serial = data[i,4]
375
406
  i += 4
376
- creation = data[i]
377
- i += 1
407
+ if tag == TAG_NEW_PID_EXT
408
+ creation = data[i,4]
409
+ i += 4
410
+ elsif tag == TAG_PID_EXT
411
+ creation = data[i]
412
+ i += 1
413
+ end
378
414
  return [i, OtpErlangPid.new(node, id, serial, creation)]
379
415
  elsif tag == TAG_SMALL_TUPLE_EXT or tag == TAG_LARGE_TUPLE_EXT
380
416
  if tag == TAG_SMALL_TUPLE_EXT
@@ -446,13 +482,18 @@ module Erlang
446
482
  #arity = data[i].ord
447
483
  i += 1
448
484
  return [i, OtpErlangFunction.new(tag, data[old_i,i - old_i])]
449
- elsif tag == TAG_NEW_REFERENCE_EXT
485
+ elsif tag == TAG_NEWER_REFERENCE_EXT or tag == TAG_NEW_REFERENCE_EXT
450
486
  j = data[i,2].unpack('n')[0] * 4
451
487
  i += 2
452
488
  result = binary_to_atom(i, data)
453
489
  i = result[0]; node = result[1]
454
- creation = data[i]
455
- i += 1
490
+ if tag == TAG_NEWER_REFERENCE_EXT
491
+ creation = data[i,4]
492
+ i += 4
493
+ elsif tag == TAG_NEW_REFERENCE_EXT
494
+ creation = data[i]
495
+ i += 1
496
+ end
456
497
  id = data[i,j]
457
498
  return [i + j, OtpErlangReference.new(node, id, creation)]
458
499
  elsif tag == TAG_SMALL_ATOM_EXT
@@ -570,7 +611,17 @@ module Erlang
570
611
  def self.binary_to_pid(i, data)
571
612
  tag = data[i].ord
572
613
  i += 1
573
- if tag == TAG_PID_EXT
614
+ if tag == TAG_NEW_PID_EXT
615
+ result = binary_to_atom(i, data)
616
+ i = result[0]; node = result[1]
617
+ id = data[i,4]
618
+ i += 4
619
+ serial = data[i,4]
620
+ i += 4
621
+ creation = data[i,4]
622
+ i += 4
623
+ return [i, OtpErlangPid.new(node, id, serial, creation)]
624
+ elsif tag == TAG_PID_EXT
574
625
  result = binary_to_atom(i, data)
575
626
  i = result[0]; node = result[1]
576
627
  id = data[i,4]
@@ -776,6 +827,9 @@ module Erlang
776
827
  TAG_NEW_FLOAT_EXT = 70
777
828
  TAG_BIT_BINARY_EXT = 77
778
829
  TAG_ATOM_CACHE_REF = 78
830
+ TAG_NEW_PID_EXT = 88
831
+ TAG_NEW_PORT_EXT = 89
832
+ TAG_NEWER_REFERENCE_EXT = 90
779
833
  TAG_SMALL_INTEGER_EXT = 97
780
834
  TAG_INTEGER_EXT = 98
781
835
  TAG_FLOAT_EXT = 99
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # MIT License
6
6
  #
7
- # Copyright (c) 2014-2018 Michael Truog <mjtruog at protonmail dot com>
7
+ # Copyright (c) 2014-2019 Michael Truog <mjtruog at protonmail dot com>
8
8
  # Copyright (c) 2009-2013 Dmitry Vasiliev <dima@hlabs.org>
9
9
  #
10
10
  # Permission is hereby granted, free of charge, to any person obtaining a
@@ -331,6 +331,67 @@ class DecodeTestCase < Test::Unit::TestCase
331
331
  assert_equal(-6618611909121,
332
332
  Erlang::binary_to_term("\x83o\0\0\0\6\1\1\2\3\4\5\6"))
333
333
  end
334
+ def test_binary_to_term_pid
335
+ pid_old_binary = (
336
+ "\x83\x67\x64\x00\x0D\x6E\x6F\x6E\x6F\x64\x65\x40\x6E\x6F" \
337
+ "\x68\x6F\x73\x74\x00\x00\x00\x4E\x00\x00\x00\x00\x00"
338
+ )
339
+ pid_old = Erlang::binary_to_term(pid_old_binary)
340
+ assert(pid_old.kind_of?(Erlang::OtpErlangPid))
341
+ assert_equal(Erlang::term_to_binary(pid_old),
342
+ "\x83gs\rnonode@nohost\x00\x00\x00N" \
343
+ "\x00\x00\x00\x00\x00")
344
+ pid_new_binary = (
345
+ "\x83\x58\x64\x00\x0D\x6E\x6F\x6E\x6F\x64\x65\x40\x6E\x6F\x68" \
346
+ "\x6F\x73\x74\x00\x00\x00\x4E\x00\x00\x00\x00\x00\x00\x00\x00"
347
+ )
348
+ pid_new = Erlang::binary_to_term(pid_new_binary)
349
+ assert(pid_new.kind_of?(Erlang::OtpErlangPid))
350
+ assert_equal(Erlang::term_to_binary(pid_new),
351
+ "\x83Xs\rnonode@nohost\x00\x00\x00N" \
352
+ "\x00\x00\x00\x00\x00\x00\x00\x00")
353
+ end
354
+ def test_binary_to_term_port
355
+ port_old_binary = (
356
+ "\x83\x66\x64\x00\x0D\x6E\x6F\x6E\x6F\x64\x65\x40\x6E\x6F\x68" \
357
+ "\x6F\x73\x74\x00\x00\x00\x06\x00"
358
+ )
359
+ port_old = Erlang::binary_to_term(port_old_binary)
360
+ assert(port_old.kind_of?(Erlang::OtpErlangPort))
361
+ assert_equal(Erlang::term_to_binary(port_old),
362
+ "\x83fs\rnonode@nohost\x00\x00\x00\x06\x00")
363
+ port_new_binary = (
364
+ "\x83\x59\x64\x00\x0D\x6E\x6F\x6E\x6F\x64\x65\x40\x6E\x6F\x68" \
365
+ "\x6F\x73\x74\x00\x00\x00\x06\x00\x00\x00\x00"
366
+ )
367
+ port_new = Erlang::binary_to_term(port_new_binary)
368
+ assert(port_new.kind_of?(Erlang::OtpErlangPort))
369
+ assert_equal(Erlang::term_to_binary(port_new),
370
+ "\x83Ys\rnonode@nohost\x00\x00\x00\x06" \
371
+ "\x00\x00\x00\x00")
372
+ end
373
+ def test_binary_to_term_ref
374
+ ref_new_binary = (
375
+ "\x83\x72\x00\x03\x64\x00\x0D\x6E\x6F\x6E\x6F\x64\x65\x40\x6E" \
376
+ "\x6F\x68\x6F\x73\x74\x00\x00\x03\xE8\x4E\xE7\x68\x00\x02\xA4" \
377
+ "\xC8\x53\x40"
378
+ )
379
+ ref_new = Erlang::binary_to_term(ref_new_binary)
380
+ assert(ref_new.kind_of?(Erlang::OtpErlangReference))
381
+ assert_equal(Erlang::term_to_binary(ref_new),
382
+ "\x83r\x00\x03s\rnonode@nohost\x00\x00\x03\xe8" \
383
+ "N\xe7h\x00\x02\xa4\xc8S@")
384
+ ref_newer_binary = (
385
+ "\x83\x5A\x00\x03\x64\x00\x0D\x6E\x6F\x6E\x6F\x64\x65\x40\x6E" \
386
+ "\x6F\x68\x6F\x73\x74\x00\x00\x00\x00\x00\x01\xAC\x03\xC7\x00" \
387
+ "\x00\x04\xBB\xB2\xCA\xEE"
388
+ )
389
+ ref_newer = Erlang::binary_to_term(ref_newer_binary)
390
+ assert(ref_newer.kind_of?(Erlang::OtpErlangReference))
391
+ assert_equal(Erlang::term_to_binary(ref_newer),
392
+ "\x83Z\x00\x03s\rnonode@nohost\x00\x00\x00\x00\x00" \
393
+ "\x01\xac\x03\xc7\x00\x00\x04\xbb\xb2\xca\xee")
394
+ end
334
395
  def test_binary_to_term_compressed_term
335
396
  assert_raise(Erlang::ParseException){
336
397
  Erlang::binary_to_term("\x83P")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erlang_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.5
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Truog
@@ -12,25 +12,25 @@ cert_chain:
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRAwDgYDVQQDDAdtanRy
14
14
  dW9nMRowGAYKCZImiZPyLGQBGRYKcHJvdG9ubWFpbDETMBEGCgmSJomT8ixkARkW
15
- A2NvbTAeFw0xODA5MTYwNjU2MTJaFw0xOTA5MTYwNjU2MTJaMEMxEDAOBgNVBAMM
15
+ A2NvbTAeFw0xOTExMjkwMjM1MzJaFw0yMDExMjgwMjM1MzJaMEMxEDAOBgNVBAMM
16
16
  B21qdHJ1b2cxGjAYBgoJkiaJk/IsZAEZFgpwcm90b25tYWlsMRMwEQYKCZImiZPy
17
- LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+GXgkcMc
18
- t35WqRkNgmolpYtITHDVIDt6uRkY8g4YiI6SlYiyZiP4rrsPNn9sulTT6ZEwXhAu
19
- OIARkWXUw6i6j1WcIGPbqOTvjNW536K2O37lqyWyH1LMEpIB9F7IzEEklkqJLKma
20
- /0flBlrg0JcTATCNBHBA4nA5aavCToA66pDZvKhf2aE4RaXZ51e/XAGp8GD3bI/T
21
- JgEynOPwKrLPsZ292/NSiP3djEG2ysW0zQMBbsn8ARzh8rY140iIQrpG51ew6Vf9
22
- tk2zKgXbJVdohfsrHW14iQwCNwX7Sm4QEw7FrNkKW2Usqk2btv8AR1qmBDOY8Q3w
23
- sTxnkypn9bICfQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
24
- HQ4EFgQUamLQcH0m/CIPCBzBBk93E2bwepswIQYDVR0RBBowGIEWbWp0cnVvZ0Bw
17
+ LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5Ar67eHx
18
+ R/cmFgsj58SkbsqEQWZOQ5GNO25IKuwjGHqznJXszXM1NW0YFLjgXjsX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XZLkjxhw67N7QPDxsCEa+jiHaWd
29
+ i+DxiISAPKf9ugw5kej0v2j15juXiK5pwKIDDGAFfv3WAFbJXleLoqdM87rbC/vq
30
+ KH+3FIhF8jYeRqq/8g4k6zsZZwRewPjObe3Wm4yEv0f0dxdQRuWcuE7s7z0Bss5J
31
+ YQYB6UQUREuP9rhSHKbAZd9CPR3XW+S7PkeQiWc8ceLFVsfK
32
32
  -----END CERTIFICATE-----
33
- date: 2018-12-18 00:00:00.000000000 Z
33
+ date: 2019-11-28 00:00:00.000000000 Z
34
34
  dependencies: []
35
35
  description: Erlang Binary Term Format for Ruby
36
36
  email: mjtruog@protonmail.com
metadata.gz.sig CHANGED
Binary file