ffi-czmq 0.1.3.pre → 0.1.4.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31358d0d534fb15604de3071fb55a7b6a5a59412
4
- data.tar.gz: e34e8d89fbf1bd9340eef647f272efef7d196d69
3
+ metadata.gz: 5bf3cc4225ba9ebcea5caf29a0b3448392cbc2b8
4
+ data.tar.gz: c4f922d3df650aabfe3cb6d36b530d682581bb79
5
5
  SHA512:
6
- metadata.gz: 6f11c4f2edd06e534a9950d79e8738d5d96dda9358d6293a737a3dd955ad54036a77083de8ad0da7d59a9d659c1ae5008fc72fe977d415c2c98ce238c87b69e4
7
- data.tar.gz: 37dc0dd23fc3e25425093b92f8be989598fba1f98da09dd3a0791b45e77e35b85138a31c588581c21119d0f43fb448598c29e0b274a998267064af865d65a95d
6
+ metadata.gz: 4e247ff4351a974e62ed4ae7284c3f80fad8a02bbebef9f210357a8188c6e9cfa227538d03aea80892806de80656c7cefbf66f45b0c633fba5665226f1d7e12a
7
+ data.tar.gz: 2fa83c6efcb617db5193969c8d28046446171842da19fcc96f15a6aae8a229ff7970a9b8f024703be9af93cb38e846615d597437088beff5c249b5d1bd834bda
data/lib/czmq/libczmq.rb CHANGED
@@ -183,7 +183,9 @@ module LibCZMQ
183
183
 
184
184
  case #{returns.inspect}
185
185
  when :pointer
186
- !result.null? ||fail(NoMemoryError, CZMQ::Utils.error, caller)
186
+ unless #{czmq_class == :zconfig}
187
+ !result.null? ||fail(NoMemoryError, CZMQ::Utils.error, caller)
188
+ end
187
189
  result
188
190
  when :int
189
191
  case #{function.inspect}
data/lib/czmq/utils.rb CHANGED
@@ -7,22 +7,22 @@ module CZMQ
7
7
 
8
8
  ffi_lib :libzmq, :czmq
9
9
 
10
- attach_function :zmq_version, :zmq_version, [:buffer_out, :buffer_out, :buffer_out], :void, blocking: true
11
- attach_function :zsys_version, :zsys_version, [:buffer_out, :buffer_out, :buffer_out], :void, blocking: true
12
- attach_function :errno, :zmq_errno, [], :int
13
- attach_function :strerror, :zmq_strerror, [:int], :string
10
+ attach_function :zmq_version, :zmq_version, [:buffer_out, :buffer_out, :buffer_out], :void, blocking: true
11
+ attach_function :zsys_version, :zsys_version, [:buffer_out, :buffer_out, :buffer_out], :void, blocking: true
12
+ attach_function :errno, :zmq_errno, [], :int, blocking: true
13
+ attach_function :strerror, :zmq_strerror, [:int], :string, blocking: true
14
14
 
15
15
  module_function
16
16
 
17
17
  def version
18
18
  unless @version
19
- z_major = FFI::MemoryPointer.new :pointer
20
- z_minor = FFI::MemoryPointer.new :pointer
21
- z_patch = FFI::MemoryPointer.new :pointer
19
+ z_major = FFI::MemoryPointer.new :int
20
+ z_minor = FFI::MemoryPointer.new :int
21
+ z_patch = FFI::MemoryPointer.new :int
22
22
 
23
- c_major = FFI::MemoryPointer.new :pointer
24
- c_minor = FFI::MemoryPointer.new :pointer
25
- c_patch = FFI::MemoryPointer.new :pointer
23
+ c_major = FFI::MemoryPointer.new :int
24
+ c_minor = FFI::MemoryPointer.new :int
25
+ c_patch = FFI::MemoryPointer.new :int
26
26
 
27
27
  zmq_version z_major, z_minor, z_patch
28
28
  zsys_version c_major, c_minor, c_patch
@@ -45,11 +45,11 @@ module CZMQ
45
45
  end
46
46
 
47
47
  def bin2hex(bytes)
48
- bytes.to_str.unpack(HEXY).first
48
+ String(bytes).unpack(HEXY).first
49
49
  end
50
50
 
51
51
  def hex2bin(hex)
52
- [hex].pack(HEXY)
52
+ [String(hex)].pack(HEXY)
53
53
  end
54
54
 
55
55
  if version[:czmq][:major] < 3
data/lib/czmq/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CZMQ
2
- VERSION = Gem::Version.new('0.1.3.pre')
2
+ VERSION = Gem::Version.new('0.1.4.pre')
3
3
  end
data/lib/czmq/zconfig.rb CHANGED
@@ -11,16 +11,16 @@ module CZMQ
11
11
  czmq_function :value, :value, [:pointer], :string
12
12
  czmq_function :put, :put, [:pointer, :string, :string], :void
13
13
  czmq_function :set_name, :set_name, [:pointer, :string], :void
14
- czmq_function :set_value, :set_value, [:pointer, :string], :void
14
+ czmq_function :set_value, :set_value, [:pointer, :string, :varargs], :void
15
15
  czmq_function :child_zconfig, :child, [:pointer], :pointer
16
16
  czmq_function :next_zconfig, :next, [:pointer], :pointer
17
17
  czmq_function :locate_zconfig, :locate, [:pointer, :string], :pointer
18
18
  czmq_function :resolve, :resolve, [:pointer, :string, :string], :string
19
19
  czmq_function :zconfig_at_depth, :at_depth, [:pointer, :int], :pointer
20
20
  czmq_function :execute_zconfig, :execute, [:pointer, :pointer, :pointer], :int
21
- czmq_function :set_comment, :set_comment, [:pointer, :string], :void
21
+ czmq_function :set_comment, :set_comment, [:pointer, :string, :varargs], :void
22
22
  czmq_function :load_zconfig, :load, [:string], :pointer
23
- czmq_function :save_zconfig, :save, [:pointer, :string], :int
23
+ czmq_function :save, :save, [:pointer, :string], :int
24
24
  czmq_function :filename, :filename, [:pointer], :string
25
25
  czmq_function :reload, :reload, [:pointer], :int
26
26
  czmq_function :has_changed, :has_changed, [:pointer], :bool
@@ -34,11 +34,15 @@ module CZMQ
34
34
  end
35
35
 
36
36
  def child
37
- self.class.new_from_czmq_obj(child_zconfig, nil)
37
+ unless (child_config = child_zconfig).null?
38
+ self.class.new_from_czmq_obj(child_zconfig, nil)
39
+ end
38
40
  end
39
41
 
40
42
  def next
41
- self.class.new_from_czmq_obj(next_zconfig, nil)
43
+ unless (next_config = next_zconfig).null?
44
+ self.class.new_from_czmq_obj(next_zconfig, nil)
45
+ end
42
46
  end
43
47
 
44
48
  def execute(&block)
@@ -53,16 +57,12 @@ module CZMQ
53
57
  def locate(path)
54
58
  unless (zconfig = locate_zconfig(path)).null?
55
59
  self.class.new_from_czmq_obj(zconfig, nil)
56
- else
57
- fail RuntimeError, Utils.error, caller
58
60
  end
59
61
  end
60
62
 
61
63
  def at_depth(level)
62
64
  unless (zconfig = zconfig_at_depth(level)).null?
63
65
  self.class.new_from_czmq_obj(zconfig, nil)
64
- else
65
- fail RuntimeError, Utils.error, caller
66
66
  end
67
67
  end
68
68
  end
data/lib/czmq/zmsg.rb CHANGED
@@ -30,7 +30,7 @@ module CZMQ
30
30
  czmq_function :next_zframe, :next, [:pointer], :pointer
31
31
  czmq_function :last_zframe, :last, [:pointer], :pointer
32
32
  czmq_function :encode_zmsg, :encode, [:pointer, :buffer_out], :size_t
33
- czmq_function :decode_zmsg, :decode, [:pointer, :size_t], :pointer
33
+ czmq_function :decode_zmsg, :decode, [:buffer_in, :size_t], :pointer
34
34
  czmq_function :dup_zmsg, :dup, [:pointer], :pointer
35
35
  czmq_function :print, :print, [:pointer], :void
36
36
 
data/lib/czmq/zsock.rb CHANGED
@@ -5,23 +5,23 @@ require_relative 'zmsg'
5
5
 
6
6
  module CZMQ
7
7
  class Zsock
8
- SET_SOCKOPT = /^set_(.+)$/.freeze
8
+ SET_SOCKOPT = 'set_'.freeze
9
9
 
10
10
  extend ::LibCZMQ
11
11
 
12
12
  czmq_constructor
13
13
  czmq_destructor
14
14
 
15
- czmq_function :bind, :bind, [:pointer, :string], :int
16
- czmq_function :endpoint, :endpoint, [:pointer], :string
17
- czmq_function :unbind, :unbind, [:pointer, :string], :int
18
- czmq_function :connect, :connect, [:pointer, :string], :int
19
- czmq_function :disconnect, :disconnect,[:pointer, :string], :int
20
- czmq_function :attach, :attach, [:pointer, :string, :bool], :int
21
- czmq_function :type_str, :type_str, [:pointer], :string
22
- czmq_function :signal, :signal, [:pointer, :uchar], :int
23
- czmq_function :wait, :wait, [:pointer], :int
24
- czmq_function :resolve, :resolve, [:pointer], :pointer
15
+ czmq_function :bind, :bind, [:pointer, :string, :varargs], :int
16
+ czmq_function :endpoint, :endpoint, [:pointer], :string
17
+ czmq_function :unbind, :unbind, [:pointer, :string, :varargs], :int
18
+ czmq_function :connect, :connect, [:pointer, :string], :int
19
+ czmq_function :disconnect, :disconnect,[:pointer, :string], :int
20
+ czmq_function :attach, :attach, [:pointer, :string, :bool], :int
21
+ czmq_function :type_str, :type_str, [:pointer], :string
22
+ czmq_function :signal, :signal, [:pointer, :uchar], :int
23
+ czmq_function :wait, :wait, [:pointer], :int
24
+ czmq_function :resolve, :resolve, [:pointer], :pointer
25
25
 
26
26
  def self.convert(czmq_obj)
27
27
  if Utils.check_for_pointer(czmq_obj)
@@ -85,7 +85,7 @@ module CZMQ
85
85
 
86
86
  def method_missing(meth, *args, &blk)
87
87
  if args.length == 1 &&
88
- meth.to_s =~ SET_SOCKOPT &&
88
+ meth.to_s.start_with?(SET_SOCKOPT) &&
89
89
  (args.first.is_a?(Fixnum) || args.first.is_a?(String))
90
90
  begin
91
91
 
data/lib/czmq/zstr.rb CHANGED
@@ -10,7 +10,7 @@ module CZMQ
10
10
  czmq_function :send_zstr, :send, [:pointer, :string], :int
11
11
  czmq_function :sendm, :sendm, [:pointer, :string], :int
12
12
  czmq_function :sendx_zstr, :sendx, [:pointer, :string, :varargs], :int
13
- czmq_function :recvx_zsrt, :recvx, [:pointer, :buffer_out, :varargs], :int
13
+ czmq_function :recvx_zstr, :recvx, [:pointer, :buffer_out, :varargs], :int
14
14
  czmq_function :free, :free, [:pointer], :void
15
15
 
16
16
  class << self
@@ -47,7 +47,7 @@ module CZMQ
47
47
  buffers << FFI::Buffer.new_out(:pointer)
48
48
  end
49
49
 
50
- recvx_zsrt(Zsock.convert(socket), *buffers, :pointer, nil)
50
+ recvx_zstr(Zsock.convert(socket), *buffers, :pointer, nil)
51
51
 
52
52
  strings = []
53
53
  buffers.select {|buffer| buffer != :buffer_out}.each do |buffer|
data/lib/czmq.rb CHANGED
@@ -14,3 +14,4 @@ require_relative 'czmq/ziflist'
14
14
  require_relative 'czmq/zconfig'
15
15
  require_relative 'czmq/zstr'
16
16
  require_relative 'czmq/zclock'
17
+ require_relative 'libzmq'
data/lib/ffi-czmq.rb CHANGED
@@ -14,3 +14,4 @@ require_relative 'czmq/ziflist'
14
14
  require_relative 'czmq/zconfig'
15
15
  require_relative 'czmq/zstr'
16
16
  require_relative 'czmq/zclock'
17
+ require_relative 'libzmq'
data/lib/libzmq.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Libzmq
4
4
  extend FFI::Library
5
- ffi_lib :libzmq, FFI::Library::LIBC
5
+ ffi_lib :libzmq
6
6
 
7
7
  POLLIN = 1
8
8
  POLLOUT = 2
@@ -32,9 +32,15 @@ module Libzmq
32
32
  def error?
33
33
  (self[:revents] & POLLERR) > 0
34
34
  end
35
+
36
+ def priority?
37
+ (self[:revents] & POLLPRI) > 0
38
+ end
35
39
  end
36
40
 
37
- attach_function :poll, :zmq_poll, [:pointer, :int, :long], :int, blocking: true
41
+ attach_function :poll, :zmq_poll, [:pointer, :int, :long], :int, blocking: true
42
+ attach_function :zmq_z85_decode, [:buffer_out, :string], :pointer, blocking: true
43
+ attach_function :zmq_z85_encode, [:buffer_out, :buffer_in, :size_t], :string, blocking: true
38
44
 
39
45
  class PollItems < Array
40
46
  def to_ptr
@@ -47,4 +53,22 @@ module Libzmq
47
53
  items_pointer
48
54
  end
49
55
  end
56
+
57
+ module_function
58
+
59
+ def z85_decode(str)
60
+ if (str.bytesize % 5 == 0)
61
+ buffer = FFI::MemoryPointer.new(:uint8, (str.bytesize * 0.8))
62
+ zmq_z85_decode(buffer, str)
63
+ buffer
64
+ end
65
+ end
66
+
67
+ def z85_encode(data)
68
+ size = data.respond_to?(:bytesize) ? data.bytesize : data.size
69
+ if (size % 4 == 0)
70
+ buffer = FFI::MemoryPointer.new(:char, (size * 1.25) + 1)
71
+ zmq_z85_encode(buffer, data, size)
72
+ end
73
+ end
50
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-czmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3.pre
4
+ version: 0.1.4.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hendrik
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-07 00:00:00.000000000 Z
12
+ date: 2014-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi