Module: FFI::StructWrapper
- Extended by:
- Accessors::ClassMethods, ClassMethods
- Includes:
- Accessors
- Included in:
- Libfuse::FuseBuf, Libfuse::FuseFileInfo, Stat
- Defined in:
- lib/ffi/struct_wrapper.rb
Overview
Helper to wrap structs with ugly names and attribute clashes with FFI::Struct (eg size)
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#native ⇒ FFI::Struct
readonly
The underlying native struct.
Instance Method Summary collapse
-
#[](member_or_attr) ⇒ Object
Get attribute.
-
#[]=(member_or_attr, val) ⇒ Object
Set attribute.
-
#method_missing(method, *args) ⇒ Object
Pass unimplemented methods on to #native underlying struct.
Methods included from ClassMethods
Methods included from Accessors::ClassMethods
attr_accessor, attr_reader, attr_writer, ffi_attr_accessor, ffi_attr_reader, ffi_attr_reader_method, ffi_attr_readers, ffi_attr_writer, ffi_attr_writer_method, ffi_attr_writers, ffi_bitflag_accessor, ffi_bitflag_reader, ffi_bitflag_writer, ffi_public_attr_readers, ffi_public_attr_writers
Methods included from Accessors
#ffi_attr_fill, #ffi_attr_reader_member, #ffi_attr_writer_member, #fill, #inspect, #to_h
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Pass unimplemented methods on to #native underlying struct
114 115 116 |
# File 'lib/ffi/struct_wrapper.rb', line 114 def method_missing(method, *args) @native.send(method, *args) end |
Instance Attribute Details
#native ⇒ FFI::Struct (readonly)
Returns the underlying native struct.
94 95 96 |
# File 'lib/ffi/struct_wrapper.rb', line 94 def native @native end |
Instance Method Details
#[](member_or_attr) ⇒ Object
Get attribute
102 103 104 105 |
# File 'lib/ffi/struct_wrapper.rb', line 102 def [](member_or_attr) _attr, member = ffi_attr_reader_member(member_or_attr, member_or_attr) @native[member] end |
#[]=(member_or_attr, val) ⇒ Object
Set attribute
108 109 110 111 |
# File 'lib/ffi/struct_wrapper.rb', line 108 def []=(member_or_attr, val) _attr, member = ffi_attr_writer_member(member_or_attr, member_or_attr) @native[member] = val end |