czmq-ffi-gen 0.9.2-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- 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,353 @@
|
|
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
|
+
# helper functions for working with files.
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Zfile
|
12
|
+
# Raised when one tries to use an instance of {Zfile} 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.zfile_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
|
+
# If file exists, populates properties. CZMQ supports portable symbolic
|
77
|
+
# links, which are files with the extension ".ln". A symbolic link is a
|
78
|
+
# text file containing one line, the filename of a target file. Reading
|
79
|
+
# data from the symbolic link actually reads from the target file. Path
|
80
|
+
# may be NULL, in which case it is not used.
|
81
|
+
# @param path [String, #to_s, nil]
|
82
|
+
# @param name [String, #to_s, nil]
|
83
|
+
# @return [CZMQ::Zfile]
|
84
|
+
def self.new(path, name)
|
85
|
+
ptr = ::CZMQ::FFI.zfile_new(path, name)
|
86
|
+
__new ptr
|
87
|
+
end
|
88
|
+
|
89
|
+
# Destroy a file item
|
90
|
+
#
|
91
|
+
# @return [void]
|
92
|
+
def destroy()
|
93
|
+
return unless @ptr
|
94
|
+
self_p = __ptr_give_ref
|
95
|
+
result = ::CZMQ::FFI.zfile_destroy(self_p)
|
96
|
+
result
|
97
|
+
end
|
98
|
+
|
99
|
+
# Duplicate a file item, returns a newly constructed item. If the file
|
100
|
+
# is null, or memory was exhausted, returns null.
|
101
|
+
#
|
102
|
+
# @return [Zfile]
|
103
|
+
def dup()
|
104
|
+
raise DestroyedError unless @ptr
|
105
|
+
self_p = @ptr
|
106
|
+
result = ::CZMQ::FFI.zfile_dup(self_p)
|
107
|
+
result = Zfile.__new result, true
|
108
|
+
result
|
109
|
+
end
|
110
|
+
|
111
|
+
# Return file name, remove path if provided
|
112
|
+
#
|
113
|
+
# @param path [String, #to_s, nil]
|
114
|
+
# @return [String]
|
115
|
+
def filename(path)
|
116
|
+
raise DestroyedError unless @ptr
|
117
|
+
self_p = @ptr
|
118
|
+
result = ::CZMQ::FFI.zfile_filename(self_p, path)
|
119
|
+
result
|
120
|
+
end
|
121
|
+
|
122
|
+
# Refresh file properties from disk; this is not done automatically
|
123
|
+
# on access methods, otherwise it is not possible to compare directory
|
124
|
+
# snapshots.
|
125
|
+
#
|
126
|
+
# @return [void]
|
127
|
+
def restat()
|
128
|
+
raise DestroyedError unless @ptr
|
129
|
+
self_p = @ptr
|
130
|
+
result = ::CZMQ::FFI.zfile_restat(self_p)
|
131
|
+
result
|
132
|
+
end
|
133
|
+
|
134
|
+
# Return when the file was last modified. If you want this to reflect the
|
135
|
+
# current situation, call zfile_restat before checking this property.
|
136
|
+
#
|
137
|
+
# @return [::FFI::Pointer]
|
138
|
+
def modified()
|
139
|
+
raise DestroyedError unless @ptr
|
140
|
+
self_p = @ptr
|
141
|
+
result = ::CZMQ::FFI.zfile_modified(self_p)
|
142
|
+
result
|
143
|
+
end
|
144
|
+
|
145
|
+
# Return the last-known size of the file. If you want this to reflect the
|
146
|
+
# current situation, call zfile_restat before checking this property.
|
147
|
+
#
|
148
|
+
# @return [::FFI::Pointer]
|
149
|
+
def cursize()
|
150
|
+
raise DestroyedError unless @ptr
|
151
|
+
self_p = @ptr
|
152
|
+
result = ::CZMQ::FFI.zfile_cursize(self_p)
|
153
|
+
result
|
154
|
+
end
|
155
|
+
|
156
|
+
# Return true if the file is a directory. If you want this to reflect
|
157
|
+
# any external changes, call zfile_restat before checking this property.
|
158
|
+
#
|
159
|
+
# @return [Boolean]
|
160
|
+
def is_directory()
|
161
|
+
raise DestroyedError unless @ptr
|
162
|
+
self_p = @ptr
|
163
|
+
result = ::CZMQ::FFI.zfile_is_directory(self_p)
|
164
|
+
result
|
165
|
+
end
|
166
|
+
|
167
|
+
# Return true if the file is a regular file. If you want this to reflect
|
168
|
+
# any external changes, call zfile_restat before checking this property.
|
169
|
+
#
|
170
|
+
# @return [Boolean]
|
171
|
+
def is_regular()
|
172
|
+
raise DestroyedError unless @ptr
|
173
|
+
self_p = @ptr
|
174
|
+
result = ::CZMQ::FFI.zfile_is_regular(self_p)
|
175
|
+
result
|
176
|
+
end
|
177
|
+
|
178
|
+
# Return true if the file is readable by this process. If you want this to
|
179
|
+
# reflect any external changes, call zfile_restat before checking this
|
180
|
+
# property.
|
181
|
+
#
|
182
|
+
# @return [Boolean]
|
183
|
+
def is_readable()
|
184
|
+
raise DestroyedError unless @ptr
|
185
|
+
self_p = @ptr
|
186
|
+
result = ::CZMQ::FFI.zfile_is_readable(self_p)
|
187
|
+
result
|
188
|
+
end
|
189
|
+
|
190
|
+
# Return true if the file is writeable by this process. If you want this
|
191
|
+
# to reflect any external changes, call zfile_restat before checking this
|
192
|
+
# property.
|
193
|
+
#
|
194
|
+
# @return [Boolean]
|
195
|
+
def is_writeable()
|
196
|
+
raise DestroyedError unless @ptr
|
197
|
+
self_p = @ptr
|
198
|
+
result = ::CZMQ::FFI.zfile_is_writeable(self_p)
|
199
|
+
result
|
200
|
+
end
|
201
|
+
|
202
|
+
# Check if file has stopped changing and can be safely processed.
|
203
|
+
# Updates the file statistics from disk at every call.
|
204
|
+
#
|
205
|
+
# @return [Boolean]
|
206
|
+
def is_stable()
|
207
|
+
raise DestroyedError unless @ptr
|
208
|
+
self_p = @ptr
|
209
|
+
result = ::CZMQ::FFI.zfile_is_stable(self_p)
|
210
|
+
result
|
211
|
+
end
|
212
|
+
|
213
|
+
# Return true if the file was changed on disk since the zfile_t object
|
214
|
+
# was created, or the last zfile_restat() call made on it.
|
215
|
+
#
|
216
|
+
# @return [Boolean]
|
217
|
+
def has_changed()
|
218
|
+
raise DestroyedError unless @ptr
|
219
|
+
self_p = @ptr
|
220
|
+
result = ::CZMQ::FFI.zfile_has_changed(self_p)
|
221
|
+
result
|
222
|
+
end
|
223
|
+
|
224
|
+
# Remove the file from disk
|
225
|
+
#
|
226
|
+
# @return [void]
|
227
|
+
def remove()
|
228
|
+
raise DestroyedError unless @ptr
|
229
|
+
self_p = @ptr
|
230
|
+
result = ::CZMQ::FFI.zfile_remove(self_p)
|
231
|
+
result
|
232
|
+
end
|
233
|
+
|
234
|
+
# Open file for reading
|
235
|
+
# Returns 0 if OK, -1 if not found or not accessible
|
236
|
+
#
|
237
|
+
# @return [Integer]
|
238
|
+
def input()
|
239
|
+
raise DestroyedError unless @ptr
|
240
|
+
self_p = @ptr
|
241
|
+
result = ::CZMQ::FFI.zfile_input(self_p)
|
242
|
+
result
|
243
|
+
end
|
244
|
+
|
245
|
+
# Open file for writing, creating directory if needed
|
246
|
+
# File is created if necessary; chunks can be written to file at any
|
247
|
+
# location. Returns 0 if OK, -1 if error.
|
248
|
+
#
|
249
|
+
# @return [Integer]
|
250
|
+
def output()
|
251
|
+
raise DestroyedError unless @ptr
|
252
|
+
self_p = @ptr
|
253
|
+
result = ::CZMQ::FFI.zfile_output(self_p)
|
254
|
+
result
|
255
|
+
end
|
256
|
+
|
257
|
+
# Read chunk from file at specified position. If this was the last chunk,
|
258
|
+
# sets the eof property. Returns a null chunk in case of error.
|
259
|
+
#
|
260
|
+
# @param bytes [Integer, #to_int, #to_i]
|
261
|
+
# @param offset [::FFI::Pointer, #to_ptr]
|
262
|
+
# @return [Zchunk]
|
263
|
+
def read(bytes, offset)
|
264
|
+
raise DestroyedError unless @ptr
|
265
|
+
self_p = @ptr
|
266
|
+
bytes = Integer(bytes)
|
267
|
+
result = ::CZMQ::FFI.zfile_read(self_p, bytes, offset)
|
268
|
+
result = Zchunk.__new result, true
|
269
|
+
result
|
270
|
+
end
|
271
|
+
|
272
|
+
# Returns true if zfile_read() just read the last chunk in the file.
|
273
|
+
#
|
274
|
+
# @return [Boolean]
|
275
|
+
def eof()
|
276
|
+
raise DestroyedError unless @ptr
|
277
|
+
self_p = @ptr
|
278
|
+
result = ::CZMQ::FFI.zfile_eof(self_p)
|
279
|
+
result
|
280
|
+
end
|
281
|
+
|
282
|
+
# Write chunk to file at specified position
|
283
|
+
# Return 0 if OK, else -1
|
284
|
+
#
|
285
|
+
# @param chunk [Zchunk, #__ptr]
|
286
|
+
# @param offset [::FFI::Pointer, #to_ptr]
|
287
|
+
# @return [Integer]
|
288
|
+
def write(chunk, offset)
|
289
|
+
raise DestroyedError unless @ptr
|
290
|
+
self_p = @ptr
|
291
|
+
chunk = chunk.__ptr if chunk
|
292
|
+
result = ::CZMQ::FFI.zfile_write(self_p, chunk, offset)
|
293
|
+
result
|
294
|
+
end
|
295
|
+
|
296
|
+
# Read next line of text from file. Returns a pointer to the text line,
|
297
|
+
# or NULL if there was nothing more to read from the file.
|
298
|
+
#
|
299
|
+
# @return [String]
|
300
|
+
def readln()
|
301
|
+
raise DestroyedError unless @ptr
|
302
|
+
self_p = @ptr
|
303
|
+
result = ::CZMQ::FFI.zfile_readln(self_p)
|
304
|
+
result
|
305
|
+
end
|
306
|
+
|
307
|
+
# Close file, if open
|
308
|
+
#
|
309
|
+
# @return [void]
|
310
|
+
def close()
|
311
|
+
raise DestroyedError unless @ptr
|
312
|
+
self_p = @ptr
|
313
|
+
result = ::CZMQ::FFI.zfile_close(self_p)
|
314
|
+
result
|
315
|
+
end
|
316
|
+
|
317
|
+
# Return file handle, if opened
|
318
|
+
#
|
319
|
+
# @return [::FFI::Pointer]
|
320
|
+
def handle()
|
321
|
+
raise DestroyedError unless @ptr
|
322
|
+
self_p = @ptr
|
323
|
+
result = ::CZMQ::FFI.zfile_handle(self_p)
|
324
|
+
result
|
325
|
+
end
|
326
|
+
|
327
|
+
# Calculate SHA1 digest for file, using zdigest class.
|
328
|
+
#
|
329
|
+
# @return [String]
|
330
|
+
def digest()
|
331
|
+
raise DestroyedError unless @ptr
|
332
|
+
self_p = @ptr
|
333
|
+
result = ::CZMQ::FFI.zfile_digest(self_p)
|
334
|
+
result
|
335
|
+
end
|
336
|
+
|
337
|
+
# Self test of this class.
|
338
|
+
#
|
339
|
+
# @param verbose [Boolean]
|
340
|
+
# @return [void]
|
341
|
+
def self.test(verbose)
|
342
|
+
verbose = !(0==verbose||!verbose) # boolean
|
343
|
+
result = ::CZMQ::FFI.zfile_test(verbose)
|
344
|
+
result
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
################################################################################
|
351
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
352
|
+
# Read the zproject/README.md for information about making permanent changes. #
|
353
|
+
################################################################################
|
@@ -0,0 +1,359 @@
|
|
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
|
+
# working with single message frames
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Zframe
|
12
|
+
#
|
13
|
+
MORE = 1
|
14
|
+
|
15
|
+
#
|
16
|
+
REUSE = 2
|
17
|
+
|
18
|
+
#
|
19
|
+
DONTWAIT = 4
|
20
|
+
|
21
|
+
# Raised when one tries to use an instance of {Zframe} after
|
22
|
+
# the internal pointer to the native object has been nullified.
|
23
|
+
class DestroyedError < RuntimeError; end
|
24
|
+
|
25
|
+
# Boilerplate for self pointer, initializer, and finalizer
|
26
|
+
class << self
|
27
|
+
alias :__new :new
|
28
|
+
end
|
29
|
+
# Attaches the pointer _ptr_ to this instance and defines a finalizer for
|
30
|
+
# it if necessary.
|
31
|
+
# @param ptr [::FFI::Pointer]
|
32
|
+
# @param finalize [Boolean]
|
33
|
+
def initialize(ptr, finalize = true)
|
34
|
+
@ptr = ptr
|
35
|
+
if @ptr.null?
|
36
|
+
@ptr = nil # Remove null pointers so we don't have to test for them.
|
37
|
+
elsif finalize
|
38
|
+
@finalizer = self.class.create_finalizer_for @ptr
|
39
|
+
ObjectSpace.define_finalizer self, @finalizer
|
40
|
+
end
|
41
|
+
end
|
42
|
+
# @param ptr [::FFI::Pointer]
|
43
|
+
# @return [Proc]
|
44
|
+
def self.create_finalizer_for(ptr)
|
45
|
+
Proc.new do
|
46
|
+
ptr_ptr = ::FFI::MemoryPointer.new :pointer
|
47
|
+
ptr_ptr.write_pointer ptr
|
48
|
+
::CZMQ::FFI.zframe_destroy ptr_ptr
|
49
|
+
end
|
50
|
+
end
|
51
|
+
# @return [Boolean]
|
52
|
+
def null?
|
53
|
+
!@ptr or @ptr.null?
|
54
|
+
end
|
55
|
+
# Return internal pointer
|
56
|
+
# @return [::FFI::Pointer]
|
57
|
+
def __ptr
|
58
|
+
raise DestroyedError unless @ptr
|
59
|
+
@ptr
|
60
|
+
end
|
61
|
+
# So external Libraries can just pass the Object to a FFI function which expects a :pointer
|
62
|
+
alias_method :to_ptr, :__ptr
|
63
|
+
# Nullify internal pointer and return pointer pointer.
|
64
|
+
# @note This detaches the current instance from the native object
|
65
|
+
# and thus makes it unusable.
|
66
|
+
# @return [::FFI::MemoryPointer] the pointer pointing to a pointer
|
67
|
+
# pointing to the native object
|
68
|
+
def __ptr_give_ref
|
69
|
+
raise DestroyedError unless @ptr
|
70
|
+
ptr_ptr = ::FFI::MemoryPointer.new :pointer
|
71
|
+
ptr_ptr.write_pointer @ptr
|
72
|
+
__undef_finalizer if @finalizer
|
73
|
+
@ptr = nil
|
74
|
+
ptr_ptr
|
75
|
+
end
|
76
|
+
# Undefines the finalizer for this object.
|
77
|
+
# @note Only use this if you need to and can guarantee that the native
|
78
|
+
# object will be freed by other means.
|
79
|
+
# @return [void]
|
80
|
+
def __undef_finalizer
|
81
|
+
ObjectSpace.undefine_finalizer self
|
82
|
+
@finalizer = nil
|
83
|
+
end
|
84
|
+
|
85
|
+
# Create a new frame. If size is not null, allocates the frame data
|
86
|
+
# to the specified size. If additionally, data is not null, copies
|
87
|
+
# size octets from the specified data into the frame body.
|
88
|
+
# @param data [::FFI::Pointer, #to_ptr]
|
89
|
+
# @param size [Integer, #to_int, #to_i]
|
90
|
+
# @return [CZMQ::Zframe]
|
91
|
+
def self.new(data, size)
|
92
|
+
size = Integer(size)
|
93
|
+
ptr = ::CZMQ::FFI.zframe_new(data, size)
|
94
|
+
__new ptr
|
95
|
+
end
|
96
|
+
|
97
|
+
# Create an empty (zero-sized) frame
|
98
|
+
# @return [CZMQ::Zframe]
|
99
|
+
def self.new_empty()
|
100
|
+
ptr = ::CZMQ::FFI.zframe_new_empty()
|
101
|
+
__new ptr
|
102
|
+
end
|
103
|
+
|
104
|
+
# Create a frame with a specified string content.
|
105
|
+
# @param string [String, #to_s, nil]
|
106
|
+
# @return [CZMQ::Zframe]
|
107
|
+
def self.from(string)
|
108
|
+
ptr = ::CZMQ::FFI.zframe_from(string)
|
109
|
+
__new ptr
|
110
|
+
end
|
111
|
+
|
112
|
+
# Receive frame from socket, returns zframe_t object or NULL if the recv
|
113
|
+
# was interrupted. Does a blocking recv, if you want to not block then use
|
114
|
+
# zpoller or zloop.
|
115
|
+
# @param source [::FFI::Pointer, #to_ptr]
|
116
|
+
# @return [CZMQ::Zframe]
|
117
|
+
def self.recv(source)
|
118
|
+
ptr = ::CZMQ::FFI.zframe_recv(source)
|
119
|
+
__new ptr
|
120
|
+
end
|
121
|
+
|
122
|
+
# Destroy a frame
|
123
|
+
#
|
124
|
+
# @return [void]
|
125
|
+
def destroy()
|
126
|
+
return unless @ptr
|
127
|
+
self_p = __ptr_give_ref
|
128
|
+
result = ::CZMQ::FFI.zframe_destroy(self_p)
|
129
|
+
result
|
130
|
+
end
|
131
|
+
|
132
|
+
# Send a frame to a socket, destroy frame after sending.
|
133
|
+
# Return -1 on error, 0 on success.
|
134
|
+
#
|
135
|
+
# @param self_p [#__ptr_give_ref]
|
136
|
+
# @param dest [::FFI::Pointer, #to_ptr]
|
137
|
+
# @param flags [Integer, #to_int, #to_i]
|
138
|
+
# @return [Integer]
|
139
|
+
def self.send(self_p, dest, flags)
|
140
|
+
self_p = self_p.__ptr_give_ref
|
141
|
+
flags = Integer(flags)
|
142
|
+
result = ::CZMQ::FFI.zframe_send(self_p, dest, flags)
|
143
|
+
result
|
144
|
+
end
|
145
|
+
|
146
|
+
# Return number of bytes in frame data
|
147
|
+
#
|
148
|
+
# @return [Integer]
|
149
|
+
def size()
|
150
|
+
raise DestroyedError unless @ptr
|
151
|
+
self_p = @ptr
|
152
|
+
result = ::CZMQ::FFI.zframe_size(self_p)
|
153
|
+
result
|
154
|
+
end
|
155
|
+
|
156
|
+
# Return address of frame data
|
157
|
+
#
|
158
|
+
# @return [::FFI::Pointer]
|
159
|
+
def data()
|
160
|
+
raise DestroyedError unless @ptr
|
161
|
+
self_p = @ptr
|
162
|
+
result = ::CZMQ::FFI.zframe_data(self_p)
|
163
|
+
result
|
164
|
+
end
|
165
|
+
|
166
|
+
# Return meta data property for frame
|
167
|
+
# Caller must free string when finished with it.
|
168
|
+
#
|
169
|
+
# @param property [String, #to_s, nil]
|
170
|
+
# @return [String]
|
171
|
+
def meta(property)
|
172
|
+
raise DestroyedError unless @ptr
|
173
|
+
self_p = @ptr
|
174
|
+
result = ::CZMQ::FFI.zframe_meta(self_p, property)
|
175
|
+
result
|
176
|
+
end
|
177
|
+
|
178
|
+
# Create a new frame that duplicates an existing frame. If frame is null,
|
179
|
+
# or memory was exhausted, returns null.
|
180
|
+
#
|
181
|
+
# @return [Zframe]
|
182
|
+
def dup()
|
183
|
+
raise DestroyedError unless @ptr
|
184
|
+
self_p = @ptr
|
185
|
+
result = ::CZMQ::FFI.zframe_dup(self_p)
|
186
|
+
result = Zframe.__new result, true
|
187
|
+
result
|
188
|
+
end
|
189
|
+
|
190
|
+
# Return frame data encoded as printable hex string, useful for 0MQ UUIDs.
|
191
|
+
# Caller must free string when finished with it.
|
192
|
+
#
|
193
|
+
# @return [::FFI::AutoPointer]
|
194
|
+
def strhex()
|
195
|
+
raise DestroyedError unless @ptr
|
196
|
+
self_p = @ptr
|
197
|
+
result = ::CZMQ::FFI.zframe_strhex(self_p)
|
198
|
+
result = ::FFI::AutoPointer.new(result, LibC.method(:free))
|
199
|
+
result
|
200
|
+
end
|
201
|
+
|
202
|
+
# Return frame data copied into freshly allocated string
|
203
|
+
# Caller must free string when finished with it.
|
204
|
+
#
|
205
|
+
# @return [::FFI::AutoPointer]
|
206
|
+
def strdup()
|
207
|
+
raise DestroyedError unless @ptr
|
208
|
+
self_p = @ptr
|
209
|
+
result = ::CZMQ::FFI.zframe_strdup(self_p)
|
210
|
+
result = ::FFI::AutoPointer.new(result, LibC.method(:free))
|
211
|
+
result
|
212
|
+
end
|
213
|
+
|
214
|
+
# Return TRUE if frame body is equal to string, excluding terminator
|
215
|
+
#
|
216
|
+
# @param string [String, #to_s, nil]
|
217
|
+
# @return [Boolean]
|
218
|
+
def streq(string)
|
219
|
+
raise DestroyedError unless @ptr
|
220
|
+
self_p = @ptr
|
221
|
+
result = ::CZMQ::FFI.zframe_streq(self_p, string)
|
222
|
+
result
|
223
|
+
end
|
224
|
+
|
225
|
+
# Return frame MORE indicator (1 or 0), set when reading frame from socket
|
226
|
+
# or by the zframe_set_more() method
|
227
|
+
#
|
228
|
+
# @return [Integer]
|
229
|
+
def more()
|
230
|
+
raise DestroyedError unless @ptr
|
231
|
+
self_p = @ptr
|
232
|
+
result = ::CZMQ::FFI.zframe_more(self_p)
|
233
|
+
result
|
234
|
+
end
|
235
|
+
|
236
|
+
# Set frame MORE indicator (1 or 0). Note this is NOT used when sending
|
237
|
+
# frame to socket, you have to specify flag explicitly.
|
238
|
+
#
|
239
|
+
# @param more [Integer, #to_int, #to_i]
|
240
|
+
# @return [void]
|
241
|
+
def set_more(more)
|
242
|
+
raise DestroyedError unless @ptr
|
243
|
+
self_p = @ptr
|
244
|
+
more = Integer(more)
|
245
|
+
result = ::CZMQ::FFI.zframe_set_more(self_p, more)
|
246
|
+
result
|
247
|
+
end
|
248
|
+
|
249
|
+
# Return frame routing ID, if the frame came from a ZMQ_SERVER socket.
|
250
|
+
# Else returns zero.
|
251
|
+
#
|
252
|
+
# @return [Integer]
|
253
|
+
def routing_id()
|
254
|
+
raise DestroyedError unless @ptr
|
255
|
+
self_p = @ptr
|
256
|
+
result = ::CZMQ::FFI.zframe_routing_id(self_p)
|
257
|
+
result
|
258
|
+
end
|
259
|
+
|
260
|
+
# Set routing ID on frame. This is used if/when the frame is sent to a
|
261
|
+
# ZMQ_SERVER socket.
|
262
|
+
#
|
263
|
+
# @param routing_id [Integer, #to_int, #to_i]
|
264
|
+
# @return [void]
|
265
|
+
def set_routing_id(routing_id)
|
266
|
+
raise DestroyedError unless @ptr
|
267
|
+
self_p = @ptr
|
268
|
+
routing_id = Integer(routing_id)
|
269
|
+
result = ::CZMQ::FFI.zframe_set_routing_id(self_p, routing_id)
|
270
|
+
result
|
271
|
+
end
|
272
|
+
|
273
|
+
# Return frame group of radio-dish pattern.
|
274
|
+
#
|
275
|
+
# @return [String]
|
276
|
+
def group()
|
277
|
+
raise DestroyedError unless @ptr
|
278
|
+
self_p = @ptr
|
279
|
+
result = ::CZMQ::FFI.zframe_group(self_p)
|
280
|
+
result
|
281
|
+
end
|
282
|
+
|
283
|
+
# Set group on frame. This is used if/when the frame is sent to a
|
284
|
+
# ZMQ_RADIO socket.
|
285
|
+
# Return -1 on error, 0 on success.
|
286
|
+
#
|
287
|
+
# @param group [String, #to_s, nil]
|
288
|
+
# @return [Integer]
|
289
|
+
def set_group(group)
|
290
|
+
raise DestroyedError unless @ptr
|
291
|
+
self_p = @ptr
|
292
|
+
result = ::CZMQ::FFI.zframe_set_group(self_p, group)
|
293
|
+
result
|
294
|
+
end
|
295
|
+
|
296
|
+
# Return TRUE if two frames have identical size and data
|
297
|
+
# If either frame is NULL, equality is always false.
|
298
|
+
#
|
299
|
+
# @param other [Zframe, #__ptr]
|
300
|
+
# @return [Boolean]
|
301
|
+
def eq(other)
|
302
|
+
raise DestroyedError unless @ptr
|
303
|
+
self_p = @ptr
|
304
|
+
other = other.__ptr if other
|
305
|
+
result = ::CZMQ::FFI.zframe_eq(self_p, other)
|
306
|
+
result
|
307
|
+
end
|
308
|
+
|
309
|
+
# Set new contents for frame
|
310
|
+
#
|
311
|
+
# @param data [::FFI::Pointer, #to_ptr]
|
312
|
+
# @param size [Integer, #to_int, #to_i]
|
313
|
+
# @return [void]
|
314
|
+
def reset(data, size)
|
315
|
+
raise DestroyedError unless @ptr
|
316
|
+
self_p = @ptr
|
317
|
+
size = Integer(size)
|
318
|
+
result = ::CZMQ::FFI.zframe_reset(self_p, data, size)
|
319
|
+
result
|
320
|
+
end
|
321
|
+
|
322
|
+
# Send message to zsys log sink (may be stdout, or system facility as
|
323
|
+
# configured by zsys_set_logstream). Prefix shows before frame, if not null.
|
324
|
+
#
|
325
|
+
# @param prefix [String, #to_s, nil]
|
326
|
+
# @return [void]
|
327
|
+
def print(prefix)
|
328
|
+
raise DestroyedError unless @ptr
|
329
|
+
self_p = @ptr
|
330
|
+
result = ::CZMQ::FFI.zframe_print(self_p, prefix)
|
331
|
+
result
|
332
|
+
end
|
333
|
+
|
334
|
+
# Probe the supplied object, and report if it looks like a zframe_t.
|
335
|
+
#
|
336
|
+
# @param self_ [::FFI::Pointer, #to_ptr]
|
337
|
+
# @return [Boolean]
|
338
|
+
def self.is(self_)
|
339
|
+
result = ::CZMQ::FFI.zframe_is(self_)
|
340
|
+
result
|
341
|
+
end
|
342
|
+
|
343
|
+
# Self test of this class.
|
344
|
+
#
|
345
|
+
# @param verbose [Boolean]
|
346
|
+
# @return [void]
|
347
|
+
def self.test(verbose)
|
348
|
+
verbose = !(0==verbose||!verbose) # boolean
|
349
|
+
result = ::CZMQ::FFI.zframe_test(verbose)
|
350
|
+
result
|
351
|
+
end
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
################################################################################
|
357
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
358
|
+
# Read the zproject/README.md for information about making permanent changes. #
|
359
|
+
################################################################################
|