class RubyVM::MJIT::CPointer::Struct

Note: We’d like to avoid alphabetic method names to avoid a conflict with member methods. to_i and to_s are considered an exception.

Public Class Methods

new(addr, sizeof, members) click to toggle source

@param name [String] @param sizeof [Integer] @param members [Hash{ Symbol => [RubyVM::MJIT::CType::*, Integer, TrueClass] }]

# File mjit/c_pointer.rb, line 11
def initialize(addr, sizeof, members)
  @addr = addr
  @sizeof = sizeof
  @members = members

Public Instance Methods

-(struct) click to toggle source

Pointer diff

# File mjit/c_pointer.rb, line 28
def -(struct)
  raise ArgumentError if self.class != struct.class
  (@addr - struct.to_i) / @sizeof
[](member) click to toggle source

Primitive API that does no automatic dereference TODO: remove this? @param member [Symbol]

# File mjit/c_pointer.rb, line 36
def [](member)
  type, offset = @members.fetch(member) + offset / 8)
to_i() click to toggle source

Get a raw address

# File mjit/c_pointer.rb, line 18
def to_i
to_s() click to toggle source

Serialized address for generated code

# File mjit/c_pointer.rb, line 23
def to_s