module GirFFI::ArgHelper

Constants

OBJECT_STORE

Public Class Methods

cast_from_pointer(type, it) click to toggle source
# File lib/gir_ffi/arg_helper.rb, line 28
def self.cast_from_pointer type, it
  case type
  when :utf8, :filename
    it.to_utf8
  when :gint32
    cast_pointer_to_int32 it
  else
    # FIXME: Only handles symbolic types.
    it.address
  end
end
cast_pointer_to_int32(ptr) click to toggle source
# File lib/gir_ffi/arg_helper.rb, line 48
def self.cast_pointer_to_int32 ptr
  cast_uint32_to_int32(ptr.address & 0xffffffff)
end
cast_uint32_to_int32(val) click to toggle source
# File lib/gir_ffi/arg_helper.rb, line 40
def self.cast_uint32_to_int32 val
  if val >= 0x80000000
    -(0x100000000-val)
  else
    val
  end
end
check_error(errpp) click to toggle source
# File lib/gir_ffi/arg_helper.rb, line 17
def self.check_error errpp
  err = GLib::Error.wrap(errpp.read_pointer)
  raise err.message if err
end
check_fixed_array_size(size, arr, name) click to toggle source
# File lib/gir_ffi/arg_helper.rb, line 22
def self.check_fixed_array_size size, arr, name
  unless arr.size == size
    raise ArgumentError, "#{name} should have size #{size}"
  end
end
ptr_to_utf8(ptr) click to toggle source

@deprecated Compatibility function. Remove in 0.7.0.

# File lib/gir_ffi/arg_helper.rb, line 9
def self.ptr_to_utf8 ptr
  ptr.to_utf8
end
ptr_to_utf8_length(ptr, len) click to toggle source
# File lib/gir_ffi/arg_helper.rb, line 13
def self.ptr_to_utf8_length ptr, len
  ptr.null? ? nil : ptr.read_string(len)
end