Class: Ragweed::Wraposx::ThreadContext::Float

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

Constant Summary collapse

FLAVOR =
8

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
# File 'lib/ragweed/wraposx/thread_context.rb', line 927

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[:fsh].members.include? meth
      self[:fsh].__send__(:[]=, mth, *args)
    else
      case self[:fsh][:flavor]
      when Ragweed::Wraposx::ThreadContext::X86_EXCEPTION_STATE32
        self[:ufs][:fs32].__send__(:[]=, mth, *args)
      when Ragweed::Wraposx::ThreadContext::X86_EXCEPTION_STATE64
        self[:ufs][:fs64].__send__(:[]=, mth, *args)
      end
    end
  else
    if self.members.include? meth
      # don't proxy
      self.__send__(:[], meth, *args)
    elsif self[:fsh].members.include? meth
      self[:fsh].__send__(:[], meth, *args)
    else
      case self[:fsh][:flavor]
      when Ragweed::Wraposx::ThreadContext::X86_EXCEPTION_STATE32
        self[:ufs][:fs32].__send__(:[], meth, *args)
      when Ragweed::Wraposx::ThreadContext::X86_EXCEPTION_STATE64
        self[:ufs][:fs64].__send__(:[], meth, *args)
      end
    end
  end
end

Instance Method Details

#headerObject



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

def header; self[:fsh]; end

#is_32?Boolean

Returns:

  • (Boolean)


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

def is_32?; !is_64?; end

#is_64?Boolean

Returns:

  • (Boolean)


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

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

#methods(regular = true) ⇒ Object



898
899
900
901
902
903
904
905
906
907
908
909
910
# File 'lib/ragweed/wraposx/thread_context.rb', line 898

def methods regular=true
  ret = super + self.members.map{|x| [x.to_s, x.to_s + "="]}
  ret += self[:fsh].members.map{|x| [x.to_s, x.to_s + "="]}
  ret += case self[:fsh][:flavor]
  when Ragweed::Wraposx::ThreadContext::X86_FLOAT_STATE32
    self[:ufs][:fs32].members.map{|x| [x.to_s, x.to_s + "="]}
  when Ragweed::Wraposx::ThreadContext::X86_FLOAT_STATE64
    self[:ufs][:fs64].members.map{|x| [x.to_s, x.to_s + "="]}
  else
    []
  end
  ret.flatten
end

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

Returns:

  • (Boolean)


961
962
963
964
# File 'lib/ragweed/wraposx/thread_context.rb', line 961

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