Class: GirFFI::BoxedBase
- Extended by:
- FFI::DataConverter
- Defined in:
- lib/gir_ffi/boxed_base.rb
Overview
Base class for generated classes representing boxed types.
Direct Known Subclasses
Constant Summary
Constants inherited from ClassBase
Instance Attribute Summary
Attributes inherited from ClassBase
Class Method Summary collapse
- .copy_value_to_pointer(value, pointer, offset = 0) ⇒ Object
- .get_value_from_pointer(pointer, offset) ⇒ Object
- .native_type ⇒ Object
- .to_ffi_type ⇒ Object
-
.to_native(value, _context) ⇒ Object
NOTE: Needed for JRuby’s FFI.
Instance Method Summary collapse
-
#initialize ⇒ BoxedBase
constructor
A new instance of BoxedBase.
Methods inherited from ClassBase
#==, direct_wrap, from, #setup_and_call, setup_and_call, setup_instance_method, setup_method, try_in_ancestors, wrap
Methods included from RegisteredTypeBase
Methods included from TypeBase
Constructor Details
#initialize ⇒ BoxedBase
Returns a new instance of BoxedBase.
35 36 37 |
# File 'lib/gir_ffi/boxed_base.rb', line 35 def initialize @struct = self.class::Struct.new end |
Class Method Details
.copy_value_to_pointer(value, pointer, offset = 0) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/gir_ffi/boxed_base.rb', line 25 def self.copy_value_to_pointer(value, pointer, offset = 0) size = self::Struct.size bytes = if value value.to_ptr.read_bytes(size) else "\x00" * size end pointer.put_bytes offset, bytes, 0, size end |
.get_value_from_pointer(pointer, offset) ⇒ Object
21 22 23 |
# File 'lib/gir_ffi/boxed_base.rb', line 21 def self.get_value_from_pointer(pointer, offset) pointer + offset end |
.native_type ⇒ Object
8 9 10 |
# File 'lib/gir_ffi/boxed_base.rb', line 8 def self.native_type FFI::Type::Struct.new(self::Struct) end |
.to_ffi_type ⇒ Object
12 13 14 |
# File 'lib/gir_ffi/boxed_base.rb', line 12 def self.to_ffi_type self end |
.to_native(value, _context) ⇒ Object
NOTE: Needed for JRuby’s FFI
17 18 19 |
# File 'lib/gir_ffi/boxed_base.rb', line 17 def self.to_native(value, _context) value.struct end |