class FFI::MemoryPointer

@private

Public Class Methods

monkey_patch_type_i_need!(which) click to toggle source

monkey patch a read_size_t and write_size_t method onto FFI::MemoryPointer. see github.com/ffi/ffi/issues/118

# File lib/systemd/ffi_size_t.rb, line 7
def self.monkey_patch_type_i_need!(which)
  return if self.respond_to?("read_#{which}")

  type = FFI.find_type(which)
  type, _ = FFI::TypeDefs.find do |(name, t)|
    method_defined?("read_#{name}") if t == type
  end

  raise "Unable to patch in reader/writer for #{which}" if type.nil?

  alias_method "read_#{which}", "read_#{type}"
  alias_method "write_#{which}", "write_#{type}"
end