Module: GirFFI::StructLikeBase::ClassMethods
- Defined in:
- lib/gir_ffi/struct_like_base.rb
Overview
Class methods for struct-like classes.
Instance Method Summary collapse
-
#copy_from(val) ⇒ Object
Create an unowned copy of the struct represented by val.
- #copy_value_to_pointer(value, pointer, offset = 0) ⇒ Object
- #get_value_from_pointer(pointer, offset) ⇒ Object
- #native_type ⇒ Object
- #size ⇒ Object
- #to_ffi_type ⇒ Object
-
#to_native(value, _context) ⇒ Object
NOTE: Needed for JRuby’s FFI.
-
#wrap_copy(val) ⇒ Object
Wrap an owned copy of the struct represented by val.
-
#wrap_own(val) ⇒ Object
Wrap value and take ownership of it.
Instance Method Details
#copy_from(val) ⇒ Object
Create an unowned copy of the struct represented by val
39 40 41 |
# File 'lib/gir_ffi/struct_like_base.rb', line 39 def copy_from(val) disown copy from(val) end |
#copy_value_to_pointer(value, pointer, offset = 0) ⇒ Object
33 34 35 36 |
# File 'lib/gir_ffi/struct_like_base.rb', line 33 def copy_value_to_pointer(value, pointer, offset = 0) bytes = value.to_ptr.read_bytes(size) pointer.put_bytes offset, bytes end |
#get_value_from_pointer(pointer, offset) ⇒ Object
25 26 27 |
# File 'lib/gir_ffi/struct_like_base.rb', line 25 def get_value_from_pointer(pointer, offset) pointer + offset end |
#native_type ⇒ Object
12 13 14 |
# File 'lib/gir_ffi/struct_like_base.rb', line 12 def native_type FFI::Type::Struct.new(self::Struct) end |
#size ⇒ Object
29 30 31 |
# File 'lib/gir_ffi/struct_like_base.rb', line 29 def size self::Struct.size end |
#to_ffi_type ⇒ Object
16 17 18 |
# File 'lib/gir_ffi/struct_like_base.rb', line 16 def to_ffi_type self end |
#to_native(value, _context) ⇒ Object
NOTE: Needed for JRuby’s FFI
21 22 23 |
# File 'lib/gir_ffi/struct_like_base.rb', line 21 def to_native(value, _context) value.struct end |
#wrap_copy(val) ⇒ Object
Wrap an owned copy of the struct represented by val
44 45 46 |
# File 'lib/gir_ffi/struct_like_base.rb', line 44 def wrap_copy(val) own copy(val) end |
#wrap_own(val) ⇒ Object
Wrap value and take ownership of it
49 50 51 |
# File 'lib/gir_ffi/struct_like_base.rb', line 49 def wrap_own(val) own wrap(val) end |