Class: FFI::StructLayout::Enum

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

Overview

An enum Field in a FFI::StructLayout.

Instance Method Summary collapse

Methods inherited from Field

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

Constructor Details

This class inherits a constructor from FFI::StructLayout::Field

Instance Method Details

#get(ptr) ⇒ Object

Get an object of type Field#type from memory pointed by ptr.


56
57
58
# File 'lib/ffi/struct_layout.rb', line 56

def get(ptr)
  type.find(ptr.get_int(offset))
end

#put(ptr, value) ⇒ nil

Set value into memory pointed by ptr.


64
65
66
# File 'lib/ffi/struct_layout.rb', line 64

def put(ptr, value)
  ptr.put_int(offset, type.find(value))
end