Class: GirFFI::ObjectBase

Inherits:
ClassBase show all
Extended by:
FFI::DataConverter
Defined in:
lib/gir_ffi/object_base.rb

Overview

Base class for all generated classes of type :object.

Constant Summary

Constants inherited from ClassBase

ClassBase::GIR_FFI_BUILDER

Instance Attribute Summary

Attributes inherited from ClassBase

#struct

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ClassBase

#==, direct_wrap, from, #initialize, setup_and_call, #setup_and_call, setup_instance_method, setup_method, try_in_ancestors

Methods included from RegisteredTypeBase

#gtype

Methods included from TypeBase

#gir_ffi_builder, #gir_info

Constructor Details

This class inherits a constructor from GirFFI::ClassBase

Class Method Details

.copy_value_to_pointer(value, pointer, offset = 0) ⇒ Object



28
29
30
# File 'lib/gir_ffi/object_base.rb', line 28

def self.copy_value_to_pointer(value, pointer, offset = 0)
  pointer.put_pointer offset, value.to_ptr
end

.find_property(name) ⇒ GObjectIntrospection::IPropertyInfo

Find property info for the named property.

Parameters:

  • name

    The property’s name

Returns:



45
46
47
48
# File 'lib/gir_ffi/object_base.rb', line 45

def self.find_property(name)
  gir_ffi_builder.find_property name or
    raise GirFFI::PropertyNotFoundError.new(name, self)
end

.find_signal(name) ⇒ GObjectIntrospection::ISignalInfo

Find signal info for the named signal.

Parameters:

  • name

    The signal’s name

Returns:



57
58
59
60
# File 'lib/gir_ffi/object_base.rb', line 57

def self.find_signal(name)
  gir_ffi_builder.find_signal name or
    raise GirFFI::SignalNotFoundError.new(name, self)
end

.get_value_from_pointer(pointer, offset = 0) ⇒ Object



24
25
26
# File 'lib/gir_ffi/object_base.rb', line 24

def self.get_value_from_pointer(pointer, offset = 0)
  pointer.get_pointer offset
end

.native_typeObject



12
13
14
# File 'lib/gir_ffi/object_base.rb', line 12

def self.native_type
  FFI::Type::POINTER
end

.object_classObject



62
63
64
65
66
67
68
# File 'lib/gir_ffi/object_base.rb', line 62

def self.object_class
  @object_class ||=
    begin
      ptr = GObject.type_class_ref(gtype).to_ptr
      gir_ffi_builder.object_class_struct.wrap ptr
    end
end

.to_ffi_typeObject



16
17
18
# File 'lib/gir_ffi/object_base.rb', line 16

def self.to_ffi_type
  self
end

.to_native(it, _) ⇒ Object



20
21
22
# File 'lib/gir_ffi/object_base.rb', line 20

def self.to_native(it, _)
  it.to_ptr
end

.wrap(ptr) ⇒ Object

Wrap the passed pointer in an instance of its type’s corresponding class, generally assumed to be a descendant of the current type.



34
35
36
# File 'lib/gir_ffi/object_base.rb', line 34

def self.wrap(ptr)
  ptr.to_object
end

Instance Method Details

#object_classObject



8
9
10
# File 'lib/gir_ffi/object_base.rb', line 8

def object_class
  self.class.object_class
end