Class: GObject::Value
- Inherits:
-
Object
- Object
- GObject::Value
- Includes:
- Overrides
- Defined in:
- lib/ffi-gobject/value.rb
Overview
Overrides for GValue, GObject’s generic value container structure.
Defined Under Namespace
Modules: Overrides
Constant Summary collapse
- METHOD_MAP =
{ TYPE_INVALID => [:get_none, :set_none], # TYPE_NONE is skipped TYPE_INTERFACE => [:get_object, :set_instance_enhanced], TYPE_CHAR => [:get_schar, :set_schar], TYPE_UCHAR => [:get_uchar, :set_uchar], TYPE_BOOLEAN => [:get_boolean, :set_boolean], TYPE_INT => [:get_int, :set_int], TYPE_UINT => [:get_uint, :set_uint], TYPE_LONG => [:get_long, :set_long], TYPE_ULONG => [:get_ulong, :set_ulong], TYPE_INT64 => [:get_int64, :set_int64], TYPE_UINT64 => [:get_uint64, :set_uint64], TYPE_ENUM => [:get_enum_enhanced, :set_enum_enhanced], TYPE_FLAGS => [:get_flags_enhanced, :set_flags_enhanced], TYPE_FLOAT => [:get_float, :set_float], TYPE_DOUBLE => [:get_double, :set_double], TYPE_STRING => [:get_string, :set_string], TYPE_POINTER => [:get_pointer, :set_pointer], TYPE_BOXED => [:get_boxed, :set_boxed], TYPE_PARAM => [:get_param, :set_param], TYPE_OBJECT => [:get_object, :set_instance_enhanced], TYPE_GTYPE => [:get_gtype, :set_gtype], TYPE_VARIANT => [:get_variant, :set_variant] }.freeze
- CLASS_TO_GTYPE_MAP =
{ NilClass => TYPE_INVALID, TrueClass => TYPE_BOOLEAN, FalseClass => TYPE_BOOLEAN, Integer => TYPE_INT, String => TYPE_STRING }.freeze
Class Method Summary collapse
- .copy_value_to_pointer(value, pointer, offset = 0) ⇒ Object
- .for_gtype(gtype) ⇒ Object
- .from(val) ⇒ Object
-
.wrap_instance(instance) ⇒ Object
TODO: Combine with wrap_ruby_value.
-
.wrap_ruby_value(val) ⇒ Object
TODO: Give more generic name.
Methods included from Overrides
#current_fundamental_type, #current_gtype, #current_gtype_name, #get_value, #get_value_plain, #init, #set_value, #uninitialized?
Class Method Details
.copy_value_to_pointer(value, pointer, offset = 0) ⇒ Object
64 65 66 67 68 |
# File 'lib/ffi-gobject/value.rb', line 64 def self.copy_value_to_pointer(value, pointer, offset = 0) target = wrap(pointer + offset) target.init(value.current_gtype) Lib.g_value_copy value, target unless value.uninitialized? end |
.for_gtype(gtype) ⇒ Object
50 51 52 53 54 |
# File 'lib/ffi-gobject/value.rb', line 50 def self.for_gtype(gtype) new.tap do |it| it.init gtype end end |
.from(val) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/ffi-gobject/value.rb', line 41 def self.from(val) case val when self val else wrap_ruby_value val end end |
.wrap_instance(instance) ⇒ Object
TODO: Combine with wrap_ruby_value
57 58 59 60 61 62 |
# File 'lib/ffi-gobject/value.rb', line 57 def self.wrap_instance(instance) new.tap do |it| it.init GObject.type_from_instance instance it.set_instance instance end end |
.wrap_ruby_value(val) ⇒ Object
TODO: Give more generic name
37 38 39 |
# File 'lib/ffi-gobject/value.rb', line 37 def self.wrap_ruby_value(val) new.tap { |gv| gv.__send__ :set_ruby_value, val } end |