czmq-ffi-gen 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d73add1339edd404b96de5b47ff0e7513dff7fe2
4
- data.tar.gz: 3b973b9f975f49eadc315eab5c7ac0b24e25e3f9
3
+ metadata.gz: 739bb30054648efc602eaff62354c63633ed0099
4
+ data.tar.gz: 2a81080b5e56231ede1770090e3168172cd0004d
5
5
  SHA512:
6
- metadata.gz: 3bfddad065f3a2359bffe941773e4d7c24a36faac3f212d8fa9ac0ef2054fa0ceb41acbc9bd01e87b865af954d999ad087188ac61253c6d74aa90ac5d8f05cd5
7
- data.tar.gz: 724a03ba6f49474f9080ce6ccae8b8d6da4d6966d7b41758b6c93f2cdfbdfa2cb739fa39a13c496d8b78a6d5015e224f89c3d3dcd7d5c27e0dc98d343c968e35
6
+ metadata.gz: 0aeb9fded462ac3262657cf447d34ceeb227b5446ed26b3ea23848634600a7587e899234bb83272753a1f211a0c37010a85c8c5bf19762de204bbe0d33f663ce
7
+ data.tar.gz: b6fdf14d753658728786dbd3e4c440a7a6acac96c6f0608d8cb0950079995de5b8a151b474bd4536fdb617d9d5f9aea816e5aa91207922995c0d0510862c1d65
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ 0.2.1 (12/12/2015)
2
+ -----
3
+ * upgrade CZMQ low-level binding to
4
+ - allow passing a null pointer (nil) for an FFI :string parameter
5
+
1
6
  0.2.0 (12/10/2015)
2
7
  -----
3
8
  * using new CZMQ version which
@@ -60,11 +60,18 @@ module CZMQ
60
60
  raise DestroyedError unless @ptr
61
61
  ptr_ptr = ::FFI::MemoryPointer.new :pointer
62
62
  ptr_ptr.write_pointer @ptr
63
- ObjectSpace.undefine_finalizer self if @finalizer
64
- @finalizer = nil
63
+ __undef_finalizer if @finalizer
65
64
  @ptr = nil
66
65
  ptr_ptr
67
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
68
75
 
69
76
  # Create a new callback of the following type:
70
77
  # Actors get a pipe and arguments from caller
@@ -60,11 +60,18 @@ module CZMQ
60
60
  raise DestroyedError unless @ptr
61
61
  ptr_ptr = ::FFI::MemoryPointer.new :pointer
62
62
  ptr_ptr.write_pointer @ptr
63
- ObjectSpace.undefine_finalizer self if @finalizer
64
- @finalizer = nil
63
+ __undef_finalizer if @finalizer
65
64
  @ptr = nil
66
65
  ptr_ptr
67
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
68
75
 
69
76
  # Create a new zarmour.
70
77
  # @return [CZMQ::Zarmour]
@@ -111,13 +118,12 @@ module CZMQ
111
118
  # The decoded output is null-terminated, so it may be treated
112
119
  # as a string, if that's what it was prior to encoding.
113
120
  #
114
- # @param data [String, #to_str, #to_s]
121
+ # @param data [String, #to_s, nil]
115
122
  # @param decode_size [::FFI::Pointer, #to_ptr]
116
123
  # @return [::FFI::Pointer]
117
124
  def decode(data, decode_size)
118
125
  raise DestroyedError unless @ptr
119
126
  self_p = @ptr
120
- data = String(data)
121
127
  result = ::CZMQ::FFI.zarmour_decode(self_p, data, decode_size)
122
128
  result
123
129
  end
@@ -60,11 +60,18 @@ module CZMQ
60
60
  raise DestroyedError unless @ptr
61
61
  ptr_ptr = ::FFI::MemoryPointer.new :pointer
62
62
  ptr_ptr.write_pointer @ptr
63
- ObjectSpace.undefine_finalizer self if @finalizer
64
- @finalizer = nil
63
+ __undef_finalizer if @finalizer
65
64
  @ptr = nil
66
65
  ptr_ptr
67
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
68
75
 
69
76
  # Create and initialize a new certificate in memory
70
77
  # @return [CZMQ::Zcert]
@@ -83,10 +90,9 @@ module CZMQ
83
90
  end
84
91
 
85
92
  # Load certificate from file
86
- # @param filename [String, #to_str, #to_s]
93
+ # @param filename [String, #to_s, nil]
87
94
  # @return [CZMQ::Zcert]
88
95
  def self.load(filename)
89
- filename = String(filename)
90
96
  ptr = ::CZMQ::FFI.zcert_load(filename)
91
97
  __new ptr
92
98
  end
@@ -143,15 +149,13 @@ module CZMQ
143
149
 
144
150
  # Set certificate metadata from formatted string.
145
151
  #
146
- # @param name [String, #to_str, #to_s]
147
- # @param format [String, #to_str, #to_s]
152
+ # @param name [String, #to_s, nil]
153
+ # @param format [String, #to_s, nil]
148
154
  # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
149
155
  # @return [void]
150
156
  def set_meta(name, format, *args)
151
157
  raise DestroyedError unless @ptr
152
158
  self_p = @ptr
153
- name = String(name)
154
- format = String(format)
155
159
  result = ::CZMQ::FFI.zcert_set_meta(self_p, name, format, *args)
156
160
  result
157
161
  end
@@ -159,12 +163,11 @@ module CZMQ
159
163
  # Get metadata value from certificate; if the metadata value doesn't
160
164
  # exist, returns NULL.
161
165
  #
162
- # @param name [String, #to_str, #to_s]
166
+ # @param name [String, #to_s, nil]
163
167
  # @return [::FFI::Pointer]
164
168
  def meta(name)
165
169
  raise DestroyedError unless @ptr
166
170
  self_p = @ptr
167
- name = String(name)
168
171
  result = ::CZMQ::FFI.zcert_meta(self_p, name)
169
172
  result
170
173
  end
@@ -184,36 +187,33 @@ module CZMQ
184
187
  # Save full certificate (public + secret) to file for persistent storage
185
188
  # This creates one public file and one secret file (filename + "_secret").
186
189
  #
187
- # @param filename [String, #to_str, #to_s]
190
+ # @param filename [String, #to_s, nil]
188
191
  # @return [Integer]
189
192
  def save(filename)
190
193
  raise DestroyedError unless @ptr
191
194
  self_p = @ptr
192
- filename = String(filename)
193
195
  result = ::CZMQ::FFI.zcert_save(self_p, filename)
194
196
  result
195
197
  end
196
198
 
197
199
  # Save public certificate only to file for persistent storage
198
200
  #
199
- # @param filename [String, #to_str, #to_s]
201
+ # @param filename [String, #to_s, nil]
200
202
  # @return [Integer]
201
203
  def save_public(filename)
202
204
  raise DestroyedError unless @ptr
203
205
  self_p = @ptr
204
- filename = String(filename)
205
206
  result = ::CZMQ::FFI.zcert_save_public(self_p, filename)
206
207
  result
207
208
  end
208
209
 
209
210
  # Save secret certificate only to file for persistent storage
210
211
  #
211
- # @param filename [String, #to_str, #to_s]
212
+ # @param filename [String, #to_s, nil]
212
213
  # @return [Integer]
213
214
  def save_secret(filename)
214
215
  raise DestroyedError unless @ptr
215
216
  self_p = @ptr
216
- filename = String(filename)
217
217
  result = ::CZMQ::FFI.zcert_save_secret(self_p, filename)
218
218
  result
219
219
  end
@@ -60,11 +60,18 @@ module CZMQ
60
60
  raise DestroyedError unless @ptr
61
61
  ptr_ptr = ::FFI::MemoryPointer.new :pointer
62
62
  ptr_ptr.write_pointer @ptr
63
- ObjectSpace.undefine_finalizer self if @finalizer
64
- @finalizer = nil
63
+ __undef_finalizer if @finalizer
65
64
  @ptr = nil
66
65
  ptr_ptr
67
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
68
75
 
69
76
  # Create a new certificate store from a disk directory, loading and
70
77
  # indexing all certificates in that location. The directory itself may be
@@ -72,10 +79,9 @@ module CZMQ
72
79
  # is automatically refreshed on any zcertstore_lookup() call. If the
73
80
  # location is specified as NULL, creates a pure-memory store, which you
74
81
  # can work with by inserting certificates at runtime.
75
- # @param location [String, #to_str, #to_s]
82
+ # @param location [String, #to_s, nil]
76
83
  # @return [CZMQ::Zcertstore]
77
84
  def self.new(location)
78
- location = String(location)
79
85
  ptr = ::CZMQ::FFI.zcertstore_new(location)
80
86
  __new ptr
81
87
  end
@@ -94,12 +100,11 @@ module CZMQ
94
100
  # Look up certificate by public key, returns zcert_t object if found,
95
101
  # else returns NULL. The public key is provided in Z85 text format.
96
102
  #
97
- # @param public_key [String, #to_str, #to_s]
103
+ # @param public_key [String, #to_s, nil]
98
104
  # @return [Zcert]
99
105
  def lookup(public_key)
100
106
  raise DestroyedError unless @ptr
101
107
  self_p = @ptr
102
- public_key = String(public_key)
103
108
  result = ::CZMQ::FFI.zcertstore_lookup(self_p, public_key)
104
109
  result = Zcert.__new result, false
105
110
  result
@@ -60,11 +60,18 @@ module CZMQ
60
60
  raise DestroyedError unless @ptr
61
61
  ptr_ptr = ::FFI::MemoryPointer.new :pointer
62
62
  ptr_ptr.write_pointer @ptr
63
- ObjectSpace.undefine_finalizer self if @finalizer
64
- @finalizer = nil
63
+ __undef_finalizer if @finalizer
65
64
  @ptr = nil
66
65
  ptr_ptr
67
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
68
75
 
69
76
  # Create a new callback of the following type:
70
77
  #
@@ -85,11 +92,10 @@ module CZMQ
85
92
  end
86
93
 
87
94
  # Create new config item
88
- # @param name [String, #to_str, #to_s]
95
+ # @param name [String, #to_s, nil]
89
96
  # @param parent [Zconfig, #__ptr]
90
97
  # @return [CZMQ::Zconfig]
91
98
  def self.new(name, parent)
92
- name = String(name)
93
99
  parent = parent.__ptr if parent
94
100
  ptr = ::CZMQ::FFI.zconfig_new(name, parent)
95
101
  __new ptr
@@ -98,21 +104,19 @@ module CZMQ
98
104
  # Load a config tree from a specified ZPL text file; returns a zconfig_t
99
105
  # reference for the root, if the file exists and is readable. Returns NULL
100
106
  # if the file does not exist.
101
- # @param filename [String, #to_str, #to_s]
107
+ # @param filename [String, #to_s, nil]
102
108
  # @return [CZMQ::Zconfig]
103
109
  def self.load(filename)
104
- filename = String(filename)
105
110
  ptr = ::CZMQ::FFI.zconfig_load(filename)
106
111
  __new ptr
107
112
  end
108
113
 
109
114
  # Equivalent to zconfig_load, taking a format string instead of a fixed
110
115
  # filename.
111
- # @param format [String, #to_str, #to_s]
116
+ # @param format [String, #to_s, nil]
112
117
  # @param args [Array<Object>]
113
118
  # @return [CZMQ::Zconfig]
114
119
  def self.loadf(format, *args)
115
- format = String(format)
116
120
  ptr = ::CZMQ::FFI.zconfig_loadf(format, *args)
117
121
  __new ptr
118
122
  end
@@ -149,14 +153,12 @@ module CZMQ
149
153
 
150
154
  # Insert or update configuration key with value
151
155
  #
152
- # @param path [String, #to_str, #to_s]
153
- # @param value [String, #to_str, #to_s]
156
+ # @param path [String, #to_s, nil]
157
+ # @param value [String, #to_s, nil]
154
158
  # @return [void]
155
159
  def put(path, value)
156
160
  raise DestroyedError unless @ptr
157
161
  self_p = @ptr
158
- path = String(path)
159
- value = String(value)
160
162
  result = ::CZMQ::FFI.zconfig_put(self_p, path, value)
161
163
  result
162
164
  end
@@ -164,15 +166,13 @@ module CZMQ
164
166
  # Equivalent to zconfig_put, accepting a format specifier and variable
165
167
  # argument list, instead of a single string value.
166
168
  #
167
- # @param path [String, #to_str, #to_s]
168
- # @param format [String, #to_str, #to_s]
169
+ # @param path [String, #to_s, nil]
170
+ # @param format [String, #to_s, nil]
169
171
  # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
170
172
  # @return [void]
171
173
  def putf(path, format, *args)
172
174
  raise DestroyedError unless @ptr
173
175
  self_p = @ptr
174
- path = String(path)
175
- format = String(format)
176
176
  result = ::CZMQ::FFI.zconfig_putf(self_p, path, format, *args)
177
177
  result
178
178
  end
@@ -180,26 +180,23 @@ module CZMQ
180
180
  # Get value for config item into a string value; leading slash is optional
181
181
  # and ignored.
182
182
  #
183
- # @param path [String, #to_str, #to_s]
184
- # @param default_value [String, #to_str, #to_s]
183
+ # @param path [String, #to_s, nil]
184
+ # @param default_value [String, #to_s, nil]
185
185
  # @return [::FFI::Pointer]
186
186
  def get(path, default_value)
187
187
  raise DestroyedError unless @ptr
188
188
  self_p = @ptr
189
- path = String(path)
190
- default_value = String(default_value)
191
189
  result = ::CZMQ::FFI.zconfig_get(self_p, path, default_value)
192
190
  result
193
191
  end
194
192
 
195
193
  # Set config item name, name may be NULL
196
194
  #
197
- # @param name [String, #to_str, #to_s]
195
+ # @param name [String, #to_s, nil]
198
196
  # @return [void]
199
197
  def set_name(name)
200
198
  raise DestroyedError unless @ptr
201
199
  self_p = @ptr
202
- name = String(name)
203
200
  result = ::CZMQ::FFI.zconfig_set_name(self_p, name)
204
201
  result
205
202
  end
@@ -209,13 +206,12 @@ module CZMQ
209
206
  # comes from an insecure source, you must use '%s' as the format, followed
210
207
  # by the string.
211
208
  #
212
- # @param format [String, #to_str, #to_s]
209
+ # @param format [String, #to_s, nil]
213
210
  # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
214
211
  # @return [void]
215
212
  def set_value(format, *args)
216
213
  raise DestroyedError unless @ptr
217
214
  self_p = @ptr
218
- format = String(format)
219
215
  result = ::CZMQ::FFI.zconfig_set_value(self_p, format, *args)
220
216
  result
221
217
  end
@@ -244,12 +240,11 @@ module CZMQ
244
240
 
245
241
  # Find a config item along a path; leading slash is optional and ignored.
246
242
  #
247
- # @param path [String, #to_str, #to_s]
243
+ # @param path [String, #to_s, nil]
248
244
  # @return [Zconfig]
249
245
  def locate(path)
250
246
  raise DestroyedError unless @ptr
251
247
  self_p = @ptr
252
- path = String(path)
253
248
  result = ::CZMQ::FFI.zconfig_locate(self_p, path)
254
249
  result = Zconfig.__new result, false
255
250
  result
@@ -285,13 +280,12 @@ module CZMQ
285
280
  # comment lines as you like. If you use a null format, all comments are
286
281
  # deleted.
287
282
  #
288
- # @param format [String, #to_str, #to_s]
283
+ # @param format [String, #to_s, nil]
289
284
  # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
290
285
  # @return [void]
291
286
  def set_comment(format, *args)
292
287
  raise DestroyedError unless @ptr
293
288
  self_p = @ptr
294
- format = String(format)
295
289
  result = ::CZMQ::FFI.zconfig_set_comment(self_p, format, *args)
296
290
  result
297
291
  end
@@ -310,12 +304,11 @@ module CZMQ
310
304
  # Save a config tree to a specified ZPL text file, where a filename
311
305
  # "-" means dump to standard output.
312
306
  #
313
- # @param filename [String, #to_str, #to_s]
307
+ # @param filename [String, #to_s, nil]
314
308
  # @return [Integer]
315
309
  def save(filename)
316
310
  raise DestroyedError unless @ptr
317
311
  self_p = @ptr
318
- filename = String(filename)
319
312
  result = ::CZMQ::FFI.zconfig_save(self_p, filename)
320
313
  result
321
314
  end
@@ -323,13 +316,12 @@ module CZMQ
323
316
  # Equivalent to zconfig_save, taking a format string instead of a fixed
324
317
  # filename.
325
318
  #
326
- # @param format [String, #to_str, #to_s]
319
+ # @param format [String, #to_s, nil]
327
320
  # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
328
321
  # @return [Integer]
329
322
  def savef(format, *args)
330
323
  raise DestroyedError unless @ptr
331
324
  self_p = @ptr
332
- format = String(format)
333
325
  result = ::CZMQ::FFI.zconfig_savef(self_p, format, *args)
334
326
  result
335
327
  end
@@ -378,10 +370,9 @@ module CZMQ
378
370
 
379
371
  # Load a config tree from a null-terminated string
380
372
  #
381
- # @param string [String, #to_str, #to_s]
373
+ # @param string [String, #to_s, nil]
382
374
  # @return [Zconfig]
383
375
  def self.str_load(string)
384
- string = String(string)
385
376
  result = ::CZMQ::FFI.zconfig_str_load(string)
386
377
  result = Zconfig.__new result, true
387
378
  result
@@ -60,21 +60,26 @@ module CZMQ
60
60
  raise DestroyedError unless @ptr
61
61
  ptr_ptr = ::FFI::MemoryPointer.new :pointer
62
62
  ptr_ptr.write_pointer @ptr
63
- ObjectSpace.undefine_finalizer self if @finalizer
64
- @finalizer = nil
63
+ __undef_finalizer if @finalizer
65
64
  @ptr = nil
66
65
  ptr_ptr
67
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
68
75
 
69
76
  # Create a new directory item that loads in the full tree of the specified
70
77
  # path, optionally located under some parent path. If parent is "-", then
71
78
  # 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]
79
+ # @param path [String, #to_s, nil]
80
+ # @param parent [String, #to_s, nil]
74
81
  # @return [CZMQ::Zdir]
75
82
  def self.new(path, parent)
76
- path = String(path)
77
- parent = String(parent)
78
83
  ptr = ::CZMQ::FFI.zdir_new(path, parent)
79
84
  __new ptr
80
85
  end
@@ -164,12 +169,11 @@ module CZMQ
164
169
  #
165
170
  # @param older [Zdir, #__ptr]
166
171
  # @param newer [Zdir, #__ptr]
167
- # @param alias_ [String, #to_str, #to_s]
172
+ # @param alias_ [String, #to_s, nil]
168
173
  # @return [Zlist]
169
174
  def self.diff(older, newer, alias_)
170
175
  older = older.__ptr if older
171
176
  newer = newer.__ptr if newer
172
- alias_ = String(alias_)
173
177
  result = ::CZMQ::FFI.zdir_diff(older, newer, alias_)
174
178
  result = Zlist.__new result, true
175
179
  result
@@ -177,12 +181,11 @@ module CZMQ
177
181
 
178
182
  # Return full contents of directory as a zdir_patch list.
179
183
  #
180
- # @param alias_ [String, #to_str, #to_s]
184
+ # @param alias_ [String, #to_s, nil]
181
185
  # @return [Zlist]
182
186
  def resync(alias_)
183
187
  raise DestroyedError unless @ptr
184
188
  self_p = @ptr
185
- alias_ = String(alias_)
186
189
  result = ::CZMQ::FFI.zdir_resync(self_p, alias_)
187
190
  result = Zlist.__new result, true
188
191
  result