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, #setup_and_call, setup_and_call, to_callback_ffi_type, try_in_ancestors
#gtype
Methods included from TypeBase
#gir_ffi_builder, #gir_info
#setup_method, #setup_method!
#setup_instance_method, #setup_instance_method!
Class Method Details
.class_struct ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/gir_ffi/object_base.rb', line 67
def self.class_struct
@class_struct ||=
begin
ptr = GObject::Lib.g_type_class_ref(gtype)
gir_ffi_builder.class_struct_class.wrap ptr
end
end
|
.copy_from(val) ⇒ Object
40
41
42
|
# File 'lib/gir_ffi/object_base.rb', line 40
def self.copy_from(val)
val&.ref
end
|
.copy_value_to_pointer(value, pointer, offset = 0) ⇒ Object
30
31
32
|
# File 'lib/gir_ffi/object_base.rb', line 30
def self.copy_value_to_pointer(value, pointer, offset = 0)
pointer.put_pointer offset, value.to_ptr
end
|
Find property info for the named property.
51
52
53
|
# File 'lib/gir_ffi/object_base.rb', line 51
def self.find_property(name)
gir_ffi_builder.find_property name
end
|
Find signal info for the named signal.
62
63
64
65
|
# File 'lib/gir_ffi/object_base.rb', line 62
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
26
27
28
|
# File 'lib/gir_ffi/object_base.rb', line 26
def self.get_value_from_pointer(pointer, offset = 0)
pointer.get_pointer offset
end
|
.included_interfaces ⇒ Object
75
76
77
|
# File 'lib/gir_ffi/object_base.rb', line 75
def self.included_interfaces
included_modules.select { |it| it.singleton_class.include? InterfaceBase }
end
|
.install_property(param_spec) ⇒ Object
92
93
94
95
96
97
98
99
100
|
# File 'lib/gir_ffi/object_base.rb', line 92
def self.install_property(param_spec)
if const_defined? :GIR_FFI_BUILDER, false
raise "Installing a property in a class that is already set up is not supported"
end
prepare_user_defined_class
gir_info.install_property(param_spec)
end
|
.install_vfunc_implementation(name, implementation = nil) ⇒ Object
102
103
104
105
106
107
108
109
110
|
# File 'lib/gir_ffi/object_base.rb', line 102
def self.install_vfunc_implementation(name, implementation = nil)
if const_defined? :GIR_FFI_BUILDER, false
raise "Installing a property in a class that is already set up is not supported"
end
prepare_user_defined_class
gir_info.install_vfunc_implementation(name, implementation)
end
|
.native_type ⇒ Object
14
15
16
|
# File 'lib/gir_ffi/object_base.rb', line 14
def self.native_type
FFI::Type::POINTER
end
|
.prepare_user_defined_class ⇒ Object
85
86
87
88
89
90
|
# File 'lib/gir_ffi/object_base.rb', line 85
def self.prepare_user_defined_class
return if const_defined? :GIR_INFO, false
info = UserDefinedObjectInfo.new(self)
const_set :GIR_INFO, info
end
|
.registered_ancestors ⇒ Object
79
80
81
82
83
|
# File 'lib/gir_ffi/object_base.rb', line 79
def self.registered_ancestors
ancestors.select do |it|
it < GirFFI::ObjectBase || it.singleton_class.include?(InterfaceBase)
end
end
|
.to_ffi_type ⇒ Object
18
19
20
|
# File 'lib/gir_ffi/object_base.rb', line 18
def self.to_ffi_type
self
end
|
.to_native(obj, _context) ⇒ Object
22
23
24
|
# File 'lib/gir_ffi/object_base.rb', line 22
def self.to_native(obj, _context)
obj.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.
36
37
38
|
# File 'lib/gir_ffi/object_base.rb', line 36
def self.wrap(ptr)
ptr.to_object
end
|
Instance Method Details
#class_struct ⇒ Object
10
11
12
|
# File 'lib/gir_ffi/object_base.rb', line 10
def class_struct
self.class.class_struct
end
|