Sha256: 630bb1b78933b6246800794150a774aa546b1ace4b1a58ebd2239505b60b6043

Contents?: true

Size: 575 Bytes

Versions: 6

Compression:

Stored size: 575 Bytes

Contents

require 'ffi'

module GLib
  # Implementation of gboolean
  class Boolean
    extend FFI::DataConverter
    native_type FFI::Type::INT

    def self.from_native(value, _context)
      value != 0 ? true : false
    end

    def self.to_native(value, _context)
      value ? 1 : 0
    end

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

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gir_ffi-0.9.2 lib/gir_ffi-base/glib/boolean.rb
gir_ffi-0.9.1 lib/gir_ffi-base/glib/boolean.rb
gir_ffi-0.9.0 lib/gir_ffi-base/glib/boolean.rb
gir_ffi-0.8.6 lib/gir_ffi-base/glib/boolean.rb
gir_ffi-0.8.5 lib/gir_ffi-base/glib/boolean.rb
gir_ffi-0.8.4 lib/gir_ffi-base/glib/boolean.rb