1################################################################################ 2# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # 3# Read the zproject/README.md for information about making permanent changes. # 4################################################################################ 5 6module CZMQ 7 module FFI 8 9 # List of network interfaces available on system 10 # @note This class is 100% generated using zproject. 11 class Ziflist 12 # Raised when one tries to use an instance of {Ziflist} 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.ziflist_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 # Get a list of network interfaces currently defined on the system 77 # @return [CZMQ::Ziflist] 78 def self.new() 79 ptr = ::CZMQ::FFI.ziflist_new() 80 __new ptr 81 end 82 83 # Destroy a ziflist instance 84 # 85 # @return [void] 86 def destroy() 87 return unless @ptr 88 self_p = __ptr_give_ref 89 result = ::CZMQ::FFI.ziflist_destroy(self_p) 90 result 91 end 92 93 # Reload network interfaces from system 94 # 95 # @return [void] 96 def reload() 97 raise DestroyedError unless @ptr 98 self_p = @ptr 99 result = ::CZMQ::FFI.ziflist_reload(self_p) 100 result 101 end 102 103 # Return the number of network interfaces on system 104 # 105 # @return [Integer] 106 def size() 107 raise DestroyedError unless @ptr 108 self_p = @ptr 109 result = ::CZMQ::FFI.ziflist_size(self_p) 110 result 111 end 112 113 # Get first network interface, return NULL if there are none 114 # 115 # @return [String] 116 def first() 117 raise DestroyedError unless @ptr 118 self_p = @ptr 119 result = ::CZMQ::FFI.ziflist_first(self_p) 120 result 121 end 122 123 # Get next network interface, return NULL if we hit the last one 124 # 125 # @return [String] 126 def next() 127 raise DestroyedError unless @ptr 128 self_p = @ptr 129 result = ::CZMQ::FFI.ziflist_next(self_p) 130 result 131 end 132 133 # Return the current interface IP address as a printable string 134 # 135 # @return [String] 136 def address() 137 raise DestroyedError unless @ptr 138 self_p = @ptr 139 result = ::CZMQ::FFI.ziflist_address(self_p) 140 result 141 end 142 143 # Return the current interface broadcast address as a printable string 144 # 145 # @return [String] 146 def broadcast() 147 raise DestroyedError unless @ptr 148 self_p = @ptr 149 result = ::CZMQ::FFI.ziflist_broadcast(self_p) 150 result 151 end 152 153 # Return the current interface network mask as a printable string 154 # 155 # @return [String] 156 def netmask() 157 raise DestroyedError unless @ptr 158 self_p = @ptr 159 result = ::CZMQ::FFI.ziflist_netmask(self_p) 160 result 161 end 162 163 # Return the list of interfaces. 164 # 165 # @return [void] 166 def print() 167 raise DestroyedError unless @ptr 168 self_p = @ptr 169 result = ::CZMQ::FFI.ziflist_print(self_p) 170 result 171 end 172 173 # Get a list of network interfaces currently defined on the system 174 # Includes IPv6 interfaces 175 # 176 # @return [Ziflist] 177 def self.new_ipv6() 178 result = ::CZMQ::FFI.ziflist_new_ipv6() 179 result = Ziflist.__new result, true 180 result 181 end 182 183 # Reload network interfaces from system, including IPv6 184 # 185 # @return [void] 186 def reload_ipv6() 187 raise DestroyedError unless @ptr 188 self_p = @ptr 189 result = ::CZMQ::FFI.ziflist_reload_ipv6(self_p) 190 result 191 end 192 193 # Return true if the current interface uses IPv6 194 # 195 # @return [Boolean] 196 def is_ipv6() 197 raise DestroyedError unless @ptr 198 self_p = @ptr 199 result = ::CZMQ::FFI.ziflist_is_ipv6(self_p) 200 result 201 end 202 203 # Self test of this class. 204 # 205 # @param verbose [Boolean] 206 # @return [void] 207 def self.test(verbose) 208 verbose = !(0==verbose||!verbose) # boolean 209 result = ::CZMQ::FFI.ziflist_test(verbose) 210 result 211 end 212 end 213 end 214end 215 216################################################################################ 217# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # 218# Read the zproject/README.md for information about making permanent changes. # 219################################################################################ 220