Sha256: 84ba77b4c1daf0be3a48ad718277753238c041f83f0cc033dc58ace75ea8fc75

Contents?: true

Size: 633 Bytes

Versions: 5

Compression:

Stored size: 633 Bytes

Contents

# frozen_string_literal: true
require 'ffi'
require 'gir_ffi-base/glib'

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

5 entries across 5 versions & 1 rubygems

Version Path
gir_ffi-0.10.2 lib/gir_ffi-base/glib/boolean.rb
gir_ffi-0.10.1 lib/gir_ffi-base/glib/boolean.rb
gir_ffi-0.10.0 lib/gir_ffi-base/glib/boolean.rb
gir_ffi-0.10.0.pre1 lib/gir_ffi-base/glib/boolean.rb
gir_ffi-0.9.5 lib/gir_ffi-base/glib/boolean.rb