Class: Ragweed::Wraposx::ThreadContext::Exception

Inherits:
FFI::Struct
  • Object
show all
Includes:
FFIStructInclude
Defined in:
lib/ragweed/wraposx/thread_context.rb

Constant Summary collapse

FLAVOR =
9

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
# File 'lib/ragweed/wraposx/thread_context.rb', line 647

def method_missing meth, *args
  super unless self.respond_to? meth
  if meth.to_s =~ /=$/
    mth = meth.to_s.gsub(/=$/,'').intern
    if self.members.include? mth
      # don't proxy
      self.__send__(:[]=, mth, *args)
    elsif self[:esh].members.include? meth
      self[:esh].__send__(:[]=, mth, *args)
    else
      case self[:esh][:flavor]
      when Ragweed::Wraposx::ThreadContext::X86_EXCEPTION_STATE32
        self[:ues][:es32].__send__(:[]=, mth, *args)
      when Ragweed::Wraposx::ThreadContext::X86_EXCEPTION_STATE64
        self[:ues][:es64].__send__(:[]=, mth, *args)
      end
    end
  else
    if self.members.include? meth
      # don't proxy
      self.__send__(:[], meth, *args)
    elsif self[:esh].members.include? meth
      self[:esh].__send__(:[], meth, *args)
    else
      case self[:esh][:flavor]
      when Ragweed::Wraposx::ThreadContext::X86_EXCEPTION_STATE32
        self[:ues][:es32].__send__(:[], meth, *args)
      when Ragweed::Wraposx::ThreadContext::X86_EXCEPTION_STATE64
        self[:ues][:es64].__send__(:[], meth, *args)
      end
    end
  end
end

Instance Method Details

#headerObject



611
# File 'lib/ragweed/wraposx/thread_context.rb', line 611

def header; self[:esh]; end

#is_32?Boolean

Returns:

  • (Boolean)


610
# File 'lib/ragweed/wraposx/thread_context.rb', line 610

def is_32?; !is_64?; end

#is_64?Boolean

Returns:

  • (Boolean)


609
# File 'lib/ragweed/wraposx/thread_context.rb', line 609

def is_64?; self[:esh].is_64?; end

#methods(regular = true) ⇒ Object



618
619
620
621
622
623
624
625
626
627
628
629
630
# File 'lib/ragweed/wraposx/thread_context.rb', line 618

def methods regular=true
  ret = super + self.members.map{|x| [x.to_s, x.to_s + "="]}
  ret += self[:esh].members.map{|x| [x.to_s, x.to_s + "="]}
  ret += case self[:esh][:flavor]
  when Ragweed::Wraposx::ThreadContext::X86_EXCEPTION_STATE32
    self[:ues][:es32].members.map{|x| [x.to_s, x.to_s + "="]}
  when Ragweed::Wraposx::ThreadContext::X86_EXCEPTION_STATE64
    self[:ues][:es64].members.map{|x| [x.to_s, x.to_s + "="]}
  else
    []
  end
  ret.flatten
end

#respond_to?(meth, include_priv = false) ⇒ Boolean

Returns:

  • (Boolean)


681
682
683
684
# File 'lib/ragweed/wraposx/thread_context.rb', line 681

def respond_to? meth, include_priv=false
  mth = meth.to_s.gsub(/=$/,'') # may not be needed anymore
  self.methods.include? mth || super
end