Sha256: 5c3ad029c65468cf30017988e0ea4c47f2884a6d690b4e2155d34d6eb641f684

Contents?: true

Size: 544 Bytes

Versions: 5

Compression:

Stored size: 544 Bytes

Contents

require 'gir_ffi/class_base'

module GirFFI
  # Base class for generated classes representing GLib structs.
  class StructBase < ClassBase
    extend FFI::DataConverter

    def self.native_type
      FFI::Type::Struct.new(self::Struct)
    end

    def self.to_ffitype
      self
    end

    def self.get_value_from_pointer pointer
      pointer.to_ptr
    end

    def self.copy_value_to_pointer value, pointer, offset=0
      size = self::Struct.size
      pointer.put_bytes offset, value.to_ptr.read_bytes(size), 0, size
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gir_ffi-0.7.4 lib/gir_ffi/struct_base.rb
gir_ffi-0.7.3 lib/gir_ffi/struct_base.rb
gir_ffi-0.7.2 lib/gir_ffi/struct_base.rb
gir_ffi-0.7.1 lib/gir_ffi/struct_base.rb
gir_ffi-0.7.0 lib/gir_ffi/struct_base.rb