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 +4 -4
- data/ffi-rzmq-core.gemspec +2 -2
- data/lib/ffi-rzmq-core/libzmq.rb +4 -1
- data/lib/ffi-rzmq-core/structures.rb +42 -14
- data/lib/ffi-rzmq-core/version.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/structures_spec.rb +13 -12
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98e134276e0884d8a3f29f6101865d65342610c2
|
4
|
+
data.tar.gz: 675f38dd32ae51a1eab313d9c280b1e6e0235773
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 863dfbb8ecf92defec732741ffd09965354a5f7db1c21bd7e5ff10aad9db10881598714b56ce1c27383b375a2ca3c05ba018c643a0072ab7b80600627d0aa86a
|
7
|
+
data.tar.gz: 7d30013ba89544d3e7276fd998923b89fc4bb33c67830c62266068537957a81520ddc35febd9e9b01774ec3cdc89ab76e6ed93b838561f27bd69515064832bdb
|
data/ffi-rzmq-core.gemspec
CHANGED
@@ -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"
|
23
|
-
s.add_development_dependency "rspec"
|
22
|
+
s.add_runtime_dependency "ffi"
|
23
|
+
s.add_development_dependency "rspec"
|
24
24
|
s.add_development_dependency "rake"
|
25
25
|
end
|
data/lib/ffi-rzmq-core/libzmq.rb
CHANGED
@@ -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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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.
|
data/spec/spec_helper.rb
CHANGED
data/spec/structures_spec.rb
CHANGED
@@ -2,23 +2,24 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe LibZMQ do
|
4
4
|
|
5
|
-
if LibZMQ.
|
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
|
-
|
12
|
-
|
13
|
-
it "
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
+
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:
|
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: '
|
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: '
|
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: '
|
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: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|