ffi-rzmq-core 1.0.4 → 1.0.5

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: 86300669439c93ba578f5881c11424212c0bf4c3
4
- data.tar.gz: b1fcf73bc95b550ba24a31526bbb73ebbcbf904b
3
+ metadata.gz: 98e134276e0884d8a3f29f6101865d65342610c2
4
+ data.tar.gz: 675f38dd32ae51a1eab313d9c280b1e6e0235773
5
5
  SHA512:
6
- metadata.gz: 79d942c1e43d2d400c3df06bcc7b63f8016b36d736f936216b564dc6e66b9086c29483ebd474630776722004ac032aeea32d617f7e2c1025170dadd3f272de0d
7
- data.tar.gz: 7747c57e3458664a3801aa55d09abbf61de1e0904316cb6b069eb29206bc4ce874a6853ce92c21a33cd295631fccd0119dc97ad141aab144467c60c7c4606226
6
+ metadata.gz: 863dfbb8ecf92defec732741ffd09965354a5f7db1c21bd7e5ff10aad9db10881598714b56ce1c27383b375a2ca3c05ba018c643a0072ab7b80600627d0aa86a
7
+ data.tar.gz: 7d30013ba89544d3e7276fd998923b89fc4bb33c67830c62266068537957a81520ddc35febd9e9b01774ec3cdc89ab76e6ed93b838561f27bd69515064832bdb
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_runtime_dependency "ffi", ["~> 1.9"]
23
- s.add_development_dependency "rspec", ["~> 2.14"]
22
+ s.add_runtime_dependency "ffi"
23
+ s.add_development_dependency "rspec"
24
24
  s.add_development_dependency "rake"
25
25
  end
@@ -1,4 +1,5 @@
1
1
  require 'open3'
2
+ require 'rbconfig'
2
3
 
3
4
  # Wraps the libzmq library and attaches to the functions that are
4
5
  # common across the 3.2.x+ and 4.x APIs.
@@ -11,6 +12,8 @@ module LibZMQ
11
12
  # to the usual system paths
12
13
  inside_gem = File.join(File.dirname(__FILE__), '..', '..', 'ext')
13
14
  local_path = FFI::Platform::IS_WINDOWS ? ENV['PATH'].split(';') : ENV['PATH'].split(':')
15
+ env_path = [ ENV['ZMQ_LIB_PATH'] ].compact
16
+ rbconfig_path = RbConfig::CONFIG["libdir"]
14
17
  homebrew_path = nil
15
18
 
16
19
  # RUBYOPT set by RVM breaks 'brew' so we need to unset it.
@@ -31,7 +34,7 @@ module LibZMQ
31
34
  ENV['RUBYOPT'] = rubyopt
32
35
 
33
36
  # Search for libzmq in the following order...
34
- ZMQ_LIB_PATHS = ([inside_gem] + local_path + [
37
+ ZMQ_LIB_PATHS = ([inside_gem] + env_path + local_path + [rbconfig_path] + [
35
38
  '/usr/local/lib', '/opt/local/lib', homebrew_path, '/usr/lib64'
36
39
  ]).compact.map{|path| "#{path}/libzmq.#{FFI::Platform::LIBSUFFIX}"}
37
40
  ffi_lib(ZMQ_LIB_PATHS + %w{libzmq})
@@ -1,23 +1,51 @@
1
1
  module LibZMQ
2
2
 
3
- # Used for casting pointers back to the msg_t struct
4
- #
5
- class Message < FFI::Struct
6
- layout :content, :pointer,
7
- :flags, :uint8,
8
- :vsm_size, :uint8,
9
- :vsm_data, [:uint8, 30]
3
+ def self.version_number
4
+ 10000 * version[:major] + 100 * version[:minor] + version[:patch]
5
+ end
6
+
7
+ def self.version_string
8
+ "%d.%d.%d" % version.values_at(:major, :minor, :patch)
10
9
  end
11
-
12
- if LibZMQ.version[:major] >= 4 && LibZMQ.version[:minor] > 0
13
-
14
- # zmq_msg_t was expanded to 64 bytes as of version 4.1.0
15
- class Message < FFI::Struct
16
- layout :content, :ulong_long
10
+
11
+ raise "zmq library version not supported: #{version_string}" if version_number < 030200
12
+
13
+ # here are the typedefs for zmsg_msg_t for all known releases of libzmq
14
+ # grep 'typedef struct zmq_msg_t' */include/zmq.h
15
+ # zeromq-3.2.2/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
16
+ # zeromq-3.2.3/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
17
+ # zeromq-3.2.4/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
18
+ # zeromq-3.2.5/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
19
+ # zeromq-4.0.0/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
20
+ # zeromq-4.0.1/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
21
+ # zeromq-4.0.2/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
22
+ # zeromq-4.0.3/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
23
+ # zeromq-4.0.4/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
24
+ # zeromq-4.0.5/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
25
+ # zeromq-4.0.6/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
26
+ # zeromq-4.0.7/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
27
+ # zeromq-4.1.0/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [48];} zmq_msg_t;
28
+ # zeromq-4.1.1/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [64];} zmq_msg_t;
29
+ # zeromq-4.1.2/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [64];} zmq_msg_t;
30
+ # zeromq-4.1.3/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [64];} zmq_msg_t;
31
+ # zeromq-4.1.4/include/zmq.h:typedef struct zmq_msg_t {unsigned char _ [64];} zmq_msg_t;
32
+ # libzmq/include/zmq.h: typedef union zmq_msg_t {unsigned char _ [64]; void *p; } zmq_msg_t;
33
+
34
+ def self.size_of_zmq_msg_t
35
+ if version_number < 040100
36
+ 32
37
+ elsif version_number < 040101
38
+ 48
39
+ else
40
+ 64
17
41
  end
18
-
19
42
  end
20
43
 
44
+ # Declare Message with correct size and alignment
45
+ class Message < FFI::Union
46
+ layout :'_', [:uint8, LibZMQ.size_of_zmq_msg_t],
47
+ :p, :pointer
48
+ end
21
49
 
22
50
  # Create the basic mapping for the poll_item_t structure so we can
23
51
  # access those fields via Ruby.
@@ -1,3 +1,3 @@
1
1
  module LibZMQ
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,6 @@ require File.expand_path(
2
2
  File.join(File.dirname(__FILE__), %w[.. lib ffi-rzmq-core]))
3
3
 
4
4
  require 'rspec'
5
- require 'rspec/autorun'
6
5
 
7
6
  Dir[File.join(File.dirname(__FILE__), "support", "*.rb")].each do |support|
8
7
  require support
@@ -2,23 +2,24 @@ require 'spec_helper'
2
2
 
3
3
  describe LibZMQ do
4
4
 
5
- if LibZMQ.version4? && LibZMQ.version[:minor] > 0
5
+ if LibZMQ.version_number >= 040101
6
6
 
7
7
  it "the msg_t struct wrapped in Message is 64 bytes" do
8
8
  LibZMQ::Message.size == 64
9
9
  end
10
-
11
- else
12
-
13
- it "wraps the msg_t struct as Message" do
14
- message = LibZMQ::Message.new
15
-
16
- expect(message[:content]).to_not be_nil
17
- expect(message[:flags]).to_not be_nil
18
- expect(message[:vsm_size]).to_not be_nil
19
- expect(message[:vsm_data]).to_not be_nil
10
+
11
+ elsif LibZMQ.version_number < 040100
12
+
13
+ it "the msg_t struct wrapped in Message is 32 bytes" do
14
+ LibZMQ::Message.size == 32
15
+ end
16
+
17
+ elsif LibZMQ.version_number == 040100
18
+
19
+ it "the msg_t struct wrapped in Message is 48 bytes" do
20
+ LibZMQ::Message.size == 32
20
21
  end
21
-
22
+
22
23
  end
23
24
 
24
25
  it "wraps poll_item_t in a PollItem" do
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-rzmq-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chuck Remes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-28 00:00:00.000000000 Z
11
+ date: 2016-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.9'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.9'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '2.14'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '2.14'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement