Class: GirFFI::Boolean

Inherits:
Object
  • Object
show all
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

Class Method Details

.copy_value_to_pointer(value, pointer) ⇒ Object



25
26
27
# File 'lib/gir_ffi/boolean.rb', line 25

def self.copy_value_to_pointer(value, pointer)
  pointer.put_int 0, to_native(value, nil)
end

.from_native(value, _context) ⇒ Object



13
14
15
# File 'lib/gir_ffi/boolean.rb', line 13

def self.from_native(value, _context)
  FROM_NATIVE.fetch(value)
end

.get_value_from_pointer(pointer, offset) ⇒ Object



29
30
31
# File 'lib/gir_ffi/boolean.rb', line 29

def self.get_value_from_pointer(pointer, offset)
  from_native pointer.get_int(offset), nil
end

.sizeObject



21
22
23
# File 'lib/gir_ffi/boolean.rb', line 21

def self.size
  FFI.type_size FFI::Type::INT
end

.to_native(value, _context) ⇒ Object



17
18
19
# File 'lib/gir_ffi/boolean.rb', line 17

def self.to_native(value, _context)
  TO_NATIVE.fetch(value)
end