class FFI::AutoPointer
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/ffi/autopointer.rbs class FFI::AutoPointer < FFI::Pointer def initialize: (FFI::Pointer ptr, ?Method proc, ) -> void end
def self.from_native(val, ctx)
-
(AutoPointer)
-
Parameters:
-
ctx
() -- not used. Please set +nil+.
-
ptr
(Pointer
) --
Overloads:
-
self.from_native(ptr, ctx)
def self.from_native(val, ctx) self.new(val) end
def self.native_type
-
(RuntimeError)
- if class does not implement a +#release+ method
Returns:
-
(Type::POINTER)
-
def self.native_type if not self.respond_to?(:release) raise RuntimeError.new("no release method defined for #{self.inspect}") end Type::POINTER end
def autorelease=(autorelease)
-
(Boolean)
- +autorelease+
Parameters:
-
autorelease
(Boolean
) --
def autorelease=(autorelease) @releaser.autorelease=(autorelease) end
def autorelease?
-
(Boolean)
- +autorelease+
def autorelease? @releaser.autorelease end
def free
-
(nil)
-
def free @releaser.free end
def initialize(ptr, proc=nil, &block)
Experimental RBS support (using type sampling data from the type_fusion
project).
def initialize: (FFI::Pointer ptr, ?Method proc, ) -> void
This signature was generated using 77 samples from 4 applications.
- Note: -
Note: - The safest, and therefore preferred, calling
Note: -
Note: - WARNING: passing a proc _may_ cause your pointer to never be
Returns:
-
(self)
- -
(self)
- -
(self)
- -
(self)
-
Parameters:
-
pointer
(Pointer
) -- -
pointer
(Pointer
) -- -
pointer
(Pointer
) -- -
method
(Method
) -- -
pointer
(Pointer
) --
Overloads:
-
initialize(pointer)
-
initialize(pointer) { |p| ... }
-
initialize(pointer, proc)
-
initialize(pointer, method)
Other tags:
- Yieldparam: p - +pointer+ passed to the block
def initialize(ptr, proc=nil, &block) super(ptr.type_size, ptr) raise TypeError, "Invalid pointer" if ptr.nil? || !ptr.kind_of?(Pointer) \ || ptr.kind_of?(MemoryPointer) || ptr.kind_of?(AutoPointer) @releaser = if proc if not proc.respond_to?(:call) raise RuntimeError.new("proc must be callable") end CallableReleaser.new(ptr, proc) else if not self.class.respond_to?(:release) raise RuntimeError.new("no release method defined") end DefaultReleaser.new(ptr, self.class) end ObjectSpace.define_finalizer(self, @releaser) self end