czmq-ffi-gen 0.4.1 → 0.5.0
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 +4 -4
- data/CHANGES.md +9 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zchunk.rb +388 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zconfig.rb +4 -2
- data/lib/czmq-ffi-gen/czmq/ffi/zfile.rb +4 -2
- data/lib/czmq-ffi-gen/czmq/ffi.rb +29 -0
- data/lib/czmq-ffi-gen/errors.rb +26 -0
- data/lib/czmq-ffi-gen/gem_version.rb +1 -1
- data/lib/czmq-ffi-gen.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ddc4ee13a1ddc22fe67e85944c03518113c53bf
|
4
|
+
data.tar.gz: 97c237e933b61b8777a028ec104ce2afc3703c17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5caa19323558d2a38336802bae75cb1ed64de047f288d20531079a77fdb555a642115e6e864329c4315b6def1bcde496f56ed153c608965de2c6c7c4ad9ee7bc
|
7
|
+
data.tar.gz: d8dd4d88b96b568a0ddfbd0f47b7462b346bea823c003f0d402f0f134598ce57257cf4c1f3517803d2b0392a6a0830a99432a7330d62c7438b6fd403a58fb7f8
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
0.5.0 (01/14/2016)
|
2
|
+
-----
|
3
|
+
* add CZMQ::FFI::Errors
|
4
|
+
- hand-written code to interact with libzmq
|
5
|
+
- .errno returns error code of last (ZMQ) error
|
6
|
+
- .strerror returns string representation of last (ZMQ) error
|
7
|
+
* upgrade CZMQ low-level binding to
|
8
|
+
- add Zchunk
|
9
|
+
|
1
10
|
0.4.1 (01/06/2016)
|
2
11
|
-----
|
3
12
|
* upgrade CZMQ low-level binding to
|
@@ -0,0 +1,388 @@
|
|
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
|
+
#
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Zchunk
|
12
|
+
# Raised when one tries to use an instance of {Zchunk} 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.zchunk_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 chunk of the specified size. If you specify the data, it
|
77
|
+
# is copied into the chunk. If you do not specify the data, the chunk is
|
78
|
+
# allocated and left empty, and you can then add data using zchunk_append.
|
79
|
+
# @param data [::FFI::Pointer, #to_ptr]
|
80
|
+
# @param size [Integer, #to_int, #to_i]
|
81
|
+
# @return [CZMQ::Zchunk]
|
82
|
+
def self.new(data, size)
|
83
|
+
size = Integer(size)
|
84
|
+
ptr = ::CZMQ::FFI.zchunk_new(data, size)
|
85
|
+
__new ptr
|
86
|
+
end
|
87
|
+
|
88
|
+
# Destroy a chunk
|
89
|
+
#
|
90
|
+
# @return [void]
|
91
|
+
def destroy()
|
92
|
+
return unless @ptr
|
93
|
+
self_p = __ptr_give_ref
|
94
|
+
result = ::CZMQ::FFI.zchunk_destroy(self_p)
|
95
|
+
result
|
96
|
+
end
|
97
|
+
|
98
|
+
# Resizes chunk max_size as requested; chunk_cur size is set to zero
|
99
|
+
#
|
100
|
+
# @param size [Integer, #to_int, #to_i]
|
101
|
+
# @return [void]
|
102
|
+
def resize(size)
|
103
|
+
raise DestroyedError unless @ptr
|
104
|
+
self_p = @ptr
|
105
|
+
size = Integer(size)
|
106
|
+
result = ::CZMQ::FFI.zchunk_resize(self_p, size)
|
107
|
+
result
|
108
|
+
end
|
109
|
+
|
110
|
+
# Return chunk cur size
|
111
|
+
#
|
112
|
+
# @return [Integer]
|
113
|
+
def size()
|
114
|
+
raise DestroyedError unless @ptr
|
115
|
+
self_p = @ptr
|
116
|
+
result = ::CZMQ::FFI.zchunk_size(self_p)
|
117
|
+
result
|
118
|
+
end
|
119
|
+
|
120
|
+
# Return chunk max size
|
121
|
+
#
|
122
|
+
# @return [Integer]
|
123
|
+
def max_size()
|
124
|
+
raise DestroyedError unless @ptr
|
125
|
+
self_p = @ptr
|
126
|
+
result = ::CZMQ::FFI.zchunk_max_size(self_p)
|
127
|
+
result
|
128
|
+
end
|
129
|
+
|
130
|
+
# Return chunk data
|
131
|
+
#
|
132
|
+
# @return [::FFI::Pointer]
|
133
|
+
def data()
|
134
|
+
raise DestroyedError unless @ptr
|
135
|
+
self_p = @ptr
|
136
|
+
result = ::CZMQ::FFI.zchunk_data(self_p)
|
137
|
+
result
|
138
|
+
end
|
139
|
+
|
140
|
+
# Set chunk data from user-supplied data; truncate if too large. Data may
|
141
|
+
# be null. Returns actual size of chunk
|
142
|
+
#
|
143
|
+
# @param data [::FFI::Pointer, #to_ptr]
|
144
|
+
# @param size [Integer, #to_int, #to_i]
|
145
|
+
# @return [Integer]
|
146
|
+
def set(data, size)
|
147
|
+
raise DestroyedError unless @ptr
|
148
|
+
self_p = @ptr
|
149
|
+
size = Integer(size)
|
150
|
+
result = ::CZMQ::FFI.zchunk_set(self_p, data, size)
|
151
|
+
result
|
152
|
+
end
|
153
|
+
|
154
|
+
# Fill chunk data from user-supplied octet
|
155
|
+
#
|
156
|
+
# @param filler [Integer, #to_int, #to_i]
|
157
|
+
# @param size [Integer, #to_int, #to_i]
|
158
|
+
# @return [Integer]
|
159
|
+
def fill(filler, size)
|
160
|
+
raise DestroyedError unless @ptr
|
161
|
+
self_p = @ptr
|
162
|
+
filler = Integer(filler)
|
163
|
+
size = Integer(size)
|
164
|
+
result = ::CZMQ::FFI.zchunk_fill(self_p, filler, size)
|
165
|
+
result
|
166
|
+
end
|
167
|
+
|
168
|
+
# Append user-supplied data to chunk, return resulting chunk size. If the
|
169
|
+
# data would exceeded the available space, it is truncated. If you want to
|
170
|
+
# grow the chunk to accommodate new data, use the zchunk_extend method.
|
171
|
+
#
|
172
|
+
# @param data [::FFI::Pointer, #to_ptr]
|
173
|
+
# @param size [Integer, #to_int, #to_i]
|
174
|
+
# @return [Integer]
|
175
|
+
def append(data, size)
|
176
|
+
raise DestroyedError unless @ptr
|
177
|
+
self_p = @ptr
|
178
|
+
size = Integer(size)
|
179
|
+
result = ::CZMQ::FFI.zchunk_append(self_p, data, size)
|
180
|
+
result
|
181
|
+
end
|
182
|
+
|
183
|
+
# Append user-supplied data to chunk, return resulting chunk size. If the
|
184
|
+
# data would exceeded the available space, the chunk grows in size.
|
185
|
+
#
|
186
|
+
# @param data [::FFI::Pointer, #to_ptr]
|
187
|
+
# @param size [Integer, #to_int, #to_i]
|
188
|
+
# @return [Integer]
|
189
|
+
def extend(data, size)
|
190
|
+
raise DestroyedError unless @ptr
|
191
|
+
self_p = @ptr
|
192
|
+
size = Integer(size)
|
193
|
+
result = ::CZMQ::FFI.zchunk_extend(self_p, data, size)
|
194
|
+
result
|
195
|
+
end
|
196
|
+
|
197
|
+
# Copy as much data from 'source' into the chunk as possible; returns the
|
198
|
+
# new size of chunk. If all data from 'source' is used, returns exhausted
|
199
|
+
# on the source chunk. Source can be consumed as many times as needed until
|
200
|
+
# it is exhausted. If source was already exhausted, does not change chunk.
|
201
|
+
#
|
202
|
+
# @param source [Zchunk, #__ptr]
|
203
|
+
# @return [Integer]
|
204
|
+
def consume(source)
|
205
|
+
raise DestroyedError unless @ptr
|
206
|
+
self_p = @ptr
|
207
|
+
source = source.__ptr if source
|
208
|
+
result = ::CZMQ::FFI.zchunk_consume(self_p, source)
|
209
|
+
result
|
210
|
+
end
|
211
|
+
|
212
|
+
# Returns true if the chunk was exhausted by consume methods, or if the
|
213
|
+
# chunk has a size of zero.
|
214
|
+
#
|
215
|
+
# @return [Boolean]
|
216
|
+
def exhausted()
|
217
|
+
raise DestroyedError unless @ptr
|
218
|
+
self_p = @ptr
|
219
|
+
result = ::CZMQ::FFI.zchunk_exhausted(self_p)
|
220
|
+
result
|
221
|
+
end
|
222
|
+
|
223
|
+
# Read chunk from an open file descriptor
|
224
|
+
#
|
225
|
+
# @param handle [::FFI::Pointer, #to_ptr]
|
226
|
+
# @param bytes [Integer, #to_int, #to_i]
|
227
|
+
# @return [Zchunk]
|
228
|
+
def self.read(handle, bytes)
|
229
|
+
bytes = Integer(bytes)
|
230
|
+
result = ::CZMQ::FFI.zchunk_read(handle, bytes)
|
231
|
+
result = Zchunk.__new result, true
|
232
|
+
result
|
233
|
+
end
|
234
|
+
|
235
|
+
# Write chunk to an open file descriptor
|
236
|
+
#
|
237
|
+
# @param handle [::FFI::Pointer, #to_ptr]
|
238
|
+
# @return [Integer]
|
239
|
+
def write(handle)
|
240
|
+
raise DestroyedError unless @ptr
|
241
|
+
self_p = @ptr
|
242
|
+
result = ::CZMQ::FFI.zchunk_write(self_p, handle)
|
243
|
+
result
|
244
|
+
end
|
245
|
+
|
246
|
+
# Try to slurp an entire file into a chunk. Will read up to maxsize of
|
247
|
+
# the file. If maxsize is 0, will attempt to read the entire file and
|
248
|
+
# fail with an assertion if that cannot fit into memory. Returns a new
|
249
|
+
# chunk containing the file data, or NULL if the file could not be read.
|
250
|
+
#
|
251
|
+
# @param filename [String, #to_s, nil]
|
252
|
+
# @param maxsize [Integer, #to_int, #to_i]
|
253
|
+
# @return [Zchunk]
|
254
|
+
def self.slurp(filename, maxsize)
|
255
|
+
maxsize = Integer(maxsize)
|
256
|
+
result = ::CZMQ::FFI.zchunk_slurp(filename, maxsize)
|
257
|
+
result = Zchunk.__new result, true
|
258
|
+
result
|
259
|
+
end
|
260
|
+
|
261
|
+
# Create copy of chunk, as new chunk object. Returns a fresh zchunk_t
|
262
|
+
# object, or null if there was not enough heap memory. If chunk is null,
|
263
|
+
# returns null.
|
264
|
+
#
|
265
|
+
# @return [Zchunk]
|
266
|
+
def dup()
|
267
|
+
raise DestroyedError unless @ptr
|
268
|
+
self_p = @ptr
|
269
|
+
result = ::CZMQ::FFI.zchunk_dup(self_p)
|
270
|
+
result = Zchunk.__new result, true
|
271
|
+
result
|
272
|
+
end
|
273
|
+
|
274
|
+
# Return chunk data encoded as printable hex string. Caller must free
|
275
|
+
# string when finished with it.
|
276
|
+
#
|
277
|
+
# @return [::FFI::AutoPointer]
|
278
|
+
def strhex()
|
279
|
+
raise DestroyedError unless @ptr
|
280
|
+
self_p = @ptr
|
281
|
+
result = ::CZMQ::FFI.zchunk_strhex(self_p)
|
282
|
+
result = ::FFI::AutoPointer.new(result, LibC.method(:free))
|
283
|
+
result
|
284
|
+
end
|
285
|
+
|
286
|
+
# Return chunk data copied into freshly allocated string
|
287
|
+
# Caller must free string when finished with it.
|
288
|
+
#
|
289
|
+
# @return [::FFI::AutoPointer]
|
290
|
+
def strdup()
|
291
|
+
raise DestroyedError unless @ptr
|
292
|
+
self_p = @ptr
|
293
|
+
result = ::CZMQ::FFI.zchunk_strdup(self_p)
|
294
|
+
result = ::FFI::AutoPointer.new(result, LibC.method(:free))
|
295
|
+
result
|
296
|
+
end
|
297
|
+
|
298
|
+
# Return TRUE if chunk body is equal to string, excluding terminator
|
299
|
+
#
|
300
|
+
# @param string [String, #to_s, nil]
|
301
|
+
# @return [Boolean]
|
302
|
+
def streq(string)
|
303
|
+
raise DestroyedError unless @ptr
|
304
|
+
self_p = @ptr
|
305
|
+
result = ::CZMQ::FFI.zchunk_streq(self_p, string)
|
306
|
+
result
|
307
|
+
end
|
308
|
+
|
309
|
+
# Transform zchunk into a zframe that can be sent in a message.
|
310
|
+
#
|
311
|
+
# @return [Zframe]
|
312
|
+
def pack()
|
313
|
+
raise DestroyedError unless @ptr
|
314
|
+
self_p = @ptr
|
315
|
+
result = ::CZMQ::FFI.zchunk_pack(self_p)
|
316
|
+
result = Zframe.__new result, true
|
317
|
+
result
|
318
|
+
end
|
319
|
+
|
320
|
+
# Transform a zframe into a zchunk.
|
321
|
+
#
|
322
|
+
# @param frame [Zframe, #__ptr]
|
323
|
+
# @return [Zchunk]
|
324
|
+
def self.unpack(frame)
|
325
|
+
frame = frame.__ptr if frame
|
326
|
+
result = ::CZMQ::FFI.zchunk_unpack(frame)
|
327
|
+
result = Zchunk.__new result, true
|
328
|
+
result
|
329
|
+
end
|
330
|
+
|
331
|
+
# Calculate SHA1 digest for chunk, using zdigest class.
|
332
|
+
#
|
333
|
+
# @return [String]
|
334
|
+
def digest()
|
335
|
+
raise DestroyedError unless @ptr
|
336
|
+
self_p = @ptr
|
337
|
+
result = ::CZMQ::FFI.zchunk_digest(self_p)
|
338
|
+
result
|
339
|
+
end
|
340
|
+
|
341
|
+
# Dump chunk to FILE stream, for debugging and tracing.
|
342
|
+
#
|
343
|
+
# @param file [::FFI::Pointer, #to_ptr]
|
344
|
+
# @return [void]
|
345
|
+
def fprint(file)
|
346
|
+
raise DestroyedError unless @ptr
|
347
|
+
self_p = @ptr
|
348
|
+
result = ::CZMQ::FFI.zchunk_fprint(self_p, file)
|
349
|
+
result
|
350
|
+
end
|
351
|
+
|
352
|
+
# Dump message to stderr, for debugging and tracing.
|
353
|
+
# See zchunk_fprint for details
|
354
|
+
#
|
355
|
+
# @return [void]
|
356
|
+
def print()
|
357
|
+
raise DestroyedError unless @ptr
|
358
|
+
self_p = @ptr
|
359
|
+
result = ::CZMQ::FFI.zchunk_print(self_p)
|
360
|
+
result
|
361
|
+
end
|
362
|
+
|
363
|
+
# Probe the supplied object, and report if it looks like a zchunk_t.
|
364
|
+
#
|
365
|
+
# @param self_ [::FFI::Pointer, #to_ptr]
|
366
|
+
# @return [Boolean]
|
367
|
+
def self.is(self_)
|
368
|
+
result = ::CZMQ::FFI.zchunk_is(self_)
|
369
|
+
result
|
370
|
+
end
|
371
|
+
|
372
|
+
# Self test of this class.
|
373
|
+
#
|
374
|
+
# @param verbose [Boolean]
|
375
|
+
# @return [void]
|
376
|
+
def self.test(verbose)
|
377
|
+
verbose = !(0==verbose||!verbose) # boolean
|
378
|
+
result = ::CZMQ::FFI.zchunk_test(verbose)
|
379
|
+
result
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
################################################################################
|
386
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
387
|
+
# Please refer to the README for information about making permanent changes. #
|
388
|
+
################################################################################
|
@@ -350,9 +350,10 @@ module CZMQ
|
|
350
350
|
|
351
351
|
# Load a config tree from a memory chunk
|
352
352
|
#
|
353
|
-
# @param chunk [
|
353
|
+
# @param chunk [Zchunk, #__ptr]
|
354
354
|
# @return [Zconfig]
|
355
355
|
def self.chunk_load(chunk)
|
356
|
+
chunk = chunk.__ptr if chunk
|
356
357
|
result = ::CZMQ::FFI.zconfig_chunk_load(chunk)
|
357
358
|
result = Zconfig.__new result, false
|
358
359
|
result
|
@@ -360,11 +361,12 @@ module CZMQ
|
|
360
361
|
|
361
362
|
# Save a config tree to a new memory chunk
|
362
363
|
#
|
363
|
-
# @return [
|
364
|
+
# @return [Zchunk]
|
364
365
|
def chunk_save()
|
365
366
|
raise DestroyedError unless @ptr
|
366
367
|
self_p = @ptr
|
367
368
|
result = ::CZMQ::FFI.zconfig_chunk_save(self_p)
|
369
|
+
result = Zchunk.__new result, false
|
368
370
|
result
|
369
371
|
end
|
370
372
|
|
@@ -259,12 +259,13 @@ module CZMQ
|
|
259
259
|
#
|
260
260
|
# @param bytes [Integer, #to_int, #to_i]
|
261
261
|
# @param offset [::FFI::Pointer, #to_ptr]
|
262
|
-
# @return [
|
262
|
+
# @return [Zchunk]
|
263
263
|
def read(bytes, offset)
|
264
264
|
raise DestroyedError unless @ptr
|
265
265
|
self_p = @ptr
|
266
266
|
bytes = Integer(bytes)
|
267
267
|
result = ::CZMQ::FFI.zfile_read(self_p, bytes, offset)
|
268
|
+
result = Zchunk.__new result, true
|
268
269
|
result
|
269
270
|
end
|
270
271
|
|
@@ -281,12 +282,13 @@ module CZMQ
|
|
281
282
|
# Write chunk to file at specified position
|
282
283
|
# Return 0 if OK, else -1
|
283
284
|
#
|
284
|
-
# @param chunk [
|
285
|
+
# @param chunk [Zchunk, #__ptr]
|
285
286
|
# @param offset [::FFI::Pointer, #to_ptr]
|
286
287
|
# @return [Integer]
|
287
288
|
def write(chunk, offset)
|
288
289
|
raise DestroyedError unless @ptr
|
289
290
|
self_p = @ptr
|
291
|
+
chunk = chunk.__ptr if chunk
|
290
292
|
result = ::CZMQ::FFI.zfile_write(self_p, chunk, offset)
|
291
293
|
result
|
292
294
|
end
|
@@ -112,6 +112,35 @@ module CZMQ
|
|
112
112
|
|
113
113
|
require_relative 'ffi/zcertstore'
|
114
114
|
|
115
|
+
attach_function :zchunk_new, [:pointer, :size_t], :pointer, **opts
|
116
|
+
attach_function :zchunk_destroy, [:pointer], :void, **opts
|
117
|
+
attach_function :zchunk_resize, [:pointer, :size_t], :void, **opts
|
118
|
+
attach_function :zchunk_size, [:pointer], :size_t, **opts
|
119
|
+
attach_function :zchunk_max_size, [:pointer], :size_t, **opts
|
120
|
+
attach_function :zchunk_data, [:pointer], :pointer, **opts
|
121
|
+
attach_function :zchunk_set, [:pointer, :pointer, :size_t], :size_t, **opts
|
122
|
+
attach_function :zchunk_fill, [:pointer, :char, :size_t], :size_t, **opts
|
123
|
+
attach_function :zchunk_append, [:pointer, :pointer, :size_t], :size_t, **opts
|
124
|
+
attach_function :zchunk_extend, [:pointer, :pointer, :size_t], :size_t, **opts
|
125
|
+
attach_function :zchunk_consume, [:pointer, :pointer], :size_t, **opts
|
126
|
+
attach_function :zchunk_exhausted, [:pointer], :bool, **opts
|
127
|
+
attach_function :zchunk_read, [:pointer, :size_t], :pointer, **opts
|
128
|
+
attach_function :zchunk_write, [:pointer, :pointer], :int, **opts
|
129
|
+
attach_function :zchunk_slurp, [:string, :size_t], :pointer, **opts
|
130
|
+
attach_function :zchunk_dup, [:pointer], :pointer, **opts
|
131
|
+
attach_function :zchunk_strhex, [:pointer], :pointer, **opts
|
132
|
+
attach_function :zchunk_strdup, [:pointer], :pointer, **opts
|
133
|
+
attach_function :zchunk_streq, [:pointer, :string], :bool, **opts
|
134
|
+
attach_function :zchunk_pack, [:pointer], :pointer, **opts
|
135
|
+
attach_function :zchunk_unpack, [:pointer], :pointer, **opts
|
136
|
+
attach_function :zchunk_digest, [:pointer], :string, **opts
|
137
|
+
attach_function :zchunk_fprint, [:pointer, :pointer], :void, **opts
|
138
|
+
attach_function :zchunk_print, [:pointer], :void, **opts
|
139
|
+
attach_function :zchunk_is, [:pointer], :bool, **opts
|
140
|
+
attach_function :zchunk_test, [:bool], :void, **opts
|
141
|
+
|
142
|
+
require_relative 'ffi/zchunk'
|
143
|
+
|
115
144
|
attach_function :zconfig_new, [:string, :pointer], :pointer, **opts
|
116
145
|
attach_function :zconfig_load, [:string], :pointer, **opts
|
117
146
|
attach_function :zconfig_loadf, [:string, :varargs], :pointer, **opts
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# This is only used to be able to read get the last ZMQ error.
|
2
|
+
module CZMQ::FFI::Errors
|
3
|
+
extend ::FFI::Library
|
4
|
+
|
5
|
+
lib_name = 'libzmq'
|
6
|
+
lib_paths = ['/usr/local/lib', '/opt/local/lib', '/usr/lib64']
|
7
|
+
.map { |path| "#{path}/#{lib_name}.#{::FFI::Platform::LIBSUFFIX}" }
|
8
|
+
ffi_lib lib_paths + [lib_name]
|
9
|
+
|
10
|
+
opts = {
|
11
|
+
blocking: true # only necessary on MRI to deal with the GIL.
|
12
|
+
}
|
13
|
+
|
14
|
+
attach_function :zmq_strerror, [:int], :string, **opts
|
15
|
+
attach_function :zmq_errno, [], :int, **opts
|
16
|
+
|
17
|
+
# @return [String] error code of the last (ZMQ) error
|
18
|
+
def self.errno
|
19
|
+
zmq_errno
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [String] the string representation of the last (ZMQ) error
|
23
|
+
def self.strerror
|
24
|
+
zmq_strerror(zmq_errno)
|
25
|
+
end
|
26
|
+
end
|
data/lib/czmq-ffi-gen.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative "czmq-ffi-gen/czmq/ffi"
|
2
2
|
require_relative "czmq-ffi-gen/gem_version"
|
3
3
|
require_relative "czmq-ffi-gen/library_version"
|
4
|
+
require_relative "czmq-ffi-gen/errors"
|
4
5
|
require_relative "czmq-ffi-gen/signals"
|
5
6
|
CZMQ::FFI.available? or raise LoadError, "libczmq is not available"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: czmq-ffi-gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrik Wenger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/czmq-ffi-gen/czmq/ffi/zarmour.rb
|
100
100
|
- lib/czmq-ffi-gen/czmq/ffi/zcert.rb
|
101
101
|
- lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb
|
102
|
+
- lib/czmq-ffi-gen/czmq/ffi/zchunk.rb
|
102
103
|
- lib/czmq-ffi-gen/czmq/ffi/zconfig.rb
|
103
104
|
- lib/czmq-ffi-gen/czmq/ffi/zdir.rb
|
104
105
|
- lib/czmq-ffi-gen/czmq/ffi/zdir_patch.rb
|
@@ -116,6 +117,7 @@ files:
|
|
116
117
|
- lib/czmq-ffi-gen/czmq/ffi/zstr.rb
|
117
118
|
- lib/czmq-ffi-gen/czmq/ffi/ztrie.rb
|
118
119
|
- lib/czmq-ffi-gen/czmq/ffi/zuuid.rb
|
120
|
+
- lib/czmq-ffi-gen/errors.rb
|
119
121
|
- lib/czmq-ffi-gen/gem_version.rb
|
120
122
|
- lib/czmq-ffi-gen/library_version.rb
|
121
123
|
- lib/czmq-ffi-gen/signals.rb
|