czmq-ffi-gen 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,11 +59,18 @@ module CZMQ
59
59
  raise DestroyedError unless @ptr
60
60
  ptr_ptr = ::FFI::MemoryPointer.new :pointer
61
61
  ptr_ptr.write_pointer @ptr
62
- ObjectSpace.undefine_finalizer self if @finalizer
63
- @finalizer = nil
62
+ __undef_finalizer if @finalizer
64
63
  @ptr = nil
65
64
  ptr_ptr
66
65
  end
66
+ # Undefines the finalizer for this object.
67
+ # @note Only use this if you need to and can guarantee that the native
68
+ # object will be freed by other means.
69
+ # @return [void]
70
+ def __undef_finalizer
71
+ ObjectSpace.undefine_finalizer self
72
+ @finalizer = nil
73
+ end
67
74
 
68
75
  # Receive C string from socket. Caller must free returned string using
69
76
  # zstr_free(). Returns NULL if the context is being terminated or the
@@ -100,10 +107,9 @@ module CZMQ
100
107
  # may be NULL, which is sent as "".
101
108
  #
102
109
  # @param dest [::FFI::Pointer, #to_ptr]
103
- # @param string [String, #to_str, #to_s]
110
+ # @param string [String, #to_s, nil]
104
111
  # @return [Integer]
105
112
  def self.send(dest, string)
106
- string = String(string)
107
113
  result = ::CZMQ::FFI.zstr_send(dest, string)
108
114
  result
109
115
  end
@@ -112,10 +118,9 @@ module CZMQ
112
118
  # you can send further strings in the same multi-part message.
113
119
  #
114
120
  # @param dest [::FFI::Pointer, #to_ptr]
115
- # @param string [String, #to_str, #to_s]
121
+ # @param string [String, #to_s, nil]
116
122
  # @return [Integer]
117
123
  def self.sendm(dest, string)
118
- string = String(string)
119
124
  result = ::CZMQ::FFI.zstr_sendm(dest, string)
120
125
  result
121
126
  end
@@ -125,11 +130,10 @@ module CZMQ
125
130
  # will create security holes).
126
131
  #
127
132
  # @param dest [::FFI::Pointer, #to_ptr]
128
- # @param format [String, #to_str, #to_s]
133
+ # @param format [String, #to_s, nil]
129
134
  # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
130
135
  # @return [Integer]
131
136
  def self.sendf(dest, format, *args)
132
- format = String(format)
133
137
  result = ::CZMQ::FFI.zstr_sendf(dest, format, *args)
134
138
  result
135
139
  end
@@ -139,11 +143,10 @@ module CZMQ
139
143
  # message.
140
144
  #
141
145
  # @param dest [::FFI::Pointer, #to_ptr]
142
- # @param format [String, #to_str, #to_s]
146
+ # @param format [String, #to_s, nil]
143
147
  # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
144
148
  # @return [Integer]
145
149
  def self.sendfm(dest, format, *args)
146
- format = String(format)
147
150
  result = ::CZMQ::FFI.zstr_sendfm(dest, format, *args)
148
151
  result
149
152
  end
@@ -152,11 +155,10 @@ module CZMQ
152
155
  # Returns 0 if the strings could be sent OK, or -1 on error.
153
156
  #
154
157
  # @param dest [::FFI::Pointer, #to_ptr]
155
- # @param string [String, #to_str, #to_s]
158
+ # @param string [String, #to_s, nil]
156
159
  # @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
157
160
  # @return [Integer]
158
161
  def self.sendx(dest, string, *args)
159
- string = String(string)
160
162
  result = ::CZMQ::FFI.zstr_sendx(dest, string, *args)
161
163
  result
162
164
  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 callback of the following type:
70
77
  # Callback function for ztrie_node to destroy node data.
@@ -104,14 +111,13 @@ module CZMQ
104
111
  # if the route already exists, otherwise 0. This method takes ownership of
105
112
  # the provided data if a destroy_data_fn is provided.
106
113
  #
107
- # @param path [String, #to_str, #to_s]
114
+ # @param path [String, #to_s, nil]
108
115
  # @param data [::FFI::Pointer, #to_ptr]
109
116
  # @param destroy_data_fn [::FFI::Pointer, #to_ptr]
110
117
  # @return [Integer]
111
118
  def insert_route(path, data, destroy_data_fn)
112
119
  raise DestroyedError unless @ptr
113
120
  self_p = @ptr
114
- path = String(path)
115
121
  result = ::CZMQ::FFI.ztrie_insert_route(self_p, path, data, destroy_data_fn)
116
122
  result
117
123
  end
@@ -120,24 +126,22 @@ module CZMQ
120
126
  # route does not exists, otherwise 0.
121
127
  # the start of the list call zlist_first (). Advances the cursor.
122
128
  #
123
- # @param path [String, #to_str, #to_s]
129
+ # @param path [String, #to_s, nil]
124
130
  # @return [Integer]
125
131
  def remove_route(path)
126
132
  raise DestroyedError unless @ptr
127
133
  self_p = @ptr
128
- path = String(path)
129
134
  result = ::CZMQ::FFI.ztrie_remove_route(self_p, path)
130
135
  result
131
136
  end
132
137
 
133
138
  # Returns true if the path matches a route in the tree, otherwise false.
134
139
  #
135
- # @param path [String, #to_str, #to_s]
140
+ # @param path [String, #to_s, nil]
136
141
  # @return [Boolean]
137
142
  def matches(path)
138
143
  raise DestroyedError unless @ptr
139
144
  self_p = @ptr
140
- path = String(path)
141
145
  result = ::CZMQ::FFI.ztrie_matches(self_p, path)
142
146
  result
143
147
  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 UUID object.
70
77
  # @return [CZMQ::Zuuid]
@@ -105,12 +112,11 @@ module CZMQ
105
112
  # Set UUID to new supplied string value skipping '-' and '{' '}'
106
113
  # optional delimiters. Return 0 if OK, else returns -1.
107
114
  #
108
- # @param source [String, #to_str, #to_s]
115
+ # @param source [String, #to_s, nil]
109
116
  # @return [Integer]
110
117
  def set_str(source)
111
118
  raise DestroyedError unless @ptr
112
119
  self_p = @ptr
113
- source = String(source)
114
120
  result = ::CZMQ::FFI.zuuid_set_str(self_p, source)
115
121
  result
116
122
  end
@@ -1,5 +1,5 @@
1
1
  module CZMQ
2
2
  module FFI
3
- GEM_VERSION = "0.2.0"
3
+ GEM_VERSION = "0.2.1"
4
4
  end
5
5
  end
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrik Wenger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-10 00:00:00.000000000 Z
11
+ date: 2015-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi