Sha256: 2c081e6fe402ce2c0c086632ea7e981e33ae4f766f6c0e516f6a92feea04bf08

Contents?: true

Size: 1.44 KB

Versions: 7

Compression:

Stored size: 1.44 KB

Contents

module Caricature

  # Encapsulates sending messages to CLR class or instance isolations
  class ClrClassMessenger < Messenger

    protected
    
      # deliver the message to the receiving isolation
      def internal_deliver(mode, method_name, return_type, *args, &b)
        exp = expectations.find(method_name, mode, *args)
        if exp
          res = instance.__send__(method_name, *args, &b) if exp.super_before?
          res = exp.execute *args
          res = instance.__send__(method_name, *args, &b) if !exp.super_before? and exp.call_super?
          res
        else
          rt = nil
          is_value_type = return_type && return_type != System::Void.to_clr_type && return_type.is_value_type
          rt = System::Activator.create_instance(return_type) if is_value_type
          rt
        end
      end

  end

  # Encapsulates sending messages to CLR interface isolations
  class ClrInterfaceMessenger < Messenger

    protected

      # deliver the message to the receiving isolation
      def internal_deliver(mode, method_name, return_type, *args, &b)
        exp = expectations.find(method_name, mode, *args)
        if exp
          res = exp.execute *args
          res
        else
          rt = nil
          rt = System::Activator.create_instance(return_type) if return_type && return_type != System::Void.to_clr_type && return_type.is_value_type
          rt
        end
      end

  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
casualjim-caricature-0.5.0 lib/caricature/clr/messenger.rb
casualjim-caricature-0.6.0 lib/caricature/clr/messenger.rb
casualjim-caricature-0.6.1 lib/caricature/clr/messenger.rb
caricature-0.6.3 lib/caricature/clr/messenger.rb
caricature-0.5.0 lib/caricature/clr/messenger.rb
caricature-0.6.0 lib/caricature/clr/messenger.rb
caricature-0.6.1 lib/caricature/clr/messenger.rb