czmq-ffi-gen 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +6 -0
- data/LICENSE +1 -1
- data/README.md +38 -25
- data/lib/czmq-ffi-gen/czmq/ffi/zactor.rb +1 -1
- data/lib/czmq-ffi-gen/czmq/ffi/zarmour.rb +1 -1
- data/lib/czmq-ffi-gen/czmq/ffi/zcert.rb +1 -1
- data/lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb +1 -1
- data/lib/czmq-ffi-gen/czmq/ffi/zchunk.rb +1 -1
- data/lib/czmq-ffi-gen/czmq/ffi/zclock.rb +140 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zdigest.rb +156 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zhash.rb +2 -4
- data/lib/czmq-ffi-gen/czmq/ffi/zhashx.rb +4 -2
- data/lib/czmq-ffi-gen/czmq/ffi/zlistx.rb +429 -0
- data/lib/czmq-ffi-gen/czmq/ffi.rb +449 -48
- data/lib/czmq-ffi-gen/gem_version.rb +1 -1
- data/lib/czmq-ffi-gen/legacy.rb +16 -0
- data/lib/czmq-ffi-gen.rb +1 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e7ea1498763380b45d14e2f37c8ca736ff24921
|
4
|
+
data.tar.gz: 30cb33214dc70fa3694bd58abbca662da97ca055
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b97a31986a2c80ee13ad7220ea965e457c94a814b39a763b50e4743787fe3bbc9b5455cf1a9abf4968afffea10fa5b8e5aeeb63d1d0e5a05e49d6e551470601
|
7
|
+
data.tar.gz: c6c557a7bf8038ed758b75832d64f0c5ed852e0d3ea5c6e50f5cebe6650c5b8e071d209345895f05e13ed66c217a2097af106f71ea321fdd9bd1261353645e2c
|
data/CHANGES.md
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -23,51 +23,64 @@ The actual generated code lies in CZMQ, which is Git submodule of this
|
|
23
23
|
repository, registered under `vendor/czmq`.
|
24
24
|
|
25
25
|
So if you're not happy with any of the generated code, go have a closer look at
|
26
|
-
CZMQ or
|
26
|
+
[CZMQ](https://github.com/zeromq/czmq) (or
|
27
|
+
[zproject](https://github.com/zeromq/zproject), which is used by CZMQ to
|
28
|
+
generate the low-level binding).
|
27
29
|
|
28
30
|
### API Documentation
|
29
31
|
For that same reason, API documentation of unreleased code (directly off this
|
30
32
|
repository), like
|
31
33
|
[rubydoc.info/github/paddor/czmq-ffi-gen](http://www.rubydoc.info/github/paddor/czmq-ffi-gen)
|
32
34
|
**does NOT include any of the generated code**. _Rubydoc.info_ doesn't check
|
33
|
-
out Git submodules as part of its documentation procedure.
|
34
|
-
documentation of the **released gem should work** just fine, as the gem release
|
35
|
-
process will include all required source files directly within the gem.
|
36
|
-
|
37
|
-
**Check out**
|
38
|
-
[http://www.rubydoc.info/gems/czmq-ffi-gen](http://www.rubydoc.info/gems/czmq-ffi-gen)
|
39
|
-
for the API documentation.
|
40
|
-
|
41
|
-
## Supported Rubies
|
42
|
-
|
43
|
-
Tested on CI with these:
|
44
|
-
|
45
|
-
* Ruby 2.2.4
|
46
|
-
* JRuby HEAD (>= 9.0.0.0)
|
47
|
-
* Rubinius
|
35
|
+
out Git submodules as part of its documentation procedure.
|
48
36
|
|
37
|
+
However, the API documentation of the **released** gem should include all the
|
38
|
+
code, as the gem release process will include all required source files
|
39
|
+
directly within the gem.
|
49
40
|
|
50
|
-
|
41
|
+
Check out
|
42
|
+
[http://www.rubydoc.info/gems/czmq-ffi-gen](http://www.rubydoc.info/gems/czmq-ffi-gen)
|
43
|
+
for the API documentation **for the released gem**.
|
51
44
|
|
52
|
-
|
53
|
-
* doesn't work because of the use of the double splat operator (`**opts`)
|
45
|
+
## Requirements
|
54
46
|
|
55
|
-
|
47
|
+
* CZMQ >= 3.0
|
48
|
+
* ZMQ >= 4.0
|
56
49
|
|
57
|
-
|
58
|
-
|
59
|
-
[libsodium](https://github.com/jedisct1/libsodium) and at least ZMQ 4.0.
|
50
|
+
For security mechanisms like CURVE, you'll need:
|
51
|
+
* [libsodium](https://github.com/jedisct1/libsodium)<Paste>
|
60
52
|
|
61
53
|
On OSX using homebrew, run:
|
62
54
|
|
63
55
|
$ brew install libsodium
|
64
56
|
$ brew install zmq --with-libsodium
|
65
|
-
$ brew install czmq
|
57
|
+
$ brew install czmq --HEAD
|
66
58
|
|
67
59
|
If you're running Linux, go check [this page](http://zeromq.org/distro:_start)
|
68
60
|
to get more help. Make sure to install CZMQ, not only ZMQ.
|
69
61
|
|
70
|
-
|
62
|
+
**Note**: The option `--HEAD` is recommended because this binding is generated
|
63
|
+
directly from CZMQ's master branch. However, it's not required.
|
64
|
+
|
65
|
+
### Supported Rubies
|
66
|
+
|
67
|
+
See [.travis.yml](https://github.com/paddor/czmq-ffi-gen/blob/master/.travis.yml)
|
68
|
+
for a list of Ruby versions against which czmq-ffi-gen is tested.
|
69
|
+
|
70
|
+
At the time of writing, these include:
|
71
|
+
|
72
|
+
* MRI 2.3, 2.2.4, 2.1.8
|
73
|
+
* Rubinius (HEAD)
|
74
|
+
* JRuby 9000 (HEAD)
|
75
|
+
|
76
|
+
#### Known NOT to work
|
77
|
+
|
78
|
+
* JRuby 1.7.x and MRI < 2.0
|
79
|
+
* doesn't work because of the use of the double splat operator (`**opts`)
|
80
|
+
|
81
|
+
## Installation
|
82
|
+
|
83
|
+
To use this gem, add this line to your application's Gemfile:
|
71
84
|
|
72
85
|
```ruby
|
73
86
|
gem 'czmq-ffi-gen'
|
@@ -6,7 +6,7 @@
|
|
6
6
|
module CZMQ
|
7
7
|
module FFI
|
8
8
|
|
9
|
-
#
|
9
|
+
# work with CURVE security certificate stores
|
10
10
|
# @note This class is 100% generated using zproject.
|
11
11
|
class Zcertstore
|
12
12
|
# Raised when one tries to use an instance of {Zcertstore} after
|
@@ -0,0 +1,140 @@
|
|
1
|
+
################################################################################
|
2
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
3
|
+
# Please refer to the README for information about making permanent changes. #
|
4
|
+
################################################################################
|
5
|
+
|
6
|
+
module CZMQ
|
7
|
+
module FFI
|
8
|
+
|
9
|
+
# millisecond clocks and delays
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Zclock
|
12
|
+
# Raised when one tries to use an instance of {Zclock} after
|
13
|
+
# the internal pointer to the native object has been nullified.
|
14
|
+
class DestroyedError < RuntimeError; end
|
15
|
+
|
16
|
+
# Boilerplate for self pointer, initializer, and finalizer
|
17
|
+
class << self
|
18
|
+
alias :__new :new
|
19
|
+
end
|
20
|
+
# Attaches the pointer _ptr_ to this instance and defines a finalizer for
|
21
|
+
# it if necessary.
|
22
|
+
# @param ptr [::FFI::Pointer]
|
23
|
+
# @param finalize [Boolean]
|
24
|
+
def initialize(ptr, finalize = true)
|
25
|
+
@ptr = ptr
|
26
|
+
if @ptr.null?
|
27
|
+
@ptr = nil # Remove null pointers so we don't have to test for them.
|
28
|
+
elsif finalize
|
29
|
+
@finalizer = self.class.create_finalizer_for @ptr
|
30
|
+
ObjectSpace.define_finalizer self, @finalizer
|
31
|
+
end
|
32
|
+
end
|
33
|
+
# @return [Proc]
|
34
|
+
def self.create_finalizer_for(ptr)
|
35
|
+
Proc.new do
|
36
|
+
"WARNING: "\
|
37
|
+
"Objects of type #{self} cannot be destroyed implicitly. "\
|
38
|
+
"Please call the correct destroy method with the relevant arguments."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
# @return [Boolean]
|
42
|
+
def null?
|
43
|
+
!@ptr or @ptr.null?
|
44
|
+
end
|
45
|
+
# Return internal pointer
|
46
|
+
# @return [::FFI::Pointer]
|
47
|
+
def __ptr
|
48
|
+
raise DestroyedError unless @ptr
|
49
|
+
@ptr
|
50
|
+
end
|
51
|
+
# So external Libraries can just pass the Object to a FFI function which expects a :pointer
|
52
|
+
alias_method :to_ptr, :__ptr
|
53
|
+
# Nullify internal pointer and return pointer pointer.
|
54
|
+
# @note This detaches the current instance from the native object
|
55
|
+
# and thus makes it unusable.
|
56
|
+
# @return [::FFI::MemoryPointer] the pointer pointing to a pointer
|
57
|
+
# pointing to the native object
|
58
|
+
def __ptr_give_ref
|
59
|
+
raise DestroyedError unless @ptr
|
60
|
+
ptr_ptr = ::FFI::MemoryPointer.new :pointer
|
61
|
+
ptr_ptr.write_pointer @ptr
|
62
|
+
__undef_finalizer if @finalizer
|
63
|
+
@ptr = nil
|
64
|
+
ptr_ptr
|
65
|
+
end
|
66
|
+
# Undefines the finalizer for this object.
|
67
|
+
# @note Only use this if you need to and can guarantee that the native
|
68
|
+
# object will be freed by other means.
|
69
|
+
# @return [void]
|
70
|
+
def __undef_finalizer
|
71
|
+
ObjectSpace.undefine_finalizer self
|
72
|
+
@finalizer = nil
|
73
|
+
end
|
74
|
+
|
75
|
+
# Sleep for a number of milliseconds
|
76
|
+
#
|
77
|
+
# @param msecs [Integer, #to_int, #to_i]
|
78
|
+
# @return [void]
|
79
|
+
def self.sleep(msecs)
|
80
|
+
msecs = Integer(msecs)
|
81
|
+
result = ::CZMQ::FFI.zclock_sleep(msecs)
|
82
|
+
result
|
83
|
+
end
|
84
|
+
|
85
|
+
# Return current system clock as milliseconds. Note that this clock can
|
86
|
+
# jump backwards (if the system clock is changed) so is unsafe to use for
|
87
|
+
# timers and time offsets. Use zclock_mono for that instead.
|
88
|
+
#
|
89
|
+
# @return [::FFI::Pointer]
|
90
|
+
def self.time()
|
91
|
+
result = ::CZMQ::FFI.zclock_time()
|
92
|
+
result
|
93
|
+
end
|
94
|
+
|
95
|
+
# Return current monotonic clock in milliseconds. Use this when you compute
|
96
|
+
# time offsets. The monotonic clock is not affected by system changes and
|
97
|
+
# so will never be reset backwards, unlike a system clock.
|
98
|
+
#
|
99
|
+
# @return [::FFI::Pointer]
|
100
|
+
def self.mono()
|
101
|
+
result = ::CZMQ::FFI.zclock_mono()
|
102
|
+
result
|
103
|
+
end
|
104
|
+
|
105
|
+
# Return current monotonic clock in microseconds. Use this when you compute
|
106
|
+
# time offsets. The monotonic clock is not affected by system changes and
|
107
|
+
# so will never be reset backwards, unlike a system clock.
|
108
|
+
#
|
109
|
+
# @return [::FFI::Pointer]
|
110
|
+
def self.usecs()
|
111
|
+
result = ::CZMQ::FFI.zclock_usecs()
|
112
|
+
result
|
113
|
+
end
|
114
|
+
|
115
|
+
# Return formatted date/time as fresh string. Free using zstr_free().
|
116
|
+
#
|
117
|
+
# @return [::FFI::AutoPointer]
|
118
|
+
def self.timestr()
|
119
|
+
result = ::CZMQ::FFI.zclock_timestr()
|
120
|
+
result = ::FFI::AutoPointer.new(result, LibC.method(:free))
|
121
|
+
result
|
122
|
+
end
|
123
|
+
|
124
|
+
# Self test of this class.
|
125
|
+
#
|
126
|
+
# @param verbose [Boolean]
|
127
|
+
# @return [void]
|
128
|
+
def self.test(verbose)
|
129
|
+
verbose = !(0==verbose||!verbose) # boolean
|
130
|
+
result = ::CZMQ::FFI.zclock_test(verbose)
|
131
|
+
result
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
################################################################################
|
138
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
139
|
+
# Please refer to the README for information about making permanent changes. #
|
140
|
+
################################################################################
|
@@ -0,0 +1,156 @@
|
|
1
|
+
################################################################################
|
2
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
3
|
+
# Please refer to the README for information about making permanent changes. #
|
4
|
+
################################################################################
|
5
|
+
|
6
|
+
module CZMQ
|
7
|
+
module FFI
|
8
|
+
|
9
|
+
# zdigest - provides hashing functions (SHA-1 at present)
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Zdigest
|
12
|
+
# Raised when one tries to use an instance of {Zdigest} after
|
13
|
+
# the internal pointer to the native object has been nullified.
|
14
|
+
class DestroyedError < RuntimeError; end
|
15
|
+
|
16
|
+
# Boilerplate for self pointer, initializer, and finalizer
|
17
|
+
class << self
|
18
|
+
alias :__new :new
|
19
|
+
end
|
20
|
+
# Attaches the pointer _ptr_ to this instance and defines a finalizer for
|
21
|
+
# it if necessary.
|
22
|
+
# @param ptr [::FFI::Pointer]
|
23
|
+
# @param finalize [Boolean]
|
24
|
+
def initialize(ptr, finalize = true)
|
25
|
+
@ptr = ptr
|
26
|
+
if @ptr.null?
|
27
|
+
@ptr = nil # Remove null pointers so we don't have to test for them.
|
28
|
+
elsif finalize
|
29
|
+
@finalizer = self.class.create_finalizer_for @ptr
|
30
|
+
ObjectSpace.define_finalizer self, @finalizer
|
31
|
+
end
|
32
|
+
end
|
33
|
+
# @param ptr [::FFI::Pointer]
|
34
|
+
# @return [Proc]
|
35
|
+
def self.create_finalizer_for(ptr)
|
36
|
+
Proc.new do
|
37
|
+
ptr_ptr = ::FFI::MemoryPointer.new :pointer
|
38
|
+
ptr_ptr.write_pointer ptr
|
39
|
+
::CZMQ::FFI.zdigest_destroy ptr_ptr
|
40
|
+
end
|
41
|
+
end
|
42
|
+
# @return [Boolean]
|
43
|
+
def null?
|
44
|
+
!@ptr or @ptr.null?
|
45
|
+
end
|
46
|
+
# Return internal pointer
|
47
|
+
# @return [::FFI::Pointer]
|
48
|
+
def __ptr
|
49
|
+
raise DestroyedError unless @ptr
|
50
|
+
@ptr
|
51
|
+
end
|
52
|
+
# So external Libraries can just pass the Object to a FFI function which expects a :pointer
|
53
|
+
alias_method :to_ptr, :__ptr
|
54
|
+
# Nullify internal pointer and return pointer pointer.
|
55
|
+
# @note This detaches the current instance from the native object
|
56
|
+
# and thus makes it unusable.
|
57
|
+
# @return [::FFI::MemoryPointer] the pointer pointing to a pointer
|
58
|
+
# pointing to the native object
|
59
|
+
def __ptr_give_ref
|
60
|
+
raise DestroyedError unless @ptr
|
61
|
+
ptr_ptr = ::FFI::MemoryPointer.new :pointer
|
62
|
+
ptr_ptr.write_pointer @ptr
|
63
|
+
__undef_finalizer if @finalizer
|
64
|
+
@ptr = nil
|
65
|
+
ptr_ptr
|
66
|
+
end
|
67
|
+
# Undefines the finalizer for this object.
|
68
|
+
# @note Only use this if you need to and can guarantee that the native
|
69
|
+
# object will be freed by other means.
|
70
|
+
# @return [void]
|
71
|
+
def __undef_finalizer
|
72
|
+
ObjectSpace.undefine_finalizer self
|
73
|
+
@finalizer = nil
|
74
|
+
end
|
75
|
+
|
76
|
+
# Constructor - creates new digest object, which you use to build up a
|
77
|
+
# digest by repeatedly calling zdigest_update() on chunks of data.
|
78
|
+
# @return [CZMQ::Zdigest]
|
79
|
+
def self.new()
|
80
|
+
ptr = ::CZMQ::FFI.zdigest_new()
|
81
|
+
__new ptr
|
82
|
+
end
|
83
|
+
|
84
|
+
# Destroy a digest object
|
85
|
+
#
|
86
|
+
# @return [void]
|
87
|
+
def destroy()
|
88
|
+
return unless @ptr
|
89
|
+
self_p = __ptr_give_ref
|
90
|
+
result = ::CZMQ::FFI.zdigest_destroy(self_p)
|
91
|
+
result
|
92
|
+
end
|
93
|
+
|
94
|
+
# Add buffer into digest calculation
|
95
|
+
#
|
96
|
+
# @param buffer [::FFI::Pointer, #to_ptr]
|
97
|
+
# @param length [Integer, #to_int, #to_i]
|
98
|
+
# @return [void]
|
99
|
+
def update(buffer, length)
|
100
|
+
raise DestroyedError unless @ptr
|
101
|
+
self_p = @ptr
|
102
|
+
length = Integer(length)
|
103
|
+
result = ::CZMQ::FFI.zdigest_update(self_p, buffer, length)
|
104
|
+
result
|
105
|
+
end
|
106
|
+
|
107
|
+
# Return final digest hash data. If built without crypto support, returns
|
108
|
+
# NULL.
|
109
|
+
#
|
110
|
+
# @return [::FFI::Pointer]
|
111
|
+
def data()
|
112
|
+
raise DestroyedError unless @ptr
|
113
|
+
self_p = @ptr
|
114
|
+
result = ::CZMQ::FFI.zdigest_data(self_p)
|
115
|
+
result
|
116
|
+
end
|
117
|
+
|
118
|
+
# Return final digest hash size
|
119
|
+
#
|
120
|
+
# @return [Integer]
|
121
|
+
def size()
|
122
|
+
raise DestroyedError unless @ptr
|
123
|
+
self_p = @ptr
|
124
|
+
result = ::CZMQ::FFI.zdigest_size(self_p)
|
125
|
+
result
|
126
|
+
end
|
127
|
+
|
128
|
+
# Return digest as printable hex string; caller should not modify nor
|
129
|
+
# free this string. After calling this, you may not use zdigest_update()
|
130
|
+
# on the same digest. If built without crypto support, returns NULL.
|
131
|
+
#
|
132
|
+
# @return [::FFI::Pointer]
|
133
|
+
def string()
|
134
|
+
raise DestroyedError unless @ptr
|
135
|
+
self_p = @ptr
|
136
|
+
result = ::CZMQ::FFI.zdigest_string(self_p)
|
137
|
+
result
|
138
|
+
end
|
139
|
+
|
140
|
+
# Self test of this class.
|
141
|
+
#
|
142
|
+
# @param verbose [Boolean]
|
143
|
+
# @return [void]
|
144
|
+
def self.test(verbose)
|
145
|
+
verbose = !(0==verbose||!verbose) # boolean
|
146
|
+
result = ::CZMQ::FFI.zdigest_test(verbose)
|
147
|
+
result
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
################################################################################
|
154
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
155
|
+
# Please refer to the README for information about making permanent changes. #
|
156
|
+
################################################################################
|
@@ -90,7 +90,7 @@ module CZMQ
|
|
90
90
|
end
|
91
91
|
|
92
92
|
# Create a new callback of the following type:
|
93
|
-
#
|
93
|
+
# Callback function for zhash_foreach method. Deprecated.
|
94
94
|
# typedef int (zhash_foreach_fn) (
|
95
95
|
# const char *key, void *item, void *argument);
|
96
96
|
#
|
@@ -383,11 +383,9 @@ module CZMQ
|
|
383
383
|
result
|
384
384
|
end
|
385
385
|
|
386
|
-
# DEPRECATED as clumsy -- use zhash_first/_next instead
|
387
386
|
# Apply function to each item in the hash table. Items are iterated in no
|
388
387
|
# defined order. Stops if callback function returns non-zero and returns
|
389
|
-
# final return code from callback function (zero = success).
|
390
|
-
# Callback function for zhash_foreach method
|
388
|
+
# final return code from callback function (zero = success). Deprecated.
|
391
389
|
#
|
392
390
|
# @param callback [::FFI::Pointer, #to_ptr]
|
393
391
|
# @param argument [::FFI::Pointer, #to_ptr]
|
@@ -308,11 +308,12 @@ module CZMQ
|
|
308
308
|
# table. Uses the key_duplicator to duplicate all keys and sets the
|
309
309
|
# key_destructor as destructor for the list.
|
310
310
|
#
|
311
|
-
# @return [
|
311
|
+
# @return [Zlistx]
|
312
312
|
def keys()
|
313
313
|
raise DestroyedError unless @ptr
|
314
314
|
self_p = @ptr
|
315
315
|
result = ::CZMQ::FFI.zhashx_keys(self_p)
|
316
|
+
result = Zlistx.__new result, true
|
316
317
|
result
|
317
318
|
end
|
318
319
|
|
@@ -320,11 +321,12 @@ module CZMQ
|
|
320
321
|
# table. Uses the duplicator to duplicate all items and sets the
|
321
322
|
# destructor as destructor for the list.
|
322
323
|
#
|
323
|
-
# @return [
|
324
|
+
# @return [Zlistx]
|
324
325
|
def values()
|
325
326
|
raise DestroyedError unless @ptr
|
326
327
|
self_p = @ptr
|
327
328
|
result = ::CZMQ::FFI.zhashx_values(self_p)
|
329
|
+
result = Zlistx.__new result, true
|
328
330
|
result
|
329
331
|
end
|
330
332
|
|