Class: FFI::ManagedBitStruct

Inherits:
ManagedStruct
  • Object
show all
Extended by:
BitField::ClassMethods
Includes:
BitField::InstanceMethods
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::ClassMethods

bit_field_layout, bit_field_members, bit_field_offsets, bit_fields

Methods included from BitField::InstanceMethods

#[], #[]=, #bit_field_members, #bit_field_offsets