Class: TurboRex::CStruct::NativeStructProxy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parser, name) ⇒ NativeStructProxy

Returns a new instance of NativeStructProxy.



545
546
547
548
549
# File 'lib/turborex/cstruct.rb', line 545

def initialize(parser, name)
  @parser = parser
  @name = name
  @size = @sizeof = parser.sizeof(parser.find_c_struct(name))
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



560
561
562
# File 'lib/turborex/cstruct.rb', line 560

def method_missing(m, *args, &block)
  @struct.send(m, *args, &block)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



542
543
544
# File 'lib/turborex/cstruct.rb', line 542

def name
  @name
end

#sizeObject (readonly)

Returns the value of attribute size.



540
541
542
# File 'lib/turborex/cstruct.rb', line 540

def size
  @size
end

#sizeofObject (readonly)

Returns the value of attribute sizeof.



541
542
543
# File 'lib/turborex/cstruct.rb', line 541

def sizeof
  @sizeof
end

#structObject (readonly)

Returns the value of attribute struct.



543
544
545
# File 'lib/turborex/cstruct.rb', line 543

def struct
  @struct
end

Instance Method Details

#from_str(str, offset = 0) ⇒ Object



551
552
553
554
# File 'lib/turborex/cstruct.rb', line 551

def from_str(str, offset = 0)
  struct = @parser.find_c_struct(@name)
  @struct = ::Metasm::C::AllocCStruct.new(@parser, struct, str, offset)
end

#to_sObject



556
557
558
# File 'lib/turborex/cstruct.rb', line 556

def to_s
  @struct.str
end