Class: FFI::StructByReference
- Includes:
- DataConverter
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/lib/ffi/struct_by_reference.rb
Overview
This class includes the DataConverter module.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#struct_class ⇒ Object
readonly
Returns the value of attribute struct_class.
Instance Method Summary collapse
-
#from_native(value, ctx) ⇒ Struct
Create a struct from content of memory
value
. -
#initialize(struct_class) ⇒ StructByReference
constructor
A new instance of StructByReference.
-
#native_type ⇒ Object
Always get Type::POINTER.
-
#to_native(value, ctx) ⇒ AbstractMemory
Pointer on
value
.
Constructor Details
#initialize(struct_class) ⇒ StructByReference
Returns a new instance of StructByReference.
39 40 41 42 43 44 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/lib/ffi/struct_by_reference.rb', line 39 def initialize(struct_class) unless Class === struct_class and struct_class < FFI::Struct raise TypeError, 'wrong type (expected subclass of FFI::Struct)' end @struct_class = struct_class end |
Instance Attribute Details
#struct_class ⇒ Object (readonly)
Returns the value of attribute struct_class.
36 37 38 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/lib/ffi/struct_by_reference.rb', line 36 def struct_class @struct_class end |
Instance Method Details
#from_native(value, ctx) ⇒ Struct
Create a struct from content of memory value
.
68 69 70 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/lib/ffi/struct_by_reference.rb', line 68 def from_native(value, ctx) @struct_class.new(value) end |
#native_type ⇒ Object
Always get Type::POINTER.
47 48 49 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/lib/ffi/struct_by_reference.rb', line 47 def native_type FFI::Type::POINTER end |
#to_native(value, ctx) ⇒ AbstractMemory
Returns Pointer on value
.
54 55 56 57 58 59 60 61 62 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/lib/ffi/struct_by_reference.rb', line 54 def to_native(value, ctx) return Pointer::NULL if value.nil? unless @struct_class === value raise TypeError, "wrong argument type #{value.class} (expected #{@struct_class})" end value.pointer end |