Class: FFI::StructLayout::Mapped

Inherits:
Field
  • Object
show all
Defined in:
lib/ffi/struct_layout.rb

Instance Method Summary collapse

Methods inherited from Field

#alignment, #name, #offset, #size, #type

Constructor Details

#initialize(name, offset, type, orig_field) ⇒ Mapped

Returns a new instance of Mapped.



82
83
84
85
# File 'lib/ffi/struct_layout.rb', line 82

def initialize(name, offset, type, orig_field)
  @orig_field = orig_field
  super(name, offset, type)
end

Instance Method Details

#get(ptr) ⇒ Object



87
88
89
# File 'lib/ffi/struct_layout.rb', line 87

def get(ptr)
  type.from_native(@orig_field.get(ptr), nil)
end

#put(ptr, value) ⇒ Object



91
92
93
# File 'lib/ffi/struct_layout.rb', line 91

def put(ptr, value)
  @orig_field.put(ptr, type.to_native(value, nil))
end