Class: GirFFI::Boolean
- Inherits:
-
Object
- Object
- GirFFI::Boolean
- Extended by:
- FFI::DataConverter
- Defined in:
- lib/gir_ffi/boolean.rb
Overview
Class representing a boolean (natively, an int).
Constant Summary collapse
- FROM_NATIVE =
{ 0 => false, 1 => true }.freeze
- TO_NATIVE =
FROM_NATIVE.invert
Class Method Summary collapse
- .copy_value_to_pointer(value, pointer, offset = 0) ⇒ Object
- .from_native(value, _context) ⇒ Object
- .get_value_from_pointer(pointer, offset) ⇒ Object
- .size ⇒ Object
- .to_native(value, _context) ⇒ Object
Class Method Details
.copy_value_to_pointer(value, pointer, offset = 0) ⇒ Object
26 27 28 |
# File 'lib/gir_ffi/boolean.rb', line 26 def self.copy_value_to_pointer(value, pointer, offset = 0) pointer.put_int offset, to_native(value, nil) end |
.from_native(value, _context) ⇒ Object
14 15 16 |
# File 'lib/gir_ffi/boolean.rb', line 14 def self.from_native(value, _context) FROM_NATIVE.fetch(value) end |
.get_value_from_pointer(pointer, offset) ⇒ Object
30 31 32 |
# File 'lib/gir_ffi/boolean.rb', line 30 def self.get_value_from_pointer(pointer, offset) from_native pointer.get_int(offset), nil end |
.size ⇒ Object
22 23 24 |
# File 'lib/gir_ffi/boolean.rb', line 22 def self.size FFI.type_size FFI::Type::INT end |
.to_native(value, _context) ⇒ Object
18 19 20 |
# File 'lib/gir_ffi/boolean.rb', line 18 def self.to_native(value, _context) TO_NATIVE.fetch(value ? true : false) end |