Class: Unarm::RawSymbols

Inherits:
Object
  • Object
show all
Defined in:
lib/unarm/unarm.rb

Overview

symbols that can be passed to Rust

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(syms) ⇒ RawSymbols

Returns a new instance of RawSymbols.



560
561
562
563
564
565
566
567
568
569
570
571
572
573
# File 'lib/unarm/unarm.rb', line 560

def initialize(syms)
  @count = syms.count
  @ptr = FFI::MemoryPointer.new(Symbol, @count)
  sym_arr = @count.times.map do |i|
    Symbol.new(@ptr + i*Symbol.size)
  end
  @name_ptrs = [] # keeps memory for symbol names alive (?)

  syms.map.each_with_index do |(name, addr), i|
    name_ptr = FFI::MemoryPointer.from_string(name)
    @name_ptrs << name_ptr
    sym_arr[i][:name] = name_ptr
    sym_arr[i][:addr] = addr
  end
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



558
559
560
# File 'lib/unarm/unarm.rb', line 558

def count
  @count
end

#ptrObject (readonly)

Returns the value of attribute ptr.



558
559
560
# File 'lib/unarm/unarm.rb', line 558

def ptr
  @ptr
end