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
@@ -0,0 +1,429 @@
|
|
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
|
+
# extended generic list container
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Zlistx
|
12
|
+
# Raised when one tries to use an instance of {Zlistx} 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.zlistx_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, empty list.
|
77
|
+
# @return [CZMQ::Zlistx]
|
78
|
+
def self.new()
|
79
|
+
ptr = ::CZMQ::FFI.zlistx_new()
|
80
|
+
__new ptr
|
81
|
+
end
|
82
|
+
|
83
|
+
# Destroy a list. If an item destructor was specified, all items in the
|
84
|
+
# list are automatically destroyed as well.
|
85
|
+
#
|
86
|
+
# @return [void]
|
87
|
+
def destroy()
|
88
|
+
return unless @ptr
|
89
|
+
self_p = __ptr_give_ref
|
90
|
+
result = ::CZMQ::FFI.zlistx_destroy(self_p)
|
91
|
+
result
|
92
|
+
end
|
93
|
+
|
94
|
+
# Add an item to the head of the list. Calls the item duplicator, if any,
|
95
|
+
# on the item. Resets cursor to list head. Returns an item handle on
|
96
|
+
# success, NULL if memory was exhausted.
|
97
|
+
#
|
98
|
+
# @param item [::FFI::Pointer, #to_ptr]
|
99
|
+
# @return [::FFI::Pointer]
|
100
|
+
def add_start(item)
|
101
|
+
raise DestroyedError unless @ptr
|
102
|
+
self_p = @ptr
|
103
|
+
result = ::CZMQ::FFI.zlistx_add_start(self_p, item)
|
104
|
+
result
|
105
|
+
end
|
106
|
+
|
107
|
+
# Add an item to the tail of the list. Calls the item duplicator, if any,
|
108
|
+
# on the item. Resets cursor to list head. Returns an item handle on
|
109
|
+
# success, NULL if memory was exhausted.
|
110
|
+
#
|
111
|
+
# @param item [::FFI::Pointer, #to_ptr]
|
112
|
+
# @return [::FFI::Pointer]
|
113
|
+
def add_end(item)
|
114
|
+
raise DestroyedError unless @ptr
|
115
|
+
self_p = @ptr
|
116
|
+
result = ::CZMQ::FFI.zlistx_add_end(self_p, item)
|
117
|
+
result
|
118
|
+
end
|
119
|
+
|
120
|
+
# Return the number of items in the list
|
121
|
+
#
|
122
|
+
# @return [Integer]
|
123
|
+
def size()
|
124
|
+
raise DestroyedError unless @ptr
|
125
|
+
self_p = @ptr
|
126
|
+
result = ::CZMQ::FFI.zlistx_size(self_p)
|
127
|
+
result
|
128
|
+
end
|
129
|
+
|
130
|
+
# Return first item in the list, or null, leaves the cursor
|
131
|
+
#
|
132
|
+
# @return [::FFI::Pointer]
|
133
|
+
def head()
|
134
|
+
raise DestroyedError unless @ptr
|
135
|
+
self_p = @ptr
|
136
|
+
result = ::CZMQ::FFI.zlistx_head(self_p)
|
137
|
+
result
|
138
|
+
end
|
139
|
+
|
140
|
+
# Return last item in the list, or null, leaves the cursor
|
141
|
+
#
|
142
|
+
# @return [::FFI::Pointer]
|
143
|
+
def tail()
|
144
|
+
raise DestroyedError unless @ptr
|
145
|
+
self_p = @ptr
|
146
|
+
result = ::CZMQ::FFI.zlistx_tail(self_p)
|
147
|
+
result
|
148
|
+
end
|
149
|
+
|
150
|
+
# Return the item at the head of list. If the list is empty, returns NULL.
|
151
|
+
# Leaves cursor pointing at the head item, or NULL if the list is empty.
|
152
|
+
#
|
153
|
+
# @return [::FFI::Pointer]
|
154
|
+
def first()
|
155
|
+
raise DestroyedError unless @ptr
|
156
|
+
self_p = @ptr
|
157
|
+
result = ::CZMQ::FFI.zlistx_first(self_p)
|
158
|
+
result
|
159
|
+
end
|
160
|
+
|
161
|
+
# Return the next item. At the end of the list (or in an empty list),
|
162
|
+
# returns NULL. Use repeated zlistx_next () calls to work through the list
|
163
|
+
# from zlistx_first (). First time, acts as zlistx_first().
|
164
|
+
#
|
165
|
+
# @return [::FFI::Pointer]
|
166
|
+
def next()
|
167
|
+
raise DestroyedError unless @ptr
|
168
|
+
self_p = @ptr
|
169
|
+
result = ::CZMQ::FFI.zlistx_next(self_p)
|
170
|
+
result
|
171
|
+
end
|
172
|
+
|
173
|
+
# Return the previous item. At the start of the list (or in an empty list),
|
174
|
+
# returns NULL. Use repeated zlistx_prev () calls to work through the list
|
175
|
+
# backwards from zlistx_last (). First time, acts as zlistx_last().
|
176
|
+
#
|
177
|
+
# @return [::FFI::Pointer]
|
178
|
+
def prev()
|
179
|
+
raise DestroyedError unless @ptr
|
180
|
+
self_p = @ptr
|
181
|
+
result = ::CZMQ::FFI.zlistx_prev(self_p)
|
182
|
+
result
|
183
|
+
end
|
184
|
+
|
185
|
+
# Return the item at the tail of list. If the list is empty, returns NULL.
|
186
|
+
# Leaves cursor pointing at the tail item, or NULL if the list is empty.
|
187
|
+
#
|
188
|
+
# @return [::FFI::Pointer]
|
189
|
+
def last()
|
190
|
+
raise DestroyedError unless @ptr
|
191
|
+
self_p = @ptr
|
192
|
+
result = ::CZMQ::FFI.zlistx_last(self_p)
|
193
|
+
result
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns the value of the item at the cursor, or NULL if the cursor is
|
197
|
+
# not pointing to an item.
|
198
|
+
#
|
199
|
+
# @return [::FFI::Pointer]
|
200
|
+
def item()
|
201
|
+
raise DestroyedError unless @ptr
|
202
|
+
self_p = @ptr
|
203
|
+
result = ::CZMQ::FFI.zlistx_item(self_p)
|
204
|
+
result
|
205
|
+
end
|
206
|
+
|
207
|
+
# Returns the handle of the item at the cursor, or NULL if the cursor is
|
208
|
+
# not pointing to an item.
|
209
|
+
#
|
210
|
+
# @return [::FFI::Pointer]
|
211
|
+
def cursor()
|
212
|
+
raise DestroyedError unless @ptr
|
213
|
+
self_p = @ptr
|
214
|
+
result = ::CZMQ::FFI.zlistx_cursor(self_p)
|
215
|
+
result
|
216
|
+
end
|
217
|
+
|
218
|
+
# Returns the item associated with the given list handle, or NULL if passed
|
219
|
+
# in handle is NULL. Asserts that the passed in handle points to a list element.
|
220
|
+
#
|
221
|
+
# @param handle [::FFI::Pointer, #to_ptr]
|
222
|
+
# @return [::FFI::Pointer]
|
223
|
+
def self.handle_item(handle)
|
224
|
+
result = ::CZMQ::FFI.zlistx_handle_item(handle)
|
225
|
+
result
|
226
|
+
end
|
227
|
+
|
228
|
+
# Find an item in the list, searching from the start. Uses the item
|
229
|
+
# comparator, if any, else compares item values directly. Returns the
|
230
|
+
# item handle found, or NULL. Sets the cursor to the found item, if any.
|
231
|
+
#
|
232
|
+
# @param item [::FFI::Pointer, #to_ptr]
|
233
|
+
# @return [::FFI::Pointer]
|
234
|
+
def find(item)
|
235
|
+
raise DestroyedError unless @ptr
|
236
|
+
self_p = @ptr
|
237
|
+
result = ::CZMQ::FFI.zlistx_find(self_p, item)
|
238
|
+
result
|
239
|
+
end
|
240
|
+
|
241
|
+
# Detach an item from the list, using its handle. The item is not modified,
|
242
|
+
# and the caller is responsible for destroying it if necessary. If handle is
|
243
|
+
# null, detaches the first item on the list. Returns item that was detached,
|
244
|
+
# or null if none was. If cursor was at item, moves cursor to previous item,
|
245
|
+
# so you can detach items while iterating forwards through a list.
|
246
|
+
#
|
247
|
+
# @param handle [::FFI::Pointer, #to_ptr]
|
248
|
+
# @return [::FFI::Pointer]
|
249
|
+
def detach(handle)
|
250
|
+
raise DestroyedError unless @ptr
|
251
|
+
self_p = @ptr
|
252
|
+
result = ::CZMQ::FFI.zlistx_detach(self_p, handle)
|
253
|
+
result
|
254
|
+
end
|
255
|
+
|
256
|
+
# Detach item at the cursor, if any, from the list. The item is not modified,
|
257
|
+
# and the caller is responsible for destroying it as necessary. Returns item
|
258
|
+
# that was detached, or null if none was. Moves cursor to previous item, so
|
259
|
+
# you can detach items while iterating forwards through a list.
|
260
|
+
#
|
261
|
+
# @return [::FFI::Pointer]
|
262
|
+
def detach_cur()
|
263
|
+
raise DestroyedError unless @ptr
|
264
|
+
self_p = @ptr
|
265
|
+
result = ::CZMQ::FFI.zlistx_detach_cur(self_p)
|
266
|
+
result
|
267
|
+
end
|
268
|
+
|
269
|
+
# Delete an item, using its handle. Calls the item destructor is any is
|
270
|
+
# set. If handle is null, deletes the first item on the list. Returns 0
|
271
|
+
# if an item was deleted, -1 if not. If cursor was at item, moves cursor
|
272
|
+
# to previous item, so you can delete items while iterating forwards
|
273
|
+
# through a list.
|
274
|
+
#
|
275
|
+
# @param handle [::FFI::Pointer, #to_ptr]
|
276
|
+
# @return [Integer]
|
277
|
+
def delete(handle)
|
278
|
+
raise DestroyedError unless @ptr
|
279
|
+
self_p = @ptr
|
280
|
+
result = ::CZMQ::FFI.zlistx_delete(self_p, handle)
|
281
|
+
result
|
282
|
+
end
|
283
|
+
|
284
|
+
# Move an item to the start of the list, via its handle.
|
285
|
+
#
|
286
|
+
# @param handle [::FFI::Pointer, #to_ptr]
|
287
|
+
# @return [void]
|
288
|
+
def move_start(handle)
|
289
|
+
raise DestroyedError unless @ptr
|
290
|
+
self_p = @ptr
|
291
|
+
result = ::CZMQ::FFI.zlistx_move_start(self_p, handle)
|
292
|
+
result
|
293
|
+
end
|
294
|
+
|
295
|
+
# Move an item to the end of the list, via its handle.
|
296
|
+
#
|
297
|
+
# @param handle [::FFI::Pointer, #to_ptr]
|
298
|
+
# @return [void]
|
299
|
+
def move_end(handle)
|
300
|
+
raise DestroyedError unless @ptr
|
301
|
+
self_p = @ptr
|
302
|
+
result = ::CZMQ::FFI.zlistx_move_end(self_p, handle)
|
303
|
+
result
|
304
|
+
end
|
305
|
+
|
306
|
+
# Remove all items from the list, and destroy them if the item destructor
|
307
|
+
# is set.
|
308
|
+
#
|
309
|
+
# @return [void]
|
310
|
+
def purge()
|
311
|
+
raise DestroyedError unless @ptr
|
312
|
+
self_p = @ptr
|
313
|
+
result = ::CZMQ::FFI.zlistx_purge(self_p)
|
314
|
+
result
|
315
|
+
end
|
316
|
+
|
317
|
+
# Sort the list. If an item comparator was set, calls that to compare
|
318
|
+
# items, otherwise compares on item value. The sort is not stable, so may
|
319
|
+
# reorder equal items.
|
320
|
+
#
|
321
|
+
# @return [void]
|
322
|
+
def sort()
|
323
|
+
raise DestroyedError unless @ptr
|
324
|
+
self_p = @ptr
|
325
|
+
result = ::CZMQ::FFI.zlistx_sort(self_p)
|
326
|
+
result
|
327
|
+
end
|
328
|
+
|
329
|
+
# Create a new node and insert it into a sorted list. Calls the item
|
330
|
+
# duplicator, if any, on the item. If low_value is true, starts searching
|
331
|
+
# from the start of the list, otherwise searches from the end. Use the item
|
332
|
+
# comparator, if any, to find where to place the new node. Returns a handle
|
333
|
+
# to the new node, or NULL if memory was exhausted. Resets the cursor to the
|
334
|
+
# list head.
|
335
|
+
#
|
336
|
+
# @param item [::FFI::Pointer, #to_ptr]
|
337
|
+
# @param low_value [Boolean]
|
338
|
+
# @return [::FFI::Pointer]
|
339
|
+
def insert(item, low_value)
|
340
|
+
raise DestroyedError unless @ptr
|
341
|
+
self_p = @ptr
|
342
|
+
low_value = !(0==low_value||!low_value) # boolean
|
343
|
+
result = ::CZMQ::FFI.zlistx_insert(self_p, item, low_value)
|
344
|
+
result
|
345
|
+
end
|
346
|
+
|
347
|
+
# Move an item, specified by handle, into position in a sorted list. Uses
|
348
|
+
# the item comparator, if any, to determine the new location. If low_value
|
349
|
+
# is true, starts searching from the start of the list, otherwise searches
|
350
|
+
# from the end.
|
351
|
+
#
|
352
|
+
# @param handle [::FFI::Pointer, #to_ptr]
|
353
|
+
# @param low_value [Boolean]
|
354
|
+
# @return [void]
|
355
|
+
def reorder(handle, low_value)
|
356
|
+
raise DestroyedError unless @ptr
|
357
|
+
self_p = @ptr
|
358
|
+
low_value = !(0==low_value||!low_value) # boolean
|
359
|
+
result = ::CZMQ::FFI.zlistx_reorder(self_p, handle, low_value)
|
360
|
+
result
|
361
|
+
end
|
362
|
+
|
363
|
+
# Make a copy of the list; items are duplicated if you set a duplicator
|
364
|
+
# for the list, otherwise not. Copying a null reference returns a null
|
365
|
+
# reference.
|
366
|
+
#
|
367
|
+
# @return [Zlistx]
|
368
|
+
def dup()
|
369
|
+
raise DestroyedError unless @ptr
|
370
|
+
self_p = @ptr
|
371
|
+
result = ::CZMQ::FFI.zlistx_dup(self_p)
|
372
|
+
result = Zlistx.__new result, false
|
373
|
+
result
|
374
|
+
end
|
375
|
+
|
376
|
+
# Set a user-defined deallocator for list items; by default items are not
|
377
|
+
# freed when the list is destroyed.
|
378
|
+
#
|
379
|
+
# @param destructor [::FFI::Pointer, #to_ptr]
|
380
|
+
# @return [void]
|
381
|
+
def set_destructor(destructor)
|
382
|
+
raise DestroyedError unless @ptr
|
383
|
+
self_p = @ptr
|
384
|
+
result = ::CZMQ::FFI.zlistx_set_destructor(self_p, destructor)
|
385
|
+
result
|
386
|
+
end
|
387
|
+
|
388
|
+
# Set a user-defined duplicator for list items; by default items are not
|
389
|
+
# copied when the list is duplicated.
|
390
|
+
#
|
391
|
+
# @param duplicator [::FFI::Pointer, #to_ptr]
|
392
|
+
# @return [void]
|
393
|
+
def set_duplicator(duplicator)
|
394
|
+
raise DestroyedError unless @ptr
|
395
|
+
self_p = @ptr
|
396
|
+
result = ::CZMQ::FFI.zlistx_set_duplicator(self_p, duplicator)
|
397
|
+
result
|
398
|
+
end
|
399
|
+
|
400
|
+
# Set a user-defined comparator for zlistx_find and zlistx_sort; the method
|
401
|
+
# must return -1, 0, or 1 depending on whether item1 is less than, equal to,
|
402
|
+
# or greater than, item2.
|
403
|
+
#
|
404
|
+
# @param comparator [::FFI::Pointer, #to_ptr]
|
405
|
+
# @return [void]
|
406
|
+
def set_comparator(comparator)
|
407
|
+
raise DestroyedError unless @ptr
|
408
|
+
self_p = @ptr
|
409
|
+
result = ::CZMQ::FFI.zlistx_set_comparator(self_p, comparator)
|
410
|
+
result
|
411
|
+
end
|
412
|
+
|
413
|
+
# Self test of this class.
|
414
|
+
#
|
415
|
+
# @param verbose [Boolean]
|
416
|
+
# @return [void]
|
417
|
+
def self.test(verbose)
|
418
|
+
verbose = !(0==verbose||!verbose) # boolean
|
419
|
+
result = ::CZMQ::FFI.zlistx_test(verbose)
|
420
|
+
result
|
421
|
+
end
|
422
|
+
end
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
################################################################################
|
427
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
428
|
+
# Please refer to the README for information about making permanent changes. #
|
429
|
+
################################################################################
|