czmq-ffi-gen 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/czmq-ffi-gen.rb +4 -0
- data/lib/czmq-ffi-gen/czmq/ffi.rb +558 -0
- data/lib/czmq-ffi-gen/czmq/ffi/version.rb +15 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zactor.rb +179 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zarmour.rb +259 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zconfig.rb +449 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zdir.rb +280 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zdir_patch.rb +182 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zfile.rb +347 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zframe.rb +311 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zhash.rb +421 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zhashx.rb +595 -0
- data/lib/czmq-ffi-gen/czmq/ffi/ziflist.rb +182 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zlist.rb +355 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zloop.rb +385 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zmsg.rb +512 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zpoller.rb +184 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zsock.rb +3242 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zstr.rb +201 -0
- data/lib/czmq-ffi-gen/czmq/ffi/ztrie.rb +217 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zuuid.rb +221 -0
- data/lib/czmq-ffi-gen/gem_version.rb +5 -0
- data/lib/czmq-ffi-gen/library_version.rb +5 -0
- metadata +138 -0
@@ -0,0 +1,449 @@
|
|
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
|
+
# zconfig - work with config files written in rfc.zeromq.org/spec:4/ZPL.
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Zconfig
|
12
|
+
# Raised when one tries to use an instance of {Zconfig} 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.zconfig_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
|
+
ObjectSpace.undefine_finalizer self if @finalizer
|
64
|
+
@finalizer = nil
|
65
|
+
@ptr = nil
|
66
|
+
ptr_ptr
|
67
|
+
end
|
68
|
+
|
69
|
+
# Create a new callback of the following type:
|
70
|
+
#
|
71
|
+
# typedef int (zconfig_fct) (
|
72
|
+
# zconfig_t *self, void *arg, int level);
|
73
|
+
#
|
74
|
+
# @note WARNING: If your Ruby code doesn't retain a reference to the
|
75
|
+
# FFI::Function object after passing it to a C function call,
|
76
|
+
# it may be garbage collected while C still holds the pointer,
|
77
|
+
# potentially resulting in a segmentation fault.
|
78
|
+
def self.fct
|
79
|
+
::FFI::Function.new :int, [:pointer, :pointer, :int], blocking: true do |self_, arg, level|
|
80
|
+
self_ = Zconfig.__new self_, false
|
81
|
+
result = yield self_, arg, level
|
82
|
+
result = Integer(result)
|
83
|
+
result
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Create new config item
|
88
|
+
# @param name [String, #to_str, #to_s]
|
89
|
+
# @param parent [Zconfig, #__ptr]
|
90
|
+
# @return [CZMQ::Zconfig]
|
91
|
+
def self.new(name, parent)
|
92
|
+
name = String(name)
|
93
|
+
parent = parent.__ptr if parent
|
94
|
+
ptr = ::CZMQ::FFI.zconfig_new(name, parent)
|
95
|
+
__new ptr
|
96
|
+
end
|
97
|
+
|
98
|
+
# Load a config tree from a specified ZPL text file; returns a zconfig_t
|
99
|
+
# reference for the root, if the file exists and is readable. Returns NULL
|
100
|
+
# if the file does not exist.
|
101
|
+
# @param filename [String, #to_str, #to_s]
|
102
|
+
# @return [CZMQ::Zconfig]
|
103
|
+
def self.load(filename)
|
104
|
+
filename = String(filename)
|
105
|
+
ptr = ::CZMQ::FFI.zconfig_load(filename)
|
106
|
+
__new ptr
|
107
|
+
end
|
108
|
+
|
109
|
+
# Equivalent to zconfig_load, taking a format string instead of a fixed
|
110
|
+
# filename.
|
111
|
+
# @param format [String, #to_str, #to_s]
|
112
|
+
# @param args [Array<Object>]
|
113
|
+
# @return [CZMQ::Zconfig]
|
114
|
+
def self.loadf(format, *args)
|
115
|
+
format = String(format)
|
116
|
+
ptr = ::CZMQ::FFI.zconfig_loadf(format, *args)
|
117
|
+
__new ptr
|
118
|
+
end
|
119
|
+
|
120
|
+
# Destroy a config item and all its children
|
121
|
+
#
|
122
|
+
# @return [void]
|
123
|
+
def destroy()
|
124
|
+
return unless @ptr
|
125
|
+
self_p = __ptr_give_ref
|
126
|
+
result = ::CZMQ::FFI.zconfig_destroy(self_p)
|
127
|
+
result
|
128
|
+
end
|
129
|
+
|
130
|
+
# Return name of config item
|
131
|
+
#
|
132
|
+
# @return [::FFI::Pointer]
|
133
|
+
def name()
|
134
|
+
raise DestroyedError unless @ptr
|
135
|
+
self_p = @ptr
|
136
|
+
result = ::CZMQ::FFI.zconfig_name(self_p)
|
137
|
+
result
|
138
|
+
end
|
139
|
+
|
140
|
+
# Return value of config item
|
141
|
+
#
|
142
|
+
# @return [::FFI::Pointer]
|
143
|
+
def value()
|
144
|
+
raise DestroyedError unless @ptr
|
145
|
+
self_p = @ptr
|
146
|
+
result = ::CZMQ::FFI.zconfig_value(self_p)
|
147
|
+
result
|
148
|
+
end
|
149
|
+
|
150
|
+
# Insert or update configuration key with value
|
151
|
+
#
|
152
|
+
# @param path [String, #to_str, #to_s]
|
153
|
+
# @param value [String, #to_str, #to_s]
|
154
|
+
# @return [void]
|
155
|
+
def put(path, value)
|
156
|
+
raise DestroyedError unless @ptr
|
157
|
+
self_p = @ptr
|
158
|
+
path = String(path)
|
159
|
+
value = String(value)
|
160
|
+
result = ::CZMQ::FFI.zconfig_put(self_p, path, value)
|
161
|
+
result
|
162
|
+
end
|
163
|
+
|
164
|
+
# Equivalent to zconfig_put, accepting a format specifier and variable
|
165
|
+
# argument list, instead of a single string value.
|
166
|
+
#
|
167
|
+
# @param path [String, #to_str, #to_s]
|
168
|
+
# @param format [String, #to_str, #to_s]
|
169
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
170
|
+
# @return [void]
|
171
|
+
def putf(path, format, *args)
|
172
|
+
raise DestroyedError unless @ptr
|
173
|
+
self_p = @ptr
|
174
|
+
path = String(path)
|
175
|
+
format = String(format)
|
176
|
+
result = ::CZMQ::FFI.zconfig_putf(self_p, path, format, *args)
|
177
|
+
result
|
178
|
+
end
|
179
|
+
|
180
|
+
# Get value for config item into a string value; leading slash is optional
|
181
|
+
# and ignored.
|
182
|
+
#
|
183
|
+
# @param path [String, #to_str, #to_s]
|
184
|
+
# @param default_value [String, #to_str, #to_s]
|
185
|
+
# @return [::FFI::Pointer]
|
186
|
+
def get(path, default_value)
|
187
|
+
raise DestroyedError unless @ptr
|
188
|
+
self_p = @ptr
|
189
|
+
path = String(path)
|
190
|
+
default_value = String(default_value)
|
191
|
+
result = ::CZMQ::FFI.zconfig_get(self_p, path, default_value)
|
192
|
+
result
|
193
|
+
end
|
194
|
+
|
195
|
+
# Set config item name, name may be NULL
|
196
|
+
#
|
197
|
+
# @param name [String, #to_str, #to_s]
|
198
|
+
# @return [void]
|
199
|
+
def set_name(name)
|
200
|
+
raise DestroyedError unless @ptr
|
201
|
+
self_p = @ptr
|
202
|
+
name = String(name)
|
203
|
+
result = ::CZMQ::FFI.zconfig_set_name(self_p, name)
|
204
|
+
result
|
205
|
+
end
|
206
|
+
|
207
|
+
# Set new value for config item. The new value may be a string, a printf
|
208
|
+
# format, or NULL. Note that if string may possibly contain '%', or if it
|
209
|
+
# comes from an insecure source, you must use '%s' as the format, followed
|
210
|
+
# by the string.
|
211
|
+
#
|
212
|
+
# @param format [String, #to_str, #to_s]
|
213
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
214
|
+
# @return [void]
|
215
|
+
def set_value(format, *args)
|
216
|
+
raise DestroyedError unless @ptr
|
217
|
+
self_p = @ptr
|
218
|
+
format = String(format)
|
219
|
+
result = ::CZMQ::FFI.zconfig_set_value(self_p, format, *args)
|
220
|
+
result
|
221
|
+
end
|
222
|
+
|
223
|
+
# Find our first child, if any
|
224
|
+
#
|
225
|
+
# @return [Zconfig]
|
226
|
+
def child()
|
227
|
+
raise DestroyedError unless @ptr
|
228
|
+
self_p = @ptr
|
229
|
+
result = ::CZMQ::FFI.zconfig_child(self_p)
|
230
|
+
result = Zconfig.__new result, false
|
231
|
+
result
|
232
|
+
end
|
233
|
+
|
234
|
+
# Find our first sibling, if any
|
235
|
+
#
|
236
|
+
# @return [Zconfig]
|
237
|
+
def next()
|
238
|
+
raise DestroyedError unless @ptr
|
239
|
+
self_p = @ptr
|
240
|
+
result = ::CZMQ::FFI.zconfig_next(self_p)
|
241
|
+
result = Zconfig.__new result, false
|
242
|
+
result
|
243
|
+
end
|
244
|
+
|
245
|
+
# Find a config item along a path; leading slash is optional and ignored.
|
246
|
+
#
|
247
|
+
# @param path [String, #to_str, #to_s]
|
248
|
+
# @return [Zconfig]
|
249
|
+
def locate(path)
|
250
|
+
raise DestroyedError unless @ptr
|
251
|
+
self_p = @ptr
|
252
|
+
path = String(path)
|
253
|
+
result = ::CZMQ::FFI.zconfig_locate(self_p, path)
|
254
|
+
result = Zconfig.__new result, false
|
255
|
+
result
|
256
|
+
end
|
257
|
+
|
258
|
+
# Locate the last config item at a specified depth
|
259
|
+
#
|
260
|
+
# @param level [Integer, #to_int, #to_i]
|
261
|
+
# @return [Zconfig]
|
262
|
+
def at_depth(level)
|
263
|
+
raise DestroyedError unless @ptr
|
264
|
+
self_p = @ptr
|
265
|
+
level = Integer(level)
|
266
|
+
result = ::CZMQ::FFI.zconfig_at_depth(self_p, level)
|
267
|
+
result = Zconfig.__new result, false
|
268
|
+
result
|
269
|
+
end
|
270
|
+
|
271
|
+
# Execute a callback for each config item in the tree; returns zero if
|
272
|
+
# successful, else -1.
|
273
|
+
#
|
274
|
+
# @param handler [::FFI::Pointer, #to_ptr]
|
275
|
+
# @param arg [::FFI::Pointer, #to_ptr]
|
276
|
+
# @return [Integer]
|
277
|
+
def execute(handler, arg)
|
278
|
+
raise DestroyedError unless @ptr
|
279
|
+
self_p = @ptr
|
280
|
+
result = ::CZMQ::FFI.zconfig_execute(self_p, handler, arg)
|
281
|
+
result
|
282
|
+
end
|
283
|
+
|
284
|
+
# Add comment to config item before saving to disk. You can add as many
|
285
|
+
# comment lines as you like. If you use a null format, all comments are
|
286
|
+
# deleted.
|
287
|
+
#
|
288
|
+
# @param format [String, #to_str, #to_s]
|
289
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
290
|
+
# @return [void]
|
291
|
+
def set_comment(format, *args)
|
292
|
+
raise DestroyedError unless @ptr
|
293
|
+
self_p = @ptr
|
294
|
+
format = String(format)
|
295
|
+
result = ::CZMQ::FFI.zconfig_set_comment(self_p, format, *args)
|
296
|
+
result
|
297
|
+
end
|
298
|
+
|
299
|
+
# Return comments of config item, as zlist.
|
300
|
+
#
|
301
|
+
# @return [Zlist]
|
302
|
+
def comments()
|
303
|
+
raise DestroyedError unless @ptr
|
304
|
+
self_p = @ptr
|
305
|
+
result = ::CZMQ::FFI.zconfig_comments(self_p)
|
306
|
+
result = Zlist.__new result, false
|
307
|
+
result
|
308
|
+
end
|
309
|
+
|
310
|
+
# Save a config tree to a specified ZPL text file, where a filename
|
311
|
+
# "-" means dump to standard output.
|
312
|
+
#
|
313
|
+
# @param filename [String, #to_str, #to_s]
|
314
|
+
# @return [Integer]
|
315
|
+
def save(filename)
|
316
|
+
raise DestroyedError unless @ptr
|
317
|
+
self_p = @ptr
|
318
|
+
filename = String(filename)
|
319
|
+
result = ::CZMQ::FFI.zconfig_save(self_p, filename)
|
320
|
+
result
|
321
|
+
end
|
322
|
+
|
323
|
+
# Equivalent to zconfig_save, taking a format string instead of a fixed
|
324
|
+
# filename.
|
325
|
+
#
|
326
|
+
# @param format [String, #to_str, #to_s]
|
327
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
328
|
+
# @return [Integer]
|
329
|
+
def savef(format, *args)
|
330
|
+
raise DestroyedError unless @ptr
|
331
|
+
self_p = @ptr
|
332
|
+
format = String(format)
|
333
|
+
result = ::CZMQ::FFI.zconfig_savef(self_p, format, *args)
|
334
|
+
result
|
335
|
+
end
|
336
|
+
|
337
|
+
# Report filename used during zconfig_load, or NULL if none
|
338
|
+
#
|
339
|
+
# @return [String]
|
340
|
+
def filename()
|
341
|
+
raise DestroyedError unless @ptr
|
342
|
+
self_p = @ptr
|
343
|
+
result = ::CZMQ::FFI.zconfig_filename(self_p)
|
344
|
+
result
|
345
|
+
end
|
346
|
+
|
347
|
+
# Reload config tree from same file that it was previously loaded from.
|
348
|
+
# Returns 0 if OK, -1 if there was an error (and then does not change
|
349
|
+
# existing data).
|
350
|
+
#
|
351
|
+
# @param self_p [#__ptr_give_ref]
|
352
|
+
# @return [Integer]
|
353
|
+
def self.reload(self_p)
|
354
|
+
self_p = self_p.__ptr_give_ref
|
355
|
+
result = ::CZMQ::FFI.zconfig_reload(self_p)
|
356
|
+
result
|
357
|
+
end
|
358
|
+
|
359
|
+
# Load a config tree from a memory chunk
|
360
|
+
#
|
361
|
+
# @param chunk [::FFI::Pointer, #to_ptr]
|
362
|
+
# @return [Zconfig]
|
363
|
+
def self.chunk_load(chunk)
|
364
|
+
result = ::CZMQ::FFI.zconfig_chunk_load(chunk)
|
365
|
+
result = Zconfig.__new result, false
|
366
|
+
result
|
367
|
+
end
|
368
|
+
|
369
|
+
# Save a config tree to a new memory chunk
|
370
|
+
#
|
371
|
+
# @return [::FFI::Pointer]
|
372
|
+
def chunk_save()
|
373
|
+
raise DestroyedError unless @ptr
|
374
|
+
self_p = @ptr
|
375
|
+
result = ::CZMQ::FFI.zconfig_chunk_save(self_p)
|
376
|
+
result
|
377
|
+
end
|
378
|
+
|
379
|
+
# Load a config tree from a null-terminated string
|
380
|
+
#
|
381
|
+
# @param string [String, #to_str, #to_s]
|
382
|
+
# @return [Zconfig]
|
383
|
+
def self.str_load(string)
|
384
|
+
string = String(string)
|
385
|
+
result = ::CZMQ::FFI.zconfig_str_load(string)
|
386
|
+
result = Zconfig.__new result, true
|
387
|
+
result
|
388
|
+
end
|
389
|
+
|
390
|
+
# Save a config tree to a new null terminated string
|
391
|
+
#
|
392
|
+
# @return [::FFI::AutoPointer]
|
393
|
+
def str_save()
|
394
|
+
raise DestroyedError unless @ptr
|
395
|
+
self_p = @ptr
|
396
|
+
result = ::CZMQ::FFI.zconfig_str_save(self_p)
|
397
|
+
result = ::FFI::AutoPointer.new(result, LibC.method(:free))
|
398
|
+
result
|
399
|
+
end
|
400
|
+
|
401
|
+
# Return true if a configuration tree was loaded from a file and that
|
402
|
+
# file has changed in since the tree was loaded.
|
403
|
+
#
|
404
|
+
# @return [Boolean]
|
405
|
+
def has_changed()
|
406
|
+
raise DestroyedError unless @ptr
|
407
|
+
self_p = @ptr
|
408
|
+
result = ::CZMQ::FFI.zconfig_has_changed(self_p)
|
409
|
+
result
|
410
|
+
end
|
411
|
+
|
412
|
+
# Print the config file to open stream
|
413
|
+
#
|
414
|
+
# @param file [::FFI::Pointer, #to_ptr]
|
415
|
+
# @return [void]
|
416
|
+
def fprint(file)
|
417
|
+
raise DestroyedError unless @ptr
|
418
|
+
self_p = @ptr
|
419
|
+
result = ::CZMQ::FFI.zconfig_fprint(self_p, file)
|
420
|
+
result
|
421
|
+
end
|
422
|
+
|
423
|
+
# Print properties of object
|
424
|
+
#
|
425
|
+
# @return [void]
|
426
|
+
def print()
|
427
|
+
raise DestroyedError unless @ptr
|
428
|
+
self_p = @ptr
|
429
|
+
result = ::CZMQ::FFI.zconfig_print(self_p)
|
430
|
+
result
|
431
|
+
end
|
432
|
+
|
433
|
+
# Self test of this class
|
434
|
+
#
|
435
|
+
# @param verbose [Boolean]
|
436
|
+
# @return [void]
|
437
|
+
def self.test(verbose)
|
438
|
+
verbose = !(0==verbose||!verbose) # boolean
|
439
|
+
result = ::CZMQ::FFI.zconfig_test(verbose)
|
440
|
+
result
|
441
|
+
end
|
442
|
+
end
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
446
|
+
################################################################################
|
447
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
448
|
+
# Please refer to the README for information about making permanent changes. #
|
449
|
+
################################################################################
|
@@ -0,0 +1,280 @@
|
|
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
|
+
# work with file-system directories
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Zdir
|
12
|
+
# Raised when one tries to use an instance of {Zdir} 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.zdir_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
|
+
ObjectSpace.undefine_finalizer self if @finalizer
|
64
|
+
@finalizer = nil
|
65
|
+
@ptr = nil
|
66
|
+
ptr_ptr
|
67
|
+
end
|
68
|
+
|
69
|
+
# Create a new directory item that loads in the full tree of the specified
|
70
|
+
# path, optionally located under some parent path. If parent is "-", then
|
71
|
+
# loads only the top-level directory, and does not use parent as a path.
|
72
|
+
# @param path [String, #to_str, #to_s]
|
73
|
+
# @param parent [String, #to_str, #to_s]
|
74
|
+
# @return [CZMQ::Zdir]
|
75
|
+
def self.new(path, parent)
|
76
|
+
path = String(path)
|
77
|
+
parent = String(parent)
|
78
|
+
ptr = ::CZMQ::FFI.zdir_new(path, parent)
|
79
|
+
__new ptr
|
80
|
+
end
|
81
|
+
|
82
|
+
# Destroy a directory tree and all children it contains.
|
83
|
+
#
|
84
|
+
# @return [void]
|
85
|
+
def destroy()
|
86
|
+
return unless @ptr
|
87
|
+
self_p = __ptr_give_ref
|
88
|
+
result = ::CZMQ::FFI.zdir_destroy(self_p)
|
89
|
+
result
|
90
|
+
end
|
91
|
+
|
92
|
+
# Return directory path
|
93
|
+
#
|
94
|
+
# @return [String]
|
95
|
+
def path()
|
96
|
+
raise DestroyedError unless @ptr
|
97
|
+
self_p = @ptr
|
98
|
+
result = ::CZMQ::FFI.zdir_path(self_p)
|
99
|
+
result
|
100
|
+
end
|
101
|
+
|
102
|
+
# Return last modification time for directory.
|
103
|
+
#
|
104
|
+
# @return [::FFI::Pointer]
|
105
|
+
def modified()
|
106
|
+
raise DestroyedError unless @ptr
|
107
|
+
self_p = @ptr
|
108
|
+
result = ::CZMQ::FFI.zdir_modified(self_p)
|
109
|
+
result
|
110
|
+
end
|
111
|
+
|
112
|
+
# Return total hierarchy size, in bytes of data contained in all files
|
113
|
+
# in the directory tree.
|
114
|
+
#
|
115
|
+
# @return [::FFI::Pointer]
|
116
|
+
def cursize()
|
117
|
+
raise DestroyedError unless @ptr
|
118
|
+
self_p = @ptr
|
119
|
+
result = ::CZMQ::FFI.zdir_cursize(self_p)
|
120
|
+
result
|
121
|
+
end
|
122
|
+
|
123
|
+
# Return directory count
|
124
|
+
#
|
125
|
+
# @return [Integer]
|
126
|
+
def count()
|
127
|
+
raise DestroyedError unless @ptr
|
128
|
+
self_p = @ptr
|
129
|
+
result = ::CZMQ::FFI.zdir_count(self_p)
|
130
|
+
result
|
131
|
+
end
|
132
|
+
|
133
|
+
# Returns a sorted list of zfile objects; Each entry in the list is a pointer
|
134
|
+
# to a zfile_t item already allocated in the zdir tree. Do not destroy the
|
135
|
+
# original zdir tree until you are done with this list.
|
136
|
+
#
|
137
|
+
# @return [Zlist]
|
138
|
+
def list()
|
139
|
+
raise DestroyedError unless @ptr
|
140
|
+
self_p = @ptr
|
141
|
+
result = ::CZMQ::FFI.zdir_list(self_p)
|
142
|
+
result = Zlist.__new result, true
|
143
|
+
result
|
144
|
+
end
|
145
|
+
|
146
|
+
# Remove directory, optionally including all files that it contains, at
|
147
|
+
# all levels. If force is false, will only remove the directory if empty.
|
148
|
+
# If force is true, will remove all files and all subdirectories.
|
149
|
+
#
|
150
|
+
# @param force [Boolean]
|
151
|
+
# @return [void]
|
152
|
+
def remove(force)
|
153
|
+
raise DestroyedError unless @ptr
|
154
|
+
self_p = @ptr
|
155
|
+
force = !(0==force||!force) # boolean
|
156
|
+
result = ::CZMQ::FFI.zdir_remove(self_p, force)
|
157
|
+
result
|
158
|
+
end
|
159
|
+
|
160
|
+
# Calculate differences between two versions of a directory tree.
|
161
|
+
# Returns a list of zdir_patch_t patches. Either older or newer may
|
162
|
+
# be null, indicating the directory is empty/absent. If alias is set,
|
163
|
+
# generates virtual filename (minus path, plus alias).
|
164
|
+
#
|
165
|
+
# @param older [Zdir, #__ptr]
|
166
|
+
# @param newer [Zdir, #__ptr]
|
167
|
+
# @param alias_ [String, #to_str, #to_s]
|
168
|
+
# @return [Zlist]
|
169
|
+
def self.diff(older, newer, alias_)
|
170
|
+
older = older.__ptr if older
|
171
|
+
newer = newer.__ptr if newer
|
172
|
+
alias_ = String(alias_)
|
173
|
+
result = ::CZMQ::FFI.zdir_diff(older, newer, alias_)
|
174
|
+
result = Zlist.__new result, true
|
175
|
+
result
|
176
|
+
end
|
177
|
+
|
178
|
+
# Return full contents of directory as a zdir_patch list.
|
179
|
+
#
|
180
|
+
# @param alias_ [String, #to_str, #to_s]
|
181
|
+
# @return [Zlist]
|
182
|
+
def resync(alias_)
|
183
|
+
raise DestroyedError unless @ptr
|
184
|
+
self_p = @ptr
|
185
|
+
alias_ = String(alias_)
|
186
|
+
result = ::CZMQ::FFI.zdir_resync(self_p, alias_)
|
187
|
+
result = Zlist.__new result, true
|
188
|
+
result
|
189
|
+
end
|
190
|
+
|
191
|
+
# Load directory cache; returns a hash table containing the SHA-1 digests
|
192
|
+
# of every file in the tree. The cache is saved between runs in .cache.
|
193
|
+
#
|
194
|
+
# @return [Zhash]
|
195
|
+
def cache()
|
196
|
+
raise DestroyedError unless @ptr
|
197
|
+
self_p = @ptr
|
198
|
+
result = ::CZMQ::FFI.zdir_cache(self_p)
|
199
|
+
result = Zhash.__new result, true
|
200
|
+
result
|
201
|
+
end
|
202
|
+
|
203
|
+
# Print contents of directory to open stream
|
204
|
+
#
|
205
|
+
# @param file [::FFI::Pointer, #to_ptr]
|
206
|
+
# @param indent [Integer, #to_int, #to_i]
|
207
|
+
# @return [void]
|
208
|
+
def fprint(file, indent)
|
209
|
+
raise DestroyedError unless @ptr
|
210
|
+
self_p = @ptr
|
211
|
+
indent = Integer(indent)
|
212
|
+
result = ::CZMQ::FFI.zdir_fprint(self_p, file, indent)
|
213
|
+
result
|
214
|
+
end
|
215
|
+
|
216
|
+
# Print contents of directory to stdout
|
217
|
+
#
|
218
|
+
# @param indent [Integer, #to_int, #to_i]
|
219
|
+
# @return [void]
|
220
|
+
def print(indent)
|
221
|
+
raise DestroyedError unless @ptr
|
222
|
+
self_p = @ptr
|
223
|
+
indent = Integer(indent)
|
224
|
+
result = ::CZMQ::FFI.zdir_print(self_p, indent)
|
225
|
+
result
|
226
|
+
end
|
227
|
+
|
228
|
+
# Create a new zdir_watch actor instance:
|
229
|
+
#
|
230
|
+
# zactor_t *watch = zactor_new (zdir_watch, NULL);
|
231
|
+
#
|
232
|
+
# Destroy zdir_watch instance:
|
233
|
+
#
|
234
|
+
# zactor_destroy (&watch);
|
235
|
+
#
|
236
|
+
# Enable verbose logging of commands and activity:
|
237
|
+
#
|
238
|
+
# zstr_send (watch, "VERBOSE");
|
239
|
+
#
|
240
|
+
# Subscribe to changes to a directory path:
|
241
|
+
#
|
242
|
+
# zsock_send (watch, "ss", "SUBSCRIBE", "directory_path");
|
243
|
+
#
|
244
|
+
# Unsubscribe from changes to a directory path:
|
245
|
+
#
|
246
|
+
# zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path");
|
247
|
+
#
|
248
|
+
# Receive directory changes:
|
249
|
+
# zsock_recv (watch, "sp", &path, &patches);
|
250
|
+
#
|
251
|
+
# // Delete the received data.
|
252
|
+
# free (path);
|
253
|
+
# zlist_destroy (&patches);
|
254
|
+
#
|
255
|
+
# @param pipe [Zsock, #__ptr]
|
256
|
+
# @param unused [::FFI::Pointer, #to_ptr]
|
257
|
+
# @return [void]
|
258
|
+
def self.watch(pipe, unused)
|
259
|
+
pipe = pipe.__ptr if pipe
|
260
|
+
result = ::CZMQ::FFI.zdir_watch(pipe, unused)
|
261
|
+
result
|
262
|
+
end
|
263
|
+
|
264
|
+
# Self test of this class.
|
265
|
+
#
|
266
|
+
# @param verbose [Boolean]
|
267
|
+
# @return [void]
|
268
|
+
def self.test(verbose)
|
269
|
+
verbose = !(0==verbose||!verbose) # boolean
|
270
|
+
result = ::CZMQ::FFI.zdir_test(verbose)
|
271
|
+
result
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
################################################################################
|
278
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
279
|
+
# Please refer to the README for information about making permanent changes. #
|
280
|
+
################################################################################
|