Class: GirFFI::InPointer
- Inherits:
-
FFI::Pointer
- Object
- FFI::Pointer
- GirFFI::InPointer
- Defined in:
- lib/gir_ffi/in_pointer.rb
Overview
The InPointer class handles conversion from ruby types to pointers for arguments with direction :in. This is used for arguments that are arrays, strings, or interfaces.
Class Method Summary collapse
Class Method Details
.from(type, val) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gir_ffi/in_pointer.rb', line 32 def self.from type, val return if !val case type when :utf8, :filename from_utf8 val when :gint32, :guint32, :gint8 new val when Class, :void val.to_ptr when Module new type[val] else raise NotImplementedError, type end end |
.from_array(type, ary) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gir_ffi/in_pointer.rb', line 6 def self.from_array type, ary return if !ary case type when :utf8, :filename from_utf8_array ary when :gboolean from_boolean_array ary when Symbol from_basic_type_array type, ary when Class if type == GObject::Value from_gvalue_array type, ary else from_struct_array type, ary end when Module from_enum_array type, ary when Array main_type, sub_type = *type raise "Unexpected main type #{main_type}" if main_type != :pointer from_pointer_array sub_type, ary else raise NotImplementedError, type end end |
.from_closure_data(obj) ⇒ Object
49 50 51 52 |
# File 'lib/gir_ffi/in_pointer.rb', line 49 def from_closure_data obj FFI::Pointer.new(obj.object_id).tap {|ptr| ArgHelper::OBJECT_STORE.store(ptr, obj) } end |