Class: FFI::ManagedBitStruct

Inherits:
ManagedStruct
  • Object
show all
Extended by:
BitField::Layout
Includes:
BitField::Property
Defined in:
lib/ffi/managed_bit_struct.rb

Overview

Subclass of FFI::ManagedStruct that supports bit fields. Combines memory management with bit field functionality.

Use this class when you need automatic memory management for your structs with bit fields. You must implement the self.release method to handle memory cleanup.

Examples:

Define a managed struct with bit fields

class ManagedFlags < FFI::ManagedBitStruct
  layout \
    :value, :uint8

  bit_fields :value,
    :read,    1,
    :write,   1,
    :execute, 1,
    :unused,  5

  def self.release(ptr)
    # Custom memory cleanup code
  end
end

Method Summary

Methods included from BitField::Layout

bit_fields

Methods included from BitField::Property

#[], #[]=