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,201 @@
|
|
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
|
+
# sending and receiving strings
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Zstr
|
12
|
+
# Raised when one tries to use an instance of {Zstr} 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
|
+
# @return [Proc]
|
34
|
+
def self.create_finalizer_for(ptr)
|
35
|
+
Proc.new do
|
36
|
+
"WARNING: "\
|
37
|
+
"Objects of type #{self} cannot be destroyed implicitly. "\
|
38
|
+
"Please call the correct destroy method with the relevant arguments."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
# @return [Boolean]
|
42
|
+
def null?
|
43
|
+
!@ptr or @ptr.null?
|
44
|
+
end
|
45
|
+
# Return internal pointer
|
46
|
+
# @return [::FFI::Pointer]
|
47
|
+
def __ptr
|
48
|
+
raise DestroyedError unless @ptr
|
49
|
+
@ptr
|
50
|
+
end
|
51
|
+
# So external Libraries can just pass the Object to a FFI function which expects a :pointer
|
52
|
+
alias_method :to_ptr, :__ptr
|
53
|
+
# Nullify internal pointer and return pointer pointer.
|
54
|
+
# @note This detaches the current instance from the native object
|
55
|
+
# and thus makes it unusable.
|
56
|
+
# @return [::FFI::MemoryPointer] the pointer pointing to a pointer
|
57
|
+
# pointing to the native object
|
58
|
+
def __ptr_give_ref
|
59
|
+
raise DestroyedError unless @ptr
|
60
|
+
ptr_ptr = ::FFI::MemoryPointer.new :pointer
|
61
|
+
ptr_ptr.write_pointer @ptr
|
62
|
+
ObjectSpace.undefine_finalizer self if @finalizer
|
63
|
+
@finalizer = nil
|
64
|
+
@ptr = nil
|
65
|
+
ptr_ptr
|
66
|
+
end
|
67
|
+
|
68
|
+
# Receive C string from socket. Caller must free returned string using
|
69
|
+
# zstr_free(). Returns NULL if the context is being terminated or the
|
70
|
+
# process was interrupted.
|
71
|
+
#
|
72
|
+
# @param source [::FFI::Pointer, #to_ptr]
|
73
|
+
# @return [::FFI::AutoPointer]
|
74
|
+
def self.recv(source)
|
75
|
+
result = ::CZMQ::FFI.zstr_recv(source)
|
76
|
+
result = ::FFI::AutoPointer.new(result, LibC.method(:free))
|
77
|
+
result
|
78
|
+
end
|
79
|
+
|
80
|
+
# Receive a series of strings (until NULL) from multipart data.
|
81
|
+
# Each string is allocated and filled with string data; if there
|
82
|
+
# are not enough frames, unallocated strings are set to NULL.
|
83
|
+
# Returns -1 if the message could not be read, else returns the
|
84
|
+
# number of strings filled, zero or more. Free each returned string
|
85
|
+
# using zstr_free(). If not enough strings are provided, remaining
|
86
|
+
# multipart frames in the message are dropped.
|
87
|
+
#
|
88
|
+
# @param source [::FFI::Pointer, #to_ptr]
|
89
|
+
# @param string_p [::FFI::Pointer, #to_ptr]
|
90
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
91
|
+
# @return [Integer]
|
92
|
+
def self.recvx(source, string_p, *args)
|
93
|
+
result = ::CZMQ::FFI.zstr_recvx(source, string_p, *args)
|
94
|
+
result
|
95
|
+
end
|
96
|
+
|
97
|
+
# Send a C string to a socket, as a frame. The string is sent without
|
98
|
+
# trailing null byte; to read this you can use zstr_recv, or a similar
|
99
|
+
# method that adds a null terminator on the received string. String
|
100
|
+
# may be NULL, which is sent as "".
|
101
|
+
#
|
102
|
+
# @param dest [::FFI::Pointer, #to_ptr]
|
103
|
+
# @param string [String, #to_str, #to_s]
|
104
|
+
# @return [Integer]
|
105
|
+
def self.send(dest, string)
|
106
|
+
string = String(string)
|
107
|
+
result = ::CZMQ::FFI.zstr_send(dest, string)
|
108
|
+
result
|
109
|
+
end
|
110
|
+
|
111
|
+
# Send a C string to a socket, as zstr_send(), with a MORE flag, so that
|
112
|
+
# you can send further strings in the same multi-part message.
|
113
|
+
#
|
114
|
+
# @param dest [::FFI::Pointer, #to_ptr]
|
115
|
+
# @param string [String, #to_str, #to_s]
|
116
|
+
# @return [Integer]
|
117
|
+
def self.sendm(dest, string)
|
118
|
+
string = String(string)
|
119
|
+
result = ::CZMQ::FFI.zstr_sendm(dest, string)
|
120
|
+
result
|
121
|
+
end
|
122
|
+
|
123
|
+
# Send a formatted string to a socket. Note that you should NOT use
|
124
|
+
# user-supplied strings in the format (they may contain '%' which
|
125
|
+
# will create security holes).
|
126
|
+
#
|
127
|
+
# @param dest [::FFI::Pointer, #to_ptr]
|
128
|
+
# @param format [String, #to_str, #to_s]
|
129
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
130
|
+
# @return [Integer]
|
131
|
+
def self.sendf(dest, format, *args)
|
132
|
+
format = String(format)
|
133
|
+
result = ::CZMQ::FFI.zstr_sendf(dest, format, *args)
|
134
|
+
result
|
135
|
+
end
|
136
|
+
|
137
|
+
# Send a formatted string to a socket, as for zstr_sendf(), with a
|
138
|
+
# MORE flag, so that you can send further strings in the same multi-part
|
139
|
+
# message.
|
140
|
+
#
|
141
|
+
# @param dest [::FFI::Pointer, #to_ptr]
|
142
|
+
# @param format [String, #to_str, #to_s]
|
143
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
144
|
+
# @return [Integer]
|
145
|
+
def self.sendfm(dest, format, *args)
|
146
|
+
format = String(format)
|
147
|
+
result = ::CZMQ::FFI.zstr_sendfm(dest, format, *args)
|
148
|
+
result
|
149
|
+
end
|
150
|
+
|
151
|
+
# Send a series of strings (until NULL) as multipart data
|
152
|
+
# Returns 0 if the strings could be sent OK, or -1 on error.
|
153
|
+
#
|
154
|
+
# @param dest [::FFI::Pointer, #to_ptr]
|
155
|
+
# @param string [String, #to_str, #to_s]
|
156
|
+
# @param args [Array<Object>] see https://github.com/ffi/ffi/wiki/examples#using-varargs
|
157
|
+
# @return [Integer]
|
158
|
+
def self.sendx(dest, string, *args)
|
159
|
+
string = String(string)
|
160
|
+
result = ::CZMQ::FFI.zstr_sendx(dest, string, *args)
|
161
|
+
result
|
162
|
+
end
|
163
|
+
|
164
|
+
# Accepts a void pointer and returns a fresh character string. If source
|
165
|
+
# is null, returns an empty string.
|
166
|
+
#
|
167
|
+
# @param source [::FFI::Pointer, #to_ptr]
|
168
|
+
# @return [::FFI::AutoPointer]
|
169
|
+
def self.str(source)
|
170
|
+
result = ::CZMQ::FFI.zstr_str(source)
|
171
|
+
result = ::FFI::AutoPointer.new(result, LibC.method(:free))
|
172
|
+
result
|
173
|
+
end
|
174
|
+
|
175
|
+
# Free a provided string, and nullify the parent pointer. Safe to call on
|
176
|
+
# a null pointer.
|
177
|
+
#
|
178
|
+
# @param string_p [::FFI::Pointer, #to_ptr]
|
179
|
+
# @return [void]
|
180
|
+
def self.free(string_p)
|
181
|
+
result = ::CZMQ::FFI.zstr_free(string_p)
|
182
|
+
result
|
183
|
+
end
|
184
|
+
|
185
|
+
# Self test of this class.
|
186
|
+
#
|
187
|
+
# @param verbose [Boolean]
|
188
|
+
# @return [void]
|
189
|
+
def self.test(verbose)
|
190
|
+
verbose = !(0==verbose||!verbose) # boolean
|
191
|
+
result = ::CZMQ::FFI.zstr_test(verbose)
|
192
|
+
result
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
################################################################################
|
199
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
200
|
+
# Please refer to the README for information about making permanent changes. #
|
201
|
+
################################################################################
|
@@ -0,0 +1,217 @@
|
|
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
|
+
# simple trie for tokenizable strings
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Ztrie
|
12
|
+
# Raised when one tries to use an instance of {Ztrie} 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.ztrie_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
|
+
# Callback function for ztrie_node to destroy node data.
|
71
|
+
# typedef void (ztrie_destroy_data_fn) (
|
72
|
+
# void **data);
|
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.destroy_data_fn
|
79
|
+
::FFI::Function.new :void, [:pointer], blocking: true do |data|
|
80
|
+
result = yield data
|
81
|
+
result
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Creates a new ztrie.
|
86
|
+
# @param delimiter [::FFI::Pointer, #to_ptr]
|
87
|
+
# @return [CZMQ::Ztrie]
|
88
|
+
def self.new(delimiter)
|
89
|
+
ptr = ::CZMQ::FFI.ztrie_new(delimiter)
|
90
|
+
__new ptr
|
91
|
+
end
|
92
|
+
|
93
|
+
# Destroy the ztrie.
|
94
|
+
#
|
95
|
+
# @return [void]
|
96
|
+
def destroy()
|
97
|
+
return unless @ptr
|
98
|
+
self_p = __ptr_give_ref
|
99
|
+
result = ::CZMQ::FFI.ztrie_destroy(self_p)
|
100
|
+
result
|
101
|
+
end
|
102
|
+
|
103
|
+
# Inserts a new route into the tree and attaches the data. Returns -1
|
104
|
+
# if the route already exists, otherwise 0. This method takes ownership of
|
105
|
+
# the provided data if a destroy_data_fn is provided.
|
106
|
+
#
|
107
|
+
# @param path [String, #to_str, #to_s]
|
108
|
+
# @param data [::FFI::Pointer, #to_ptr]
|
109
|
+
# @param destroy_data_fn [::FFI::Pointer, #to_ptr]
|
110
|
+
# @return [Integer]
|
111
|
+
def insert_route(path, data, destroy_data_fn)
|
112
|
+
raise DestroyedError unless @ptr
|
113
|
+
self_p = @ptr
|
114
|
+
path = String(path)
|
115
|
+
result = ::CZMQ::FFI.ztrie_insert_route(self_p, path, data, destroy_data_fn)
|
116
|
+
result
|
117
|
+
end
|
118
|
+
|
119
|
+
# Removes a route from the trie and destroys its data. Returns -1 if the
|
120
|
+
# route does not exists, otherwise 0.
|
121
|
+
# the start of the list call zlist_first (). Advances the cursor.
|
122
|
+
#
|
123
|
+
# @param path [String, #to_str, #to_s]
|
124
|
+
# @return [Integer]
|
125
|
+
def remove_route(path)
|
126
|
+
raise DestroyedError unless @ptr
|
127
|
+
self_p = @ptr
|
128
|
+
path = String(path)
|
129
|
+
result = ::CZMQ::FFI.ztrie_remove_route(self_p, path)
|
130
|
+
result
|
131
|
+
end
|
132
|
+
|
133
|
+
# Returns true if the path matches a route in the tree, otherwise false.
|
134
|
+
#
|
135
|
+
# @param path [String, #to_str, #to_s]
|
136
|
+
# @return [Boolean]
|
137
|
+
def matches(path)
|
138
|
+
raise DestroyedError unless @ptr
|
139
|
+
self_p = @ptr
|
140
|
+
path = String(path)
|
141
|
+
result = ::CZMQ::FFI.ztrie_matches(self_p, path)
|
142
|
+
result
|
143
|
+
end
|
144
|
+
|
145
|
+
# Returns the data of a matched route from last ztrie_matches. If the path
|
146
|
+
# did not match, returns NULL. Do not delete the data as it's owned by
|
147
|
+
# ztrie.
|
148
|
+
#
|
149
|
+
# @return [::FFI::Pointer]
|
150
|
+
def hit_data()
|
151
|
+
raise DestroyedError unless @ptr
|
152
|
+
self_p = @ptr
|
153
|
+
result = ::CZMQ::FFI.ztrie_hit_data(self_p)
|
154
|
+
result
|
155
|
+
end
|
156
|
+
|
157
|
+
# Returns the count of parameters that a matched route has.
|
158
|
+
#
|
159
|
+
# @return [Integer]
|
160
|
+
def hit_parameter_count()
|
161
|
+
raise DestroyedError unless @ptr
|
162
|
+
self_p = @ptr
|
163
|
+
result = ::CZMQ::FFI.ztrie_hit_parameter_count(self_p)
|
164
|
+
result
|
165
|
+
end
|
166
|
+
|
167
|
+
# Returns the parameters of a matched route with named regexes from last
|
168
|
+
# ztrie_matches. If the path did not match or the route did not contain any
|
169
|
+
# named regexes, returns NULL.
|
170
|
+
#
|
171
|
+
# @return [Zhashx]
|
172
|
+
def hit_parameters()
|
173
|
+
raise DestroyedError unless @ptr
|
174
|
+
self_p = @ptr
|
175
|
+
result = ::CZMQ::FFI.ztrie_hit_parameters(self_p)
|
176
|
+
result = Zhashx.__new result, false
|
177
|
+
result
|
178
|
+
end
|
179
|
+
|
180
|
+
# Returns the asterisk matched part of a route, if there has been no match
|
181
|
+
# or no asterisk match, returns NULL.
|
182
|
+
#
|
183
|
+
# @return [String]
|
184
|
+
def hit_asterisk_match()
|
185
|
+
raise DestroyedError unless @ptr
|
186
|
+
self_p = @ptr
|
187
|
+
result = ::CZMQ::FFI.ztrie_hit_asterisk_match(self_p)
|
188
|
+
result
|
189
|
+
end
|
190
|
+
|
191
|
+
# Print the trie
|
192
|
+
#
|
193
|
+
# @return [void]
|
194
|
+
def print()
|
195
|
+
raise DestroyedError unless @ptr
|
196
|
+
self_p = @ptr
|
197
|
+
result = ::CZMQ::FFI.ztrie_print(self_p)
|
198
|
+
result
|
199
|
+
end
|
200
|
+
|
201
|
+
# Self test of this class.
|
202
|
+
#
|
203
|
+
# @param verbose [Boolean]
|
204
|
+
# @return [void]
|
205
|
+
def self.test(verbose)
|
206
|
+
verbose = !(0==verbose||!verbose) # boolean
|
207
|
+
result = ::CZMQ::FFI.ztrie_test(verbose)
|
208
|
+
result
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
################################################################################
|
215
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
216
|
+
# Please refer to the README for information about making permanent changes. #
|
217
|
+
################################################################################
|
@@ -0,0 +1,221 @@
|
|
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
|
+
# UUID support class
|
10
|
+
# @note This class is 100% generated using zproject.
|
11
|
+
class Zuuid
|
12
|
+
# Raised when one tries to use an instance of {Zuuid} 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.zuuid_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 UUID object.
|
70
|
+
# @return [CZMQ::Zuuid]
|
71
|
+
def self.new()
|
72
|
+
ptr = ::CZMQ::FFI.zuuid_new()
|
73
|
+
__new ptr
|
74
|
+
end
|
75
|
+
|
76
|
+
# Create UUID object from supplied ZUUID_LEN-octet value.
|
77
|
+
# @param source [::FFI::Pointer, #to_ptr]
|
78
|
+
# @return [CZMQ::Zuuid]
|
79
|
+
def self.new_from(source)
|
80
|
+
ptr = ::CZMQ::FFI.zuuid_new_from(source)
|
81
|
+
__new ptr
|
82
|
+
end
|
83
|
+
|
84
|
+
# Destroy a specified UUID object.
|
85
|
+
#
|
86
|
+
# @return [void]
|
87
|
+
def destroy()
|
88
|
+
return unless @ptr
|
89
|
+
self_p = __ptr_give_ref
|
90
|
+
result = ::CZMQ::FFI.zuuid_destroy(self_p)
|
91
|
+
result
|
92
|
+
end
|
93
|
+
|
94
|
+
# Set UUID to new supplied ZUUID_LEN-octet value.
|
95
|
+
#
|
96
|
+
# @param source [::FFI::Pointer, #to_ptr]
|
97
|
+
# @return [void]
|
98
|
+
def set(source)
|
99
|
+
raise DestroyedError unless @ptr
|
100
|
+
self_p = @ptr
|
101
|
+
result = ::CZMQ::FFI.zuuid_set(self_p, source)
|
102
|
+
result
|
103
|
+
end
|
104
|
+
|
105
|
+
# Set UUID to new supplied string value skipping '-' and '{' '}'
|
106
|
+
# optional delimiters. Return 0 if OK, else returns -1.
|
107
|
+
#
|
108
|
+
# @param source [String, #to_str, #to_s]
|
109
|
+
# @return [Integer]
|
110
|
+
def set_str(source)
|
111
|
+
raise DestroyedError unless @ptr
|
112
|
+
self_p = @ptr
|
113
|
+
source = String(source)
|
114
|
+
result = ::CZMQ::FFI.zuuid_set_str(self_p, source)
|
115
|
+
result
|
116
|
+
end
|
117
|
+
|
118
|
+
# Return UUID binary data.
|
119
|
+
#
|
120
|
+
# @return [::FFI::Pointer]
|
121
|
+
def data()
|
122
|
+
raise DestroyedError unless @ptr
|
123
|
+
self_p = @ptr
|
124
|
+
result = ::CZMQ::FFI.zuuid_data(self_p)
|
125
|
+
result
|
126
|
+
end
|
127
|
+
|
128
|
+
# Return UUID binary size
|
129
|
+
#
|
130
|
+
# @return [Integer]
|
131
|
+
def size()
|
132
|
+
raise DestroyedError unless @ptr
|
133
|
+
self_p = @ptr
|
134
|
+
result = ::CZMQ::FFI.zuuid_size(self_p)
|
135
|
+
result
|
136
|
+
end
|
137
|
+
|
138
|
+
# Returns UUID as string
|
139
|
+
#
|
140
|
+
# @return [String]
|
141
|
+
def str()
|
142
|
+
raise DestroyedError unless @ptr
|
143
|
+
self_p = @ptr
|
144
|
+
result = ::CZMQ::FFI.zuuid_str(self_p)
|
145
|
+
result
|
146
|
+
end
|
147
|
+
|
148
|
+
# Return UUID in the canonical string format: 8-4-4-4-12, in lower
|
149
|
+
# case. Caller does not modify or free returned value. See
|
150
|
+
# http://en.wikipedia.org/wiki/Universally_unique_identifier
|
151
|
+
#
|
152
|
+
# @return [String]
|
153
|
+
def str_canonical()
|
154
|
+
raise DestroyedError unless @ptr
|
155
|
+
self_p = @ptr
|
156
|
+
result = ::CZMQ::FFI.zuuid_str_canonical(self_p)
|
157
|
+
result
|
158
|
+
end
|
159
|
+
|
160
|
+
# Store UUID blob in target array
|
161
|
+
#
|
162
|
+
# @param target [::FFI::Pointer, #to_ptr]
|
163
|
+
# @return [void]
|
164
|
+
def export(target)
|
165
|
+
raise DestroyedError unless @ptr
|
166
|
+
self_p = @ptr
|
167
|
+
result = ::CZMQ::FFI.zuuid_export(self_p, target)
|
168
|
+
result
|
169
|
+
end
|
170
|
+
|
171
|
+
# Check if UUID is same as supplied value
|
172
|
+
#
|
173
|
+
# @param compare [::FFI::Pointer, #to_ptr]
|
174
|
+
# @return [Boolean]
|
175
|
+
def eq(compare)
|
176
|
+
raise DestroyedError unless @ptr
|
177
|
+
self_p = @ptr
|
178
|
+
result = ::CZMQ::FFI.zuuid_eq(self_p, compare)
|
179
|
+
result
|
180
|
+
end
|
181
|
+
|
182
|
+
# Check if UUID is different from supplied value
|
183
|
+
#
|
184
|
+
# @param compare [::FFI::Pointer, #to_ptr]
|
185
|
+
# @return [Boolean]
|
186
|
+
def neq(compare)
|
187
|
+
raise DestroyedError unless @ptr
|
188
|
+
self_p = @ptr
|
189
|
+
result = ::CZMQ::FFI.zuuid_neq(self_p, compare)
|
190
|
+
result
|
191
|
+
end
|
192
|
+
|
193
|
+
# Make copy of UUID object; if uuid is null, or memory was exhausted,
|
194
|
+
# returns null.
|
195
|
+
#
|
196
|
+
# @return [Zuuid]
|
197
|
+
def dup()
|
198
|
+
raise DestroyedError unless @ptr
|
199
|
+
self_p = @ptr
|
200
|
+
result = ::CZMQ::FFI.zuuid_dup(self_p)
|
201
|
+
result = Zuuid.__new result, false
|
202
|
+
result
|
203
|
+
end
|
204
|
+
|
205
|
+
# Self test of this class.
|
206
|
+
#
|
207
|
+
# @param verbose [Boolean]
|
208
|
+
# @return [void]
|
209
|
+
def self.test(verbose)
|
210
|
+
verbose = !(0==verbose||!verbose) # boolean
|
211
|
+
result = ::CZMQ::FFI.zuuid_test(verbose)
|
212
|
+
result
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
################################################################################
|
219
|
+
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
|
220
|
+
# Please refer to the README for information about making permanent changes. #
|
221
|
+
################################################################################
|