czmq-ffi-gen 0.9.2-x64-mingw32
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 +7 -0
- data/AUTHORS +1 -0
- data/CHANGES.md +92 -0
- data/Gemfile +2 -0
- data/LICENSE +14 -0
- data/README.md +112 -0
- data/lib/czmq-ffi-gen.rb +7 -0
- data/lib/czmq-ffi-gen/czmq/ffi.rb +1210 -0
- data/lib/czmq-ffi-gen/czmq/ffi/version.rb +15 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zactor.rb +186 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zarmour.rb +286 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zcert.rb +307 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb +222 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zchunk.rb +388 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zclock.rb +140 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zconfig.rb +442 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zdigest.rb +156 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zdir.rb +283 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zdir_patch.rb +194 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zfile.rb +353 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zframe.rb +359 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zhash.rb +416 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zhashx.rb +659 -0
- data/lib/czmq-ffi-gen/czmq/ffi/ziflist.rb +189 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zlist.rb +365 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zlistx.rb +478 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zloop.rb +396 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zmsg.rb +515 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zpoller.rb +194 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zproc.rb +294 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zsock.rb +3479 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zstr.rb +203 -0
- data/lib/czmq-ffi-gen/czmq/ffi/ztimerset.rb +203 -0
- data/lib/czmq-ffi-gen/czmq/ffi/ztrie.rb +221 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zuuid.rb +227 -0
- data/lib/czmq-ffi-gen/errors.rb +12 -0
- data/lib/czmq-ffi-gen/gem_version.rb +5 -0
- data/lib/czmq-ffi-gen/legacy.rb +16 -0
- data/lib/czmq-ffi-gen/libzmq.rb +18 -0
- data/lib/czmq-ffi-gen/signals.rb +27 -0
- data/lib/czmq-ffi-gen/vendor.rb +5 -0
- data/lib/czmq-ffi-gen/versions.rb +19 -0
- data/vendor/local/bin/inproc_lat.exe +0 -0
- data/vendor/local/bin/inproc_thr.exe +0 -0
- data/vendor/local/bin/libczmq.dll +0 -0
- data/vendor/local/bin/libgcc_s_seh-1.dll +0 -0
- data/vendor/local/bin/libstdc++-6.dll +0 -0
- data/vendor/local/bin/libzmq.dll +0 -0
- data/vendor/local/bin/local_lat.exe +0 -0
- data/vendor/local/bin/local_thr.exe +0 -0
- data/vendor/local/bin/remote_lat.exe +0 -0
- data/vendor/local/bin/remote_thr.exe +0 -0
- data/vendor/local/include/czmq.h +31 -0
- data/vendor/local/include/czmq_library.h +199 -0
- data/vendor/local/include/czmq_prelude.h +641 -0
- data/vendor/local/include/readme.txt +83 -0
- data/vendor/local/include/sha1.h +76 -0
- data/vendor/local/include/sha1.inc_c +335 -0
- data/vendor/local/include/slre.h +92 -0
- data/vendor/local/include/slre.inc_c +660 -0
- data/vendor/local/include/zactor.h +76 -0
- data/vendor/local/include/zarmour.h +114 -0
- data/vendor/local/include/zauth.h +100 -0
- data/vendor/local/include/zauth_v2.h +88 -0
- data/vendor/local/include/zbeacon.h +86 -0
- data/vendor/local/include/zbeacon_v2.h +75 -0
- data/vendor/local/include/zcert.h +136 -0
- data/vendor/local/include/zcertstore.h +100 -0
- data/vendor/local/include/zchunk.h +163 -0
- data/vendor/local/include/zclock.h +73 -0
- data/vendor/local/include/zconfig.h +185 -0
- data/vendor/local/include/zctx.h +107 -0
- data/vendor/local/include/zdigest.h +65 -0
- data/vendor/local/include/zdir.h +149 -0
- data/vendor/local/include/zdir_patch.h +82 -0
- data/vendor/local/include/zfile.h +177 -0
- data/vendor/local/include/zframe.h +176 -0
- data/vendor/local/include/zgossip.h +95 -0
- data/vendor/local/include/zgossip_engine.inc +927 -0
- data/vendor/local/include/zgossip_msg.h +129 -0
- data/vendor/local/include/zhash.h +195 -0
- data/vendor/local/include/zhash_primes.inc +329 -0
- data/vendor/local/include/zhashx.h +298 -0
- data/vendor/local/include/ziflist.h +77 -0
- data/vendor/local/include/zlist.h +158 -0
- data/vendor/local/include/zlistx.h +205 -0
- data/vendor/local/include/zloop.h +168 -0
- data/vendor/local/include/zmonitor.h +73 -0
- data/vendor/local/include/zmonitor_v2.h +56 -0
- data/vendor/local/include/zmq.h +617 -0
- data/vendor/local/include/zmq_utils.h +48 -0
- data/vendor/local/include/zmsg.h +280 -0
- data/vendor/local/include/zmutex.h +55 -0
- data/vendor/local/include/zpoller.h +92 -0
- data/vendor/local/include/zproc.h +168 -0
- data/vendor/local/include/zproxy.h +111 -0
- data/vendor/local/include/zproxy_v2.h +62 -0
- data/vendor/local/include/zrex.h +82 -0
- data/vendor/local/include/zsock.h +912 -0
- data/vendor/local/include/zsock_option.inc +4126 -0
- data/vendor/local/include/zsocket.h +110 -0
- data/vendor/local/include/zsockopt.h +256 -0
- data/vendor/local/include/zstr.h +110 -0
- data/vendor/local/include/zsys.h +386 -0
- data/vendor/local/include/zthread.h +50 -0
- data/vendor/local/include/ztimerset.h +90 -0
- data/vendor/local/include/ztrie.h +106 -0
- data/vendor/local/include/zuuid.h +96 -0
- data/vendor/local/lib/libczmq.dll.a +0 -0
- data/vendor/local/lib/liblibzmq.dll.a +0 -0
- data/vendor/local/lib/libzmq-static.a +0 -0
- data/vendor/local/lib/pkgconfig/libczmq.pc +23 -0
- data/vendor/local/lib/pkgconfig/libzmq.pc +11 -0
- data/vendor/local/share/zmq/AUTHORS.txt +147 -0
- data/vendor/local/share/zmq/COPYING.LESSER.txt +181 -0
- data/vendor/local/share/zmq/COPYING.txt +674 -0
- data/vendor/local/share/zmq/NEWS.txt +978 -0
- metadata +230 -0
@@ -0,0 +1,203 @@
|
|
1
|
+
################################################################################
|
2
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
3
|
+
# Read the zproject/README.md for information about making permanent changes. #
|
4
|
+
################################################################################
|
5
|
+
|
6
|
+
module CZMQ
|
7
|
+
module FFI
|
8
|
+
|
9
|
+
# sending and receiving strings
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Zstr
|
12
|
+
# Raised when one tries to use an instance of {Zstr} 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
|
+
# Receive C string from socket. Caller must free returned string using
|
76
|
+
# zstr_free(). Returns NULL if the context is being terminated or the
|
77
|
+
# process was interrupted.
|
78
|
+
#
|
79
|
+
# @param source [::FFI::Pointer, #to_ptr]
|
80
|
+
# @return [::FFI::AutoPointer]
|
81
|
+
def self.recv(source)
|
82
|
+
result = ::CZMQ::FFI.zstr_recv(source)
|
83
|
+
result = ::FFI::AutoPointer.new(result, LibC.method(:free))
|
84
|
+
result
|
85
|
+
end
|
86
|
+
|
87
|
+
# Receive a series of strings (until NULL) from multipart data.
|
88
|
+
# Each string is allocated and filled with string data; if there
|
89
|
+
# are not enough frames, unallocated strings are set to NULL.
|
90
|
+
# Returns -1 if the message could not be read, else returns the
|
91
|
+
# number of strings filled, zero or more. Free each returned string
|
92
|
+
# using zstr_free(). If not enough strings are provided, remaining
|
93
|
+
# multipart frames in the message are dropped.
|
94
|
+
#
|
95
|
+
# @param source [::FFI::Pointer, #to_ptr]
|
96
|
+
# @param string_p [::FFI::Pointer, #to_ptr]
|
97
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
98
|
+
# @return [Integer]
|
99
|
+
def self.recvx(source, string_p, *args)
|
100
|
+
result = ::CZMQ::FFI.zstr_recvx(source, string_p, *args)
|
101
|
+
result
|
102
|
+
end
|
103
|
+
|
104
|
+
# Send a C string to a socket, as a frame. The string is sent without
|
105
|
+
# trailing null byte; to read this you can use zstr_recv, or a similar
|
106
|
+
# method that adds a null terminator on the received string. String
|
107
|
+
# may be NULL, which is sent as "".
|
108
|
+
#
|
109
|
+
# @param dest [::FFI::Pointer, #to_ptr]
|
110
|
+
# @param string [String, #to_s, nil]
|
111
|
+
# @return [Integer]
|
112
|
+
def self.send(dest, string)
|
113
|
+
result = ::CZMQ::FFI.zstr_send(dest, string)
|
114
|
+
result
|
115
|
+
end
|
116
|
+
|
117
|
+
# Send a C string to a socket, as zstr_send(), with a MORE flag, so that
|
118
|
+
# you can send further strings in the same multi-part message.
|
119
|
+
#
|
120
|
+
# @param dest [::FFI::Pointer, #to_ptr]
|
121
|
+
# @param string [String, #to_s, nil]
|
122
|
+
# @return [Integer]
|
123
|
+
def self.sendm(dest, string)
|
124
|
+
result = ::CZMQ::FFI.zstr_sendm(dest, string)
|
125
|
+
result
|
126
|
+
end
|
127
|
+
|
128
|
+
# Send a formatted string to a socket. Note that you should NOT use
|
129
|
+
# user-supplied strings in the format (they may contain '%' which
|
130
|
+
# will create security holes).
|
131
|
+
#
|
132
|
+
# @param dest [::FFI::Pointer, #to_ptr]
|
133
|
+
# @param format [String, #to_s, nil]
|
134
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
135
|
+
# @return [Integer]
|
136
|
+
def self.sendf(dest, format, *args)
|
137
|
+
result = ::CZMQ::FFI.zstr_sendf(dest, format, *args)
|
138
|
+
result
|
139
|
+
end
|
140
|
+
|
141
|
+
# Send a formatted string to a socket, as for zstr_sendf(), with a
|
142
|
+
# MORE flag, so that you can send further strings in the same multi-part
|
143
|
+
# message.
|
144
|
+
#
|
145
|
+
# @param dest [::FFI::Pointer, #to_ptr]
|
146
|
+
# @param format [String, #to_s, nil]
|
147
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
148
|
+
# @return [Integer]
|
149
|
+
def self.sendfm(dest, format, *args)
|
150
|
+
result = ::CZMQ::FFI.zstr_sendfm(dest, format, *args)
|
151
|
+
result
|
152
|
+
end
|
153
|
+
|
154
|
+
# Send a series of strings (until NULL) as multipart data
|
155
|
+
# Returns 0 if the strings could be sent OK, or -1 on error.
|
156
|
+
#
|
157
|
+
# @param dest [::FFI::Pointer, #to_ptr]
|
158
|
+
# @param string [String, #to_s, nil]
|
159
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
160
|
+
# @return [Integer]
|
161
|
+
def self.sendx(dest, string, *args)
|
162
|
+
result = ::CZMQ::FFI.zstr_sendx(dest, string, *args)
|
163
|
+
result
|
164
|
+
end
|
165
|
+
|
166
|
+
# Accepts a void pointer and returns a fresh character string. If source
|
167
|
+
# is null, returns an empty string.
|
168
|
+
#
|
169
|
+
# @param source [::FFI::Pointer, #to_ptr]
|
170
|
+
# @return [::FFI::AutoPointer]
|
171
|
+
def self.str(source)
|
172
|
+
result = ::CZMQ::FFI.zstr_str(source)
|
173
|
+
result = ::FFI::AutoPointer.new(result, LibC.method(:free))
|
174
|
+
result
|
175
|
+
end
|
176
|
+
|
177
|
+
# Free a provided string, and nullify the parent pointer. Safe to call on
|
178
|
+
# a null pointer.
|
179
|
+
#
|
180
|
+
# @param string_p [::FFI::Pointer, #to_ptr]
|
181
|
+
# @return [void]
|
182
|
+
def self.free(string_p)
|
183
|
+
result = ::CZMQ::FFI.zstr_free(string_p)
|
184
|
+
result
|
185
|
+
end
|
186
|
+
|
187
|
+
# Self test of this class.
|
188
|
+
#
|
189
|
+
# @param verbose [Boolean]
|
190
|
+
# @return [void]
|
191
|
+
def self.test(verbose)
|
192
|
+
verbose = !(0==verbose||!verbose) # boolean
|
193
|
+
result = ::CZMQ::FFI.zstr_test(verbose)
|
194
|
+
result
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
################################################################################
|
201
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
202
|
+
# Read the zproject/README.md for information about making permanent changes. #
|
203
|
+
################################################################################
|
@@ -0,0 +1,203 @@
|
|
1
|
+
################################################################################
|
2
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
3
|
+
# Read the zproject/README.md for information about making permanent changes. #
|
4
|
+
################################################################################
|
5
|
+
|
6
|
+
module CZMQ
|
7
|
+
module FFI
|
8
|
+
|
9
|
+
# timer set
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Ztimerset
|
12
|
+
# Raised when one tries to use an instance of {Ztimerset} 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.ztimerset_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
|
+
# Create a new callback of the following type:
|
77
|
+
# Callback function for timer event.
|
78
|
+
# typedef void (ztimerset_fn) (
|
79
|
+
# int timer_id, void *arg);
|
80
|
+
#
|
81
|
+
# @note WARNING: If your Ruby code doesn't retain a reference to the
|
82
|
+
# FFI::Function object after passing it to a C function call,
|
83
|
+
# it may be garbage collected while C still holds the pointer,
|
84
|
+
# potentially resulting in a segmentation fault.
|
85
|
+
def self.fn
|
86
|
+
::FFI::Function.new :void, [:int, :pointer], blocking: true do |timer_id, arg|
|
87
|
+
result = yield timer_id, arg
|
88
|
+
result
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Create new timer set.
|
93
|
+
# @return [CZMQ::Ztimerset]
|
94
|
+
def self.new()
|
95
|
+
ptr = ::CZMQ::FFI.ztimerset_new()
|
96
|
+
__new ptr
|
97
|
+
end
|
98
|
+
|
99
|
+
# Destroy a timer set
|
100
|
+
#
|
101
|
+
# @return [void]
|
102
|
+
def destroy()
|
103
|
+
return unless @ptr
|
104
|
+
self_p = __ptr_give_ref
|
105
|
+
result = ::CZMQ::FFI.ztimerset_destroy(self_p)
|
106
|
+
result
|
107
|
+
end
|
108
|
+
|
109
|
+
# Add a timer to the set. Returns timer id if OK, -1 on failure.
|
110
|
+
#
|
111
|
+
# @param interval [Integer, #to_int, #to_i]
|
112
|
+
# @param handler [::FFI::Pointer, #to_ptr]
|
113
|
+
# @param arg [::FFI::Pointer, #to_ptr]
|
114
|
+
# @return [Integer]
|
115
|
+
def add(interval, handler, arg)
|
116
|
+
raise DestroyedError unless @ptr
|
117
|
+
self_p = @ptr
|
118
|
+
interval = Integer(interval)
|
119
|
+
result = ::CZMQ::FFI.ztimerset_add(self_p, interval, handler, arg)
|
120
|
+
result
|
121
|
+
end
|
122
|
+
|
123
|
+
# Cancel a timer. Returns 0 if OK, -1 on failure.
|
124
|
+
#
|
125
|
+
# @param timer_id [Integer, #to_int, #to_i]
|
126
|
+
# @return [Integer]
|
127
|
+
def cancel(timer_id)
|
128
|
+
raise DestroyedError unless @ptr
|
129
|
+
self_p = @ptr
|
130
|
+
timer_id = Integer(timer_id)
|
131
|
+
result = ::CZMQ::FFI.ztimerset_cancel(self_p, timer_id)
|
132
|
+
result
|
133
|
+
end
|
134
|
+
|
135
|
+
# Set timer interval. Returns 0 if OK, -1 on failure.
|
136
|
+
# This method is slow, canceling the timer and adding a new one yield better performance.
|
137
|
+
#
|
138
|
+
# @param timer_id [Integer, #to_int, #to_i]
|
139
|
+
# @param interval [Integer, #to_int, #to_i]
|
140
|
+
# @return [Integer]
|
141
|
+
def set_interval(timer_id, interval)
|
142
|
+
raise DestroyedError unless @ptr
|
143
|
+
self_p = @ptr
|
144
|
+
timer_id = Integer(timer_id)
|
145
|
+
interval = Integer(interval)
|
146
|
+
result = ::CZMQ::FFI.ztimerset_set_interval(self_p, timer_id, interval)
|
147
|
+
result
|
148
|
+
end
|
149
|
+
|
150
|
+
# Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure.
|
151
|
+
# This method is slow, canceling the timer and adding a new one yield better performance.
|
152
|
+
#
|
153
|
+
# @param timer_id [Integer, #to_int, #to_i]
|
154
|
+
# @return [Integer]
|
155
|
+
def reset(timer_id)
|
156
|
+
raise DestroyedError unless @ptr
|
157
|
+
self_p = @ptr
|
158
|
+
timer_id = Integer(timer_id)
|
159
|
+
result = ::CZMQ::FFI.ztimerset_reset(self_p, timer_id)
|
160
|
+
result
|
161
|
+
end
|
162
|
+
|
163
|
+
# Return the time until the next interval.
|
164
|
+
# Should be used as timeout parameter for the zpoller wait method.
|
165
|
+
# The timeout is in msec.
|
166
|
+
#
|
167
|
+
# @return [Integer]
|
168
|
+
def timeout()
|
169
|
+
raise DestroyedError unless @ptr
|
170
|
+
self_p = @ptr
|
171
|
+
result = ::CZMQ::FFI.ztimerset_timeout(self_p)
|
172
|
+
result
|
173
|
+
end
|
174
|
+
|
175
|
+
# Invoke callback function of all timers which their interval has elapsed.
|
176
|
+
# Should be call after zpoller wait method.
|
177
|
+
# Returns 0 if OK, -1 on failure.
|
178
|
+
#
|
179
|
+
# @return [Integer]
|
180
|
+
def execute()
|
181
|
+
raise DestroyedError unless @ptr
|
182
|
+
self_p = @ptr
|
183
|
+
result = ::CZMQ::FFI.ztimerset_execute(self_p)
|
184
|
+
result
|
185
|
+
end
|
186
|
+
|
187
|
+
# Self test of this class.
|
188
|
+
#
|
189
|
+
# @param verbose [Boolean]
|
190
|
+
# @return [void]
|
191
|
+
def self.test(verbose)
|
192
|
+
verbose = !(0==verbose||!verbose) # boolean
|
193
|
+
result = ::CZMQ::FFI.ztimerset_test(verbose)
|
194
|
+
result
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
################################################################################
|
201
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
202
|
+
# Read the zproject/README.md for information about making permanent changes. #
|
203
|
+
################################################################################
|
@@ -0,0 +1,221 @@
|
|
1
|
+
################################################################################
|
2
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
3
|
+
# Read the zproject/README.md for information about making permanent changes. #
|
4
|
+
################################################################################
|
5
|
+
|
6
|
+
module CZMQ
|
7
|
+
module FFI
|
8
|
+
|
9
|
+
# simple trie for tokenizable strings
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Ztrie
|
12
|
+
# Raised when one tries to use an instance of {Ztrie} 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.ztrie_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
|
+
# Create a new callback of the following type:
|
77
|
+
# Callback function for ztrie_node to destroy node data.
|
78
|
+
# typedef void (ztrie_destroy_data_fn) (
|
79
|
+
# void **data);
|
80
|
+
#
|
81
|
+
# @note WARNING: If your Ruby code doesn't retain a reference to the
|
82
|
+
# FFI::Function object after passing it to a C function call,
|
83
|
+
# it may be garbage collected while C still holds the pointer,
|
84
|
+
# potentially resulting in a segmentation fault.
|
85
|
+
def self.destroy_data_fn
|
86
|
+
::FFI::Function.new :void, [:pointer], blocking: true do |data|
|
87
|
+
result = yield data
|
88
|
+
result
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Creates a new ztrie.
|
93
|
+
# @param delimiter [::FFI::Pointer, #to_ptr]
|
94
|
+
# @return [CZMQ::Ztrie]
|
95
|
+
def self.new(delimiter)
|
96
|
+
ptr = ::CZMQ::FFI.ztrie_new(delimiter)
|
97
|
+
__new ptr
|
98
|
+
end
|
99
|
+
|
100
|
+
# Destroy the ztrie.
|
101
|
+
#
|
102
|
+
# @return [void]
|
103
|
+
def destroy()
|
104
|
+
return unless @ptr
|
105
|
+
self_p = __ptr_give_ref
|
106
|
+
result = ::CZMQ::FFI.ztrie_destroy(self_p)
|
107
|
+
result
|
108
|
+
end
|
109
|
+
|
110
|
+
# Inserts a new route into the tree and attaches the data. Returns -1
|
111
|
+
# if the route already exists, otherwise 0. This method takes ownership of
|
112
|
+
# the provided data if a destroy_data_fn is provided.
|
113
|
+
#
|
114
|
+
# @param path [String, #to_s, nil]
|
115
|
+
# @param data [::FFI::Pointer, #to_ptr]
|
116
|
+
# @param destroy_data_fn [::FFI::Pointer, #to_ptr]
|
117
|
+
# @return [Integer]
|
118
|
+
def insert_route(path, data, destroy_data_fn)
|
119
|
+
raise DestroyedError unless @ptr
|
120
|
+
self_p = @ptr
|
121
|
+
result = ::CZMQ::FFI.ztrie_insert_route(self_p, path, data, destroy_data_fn)
|
122
|
+
result
|
123
|
+
end
|
124
|
+
|
125
|
+
# Removes a route from the trie and destroys its data. Returns -1 if the
|
126
|
+
# route does not exists, otherwise 0.
|
127
|
+
# the start of the list call zlist_first (). Advances the cursor.
|
128
|
+
#
|
129
|
+
# @param path [String, #to_s, nil]
|
130
|
+
# @return [Integer]
|
131
|
+
def remove_route(path)
|
132
|
+
raise DestroyedError unless @ptr
|
133
|
+
self_p = @ptr
|
134
|
+
result = ::CZMQ::FFI.ztrie_remove_route(self_p, path)
|
135
|
+
result
|
136
|
+
end
|
137
|
+
|
138
|
+
# Returns true if the path matches a route in the tree, otherwise false.
|
139
|
+
#
|
140
|
+
# @param path [String, #to_s, nil]
|
141
|
+
# @return [Boolean]
|
142
|
+
def matches(path)
|
143
|
+
raise DestroyedError unless @ptr
|
144
|
+
self_p = @ptr
|
145
|
+
result = ::CZMQ::FFI.ztrie_matches(self_p, path)
|
146
|
+
result
|
147
|
+
end
|
148
|
+
|
149
|
+
# Returns the data of a matched route from last ztrie_matches. If the path
|
150
|
+
# did not match, returns NULL. Do not delete the data as it's owned by
|
151
|
+
# ztrie.
|
152
|
+
#
|
153
|
+
# @return [::FFI::Pointer]
|
154
|
+
def hit_data()
|
155
|
+
raise DestroyedError unless @ptr
|
156
|
+
self_p = @ptr
|
157
|
+
result = ::CZMQ::FFI.ztrie_hit_data(self_p)
|
158
|
+
result
|
159
|
+
end
|
160
|
+
|
161
|
+
# Returns the count of parameters that a matched route has.
|
162
|
+
#
|
163
|
+
# @return [Integer]
|
164
|
+
def hit_parameter_count()
|
165
|
+
raise DestroyedError unless @ptr
|
166
|
+
self_p = @ptr
|
167
|
+
result = ::CZMQ::FFI.ztrie_hit_parameter_count(self_p)
|
168
|
+
result
|
169
|
+
end
|
170
|
+
|
171
|
+
# Returns the parameters of a matched route with named regexes from last
|
172
|
+
# ztrie_matches. If the path did not match or the route did not contain any
|
173
|
+
# named regexes, returns NULL.
|
174
|
+
#
|
175
|
+
# @return [Zhashx]
|
176
|
+
def hit_parameters()
|
177
|
+
raise DestroyedError unless @ptr
|
178
|
+
self_p = @ptr
|
179
|
+
result = ::CZMQ::FFI.ztrie_hit_parameters(self_p)
|
180
|
+
result = Zhashx.__new result, false
|
181
|
+
result
|
182
|
+
end
|
183
|
+
|
184
|
+
# Returns the asterisk matched part of a route, if there has been no match
|
185
|
+
# or no asterisk match, returns NULL.
|
186
|
+
#
|
187
|
+
# @return [String]
|
188
|
+
def hit_asterisk_match()
|
189
|
+
raise DestroyedError unless @ptr
|
190
|
+
self_p = @ptr
|
191
|
+
result = ::CZMQ::FFI.ztrie_hit_asterisk_match(self_p)
|
192
|
+
result
|
193
|
+
end
|
194
|
+
|
195
|
+
# Print the trie
|
196
|
+
#
|
197
|
+
# @return [void]
|
198
|
+
def print()
|
199
|
+
raise DestroyedError unless @ptr
|
200
|
+
self_p = @ptr
|
201
|
+
result = ::CZMQ::FFI.ztrie_print(self_p)
|
202
|
+
result
|
203
|
+
end
|
204
|
+
|
205
|
+
# Self test of this class.
|
206
|
+
#
|
207
|
+
# @param verbose [Boolean]
|
208
|
+
# @return [void]
|
209
|
+
def self.test(verbose)
|
210
|
+
verbose = !(0==verbose||!verbose) # boolean
|
211
|
+
result = ::CZMQ::FFI.ztrie_test(verbose)
|
212
|
+
result
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
################################################################################
|
219
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
220
|
+
# Read the zproject/README.md for information about making permanent changes. #
|
221
|
+
################################################################################
|