Class: Fzeet::Windows::HTMLXDomainRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/fzeet/windows/mshtml/Common.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#handlersObject (readonly)

Returns the value of attribute handlers.



553
554
555
# File 'lib/fzeet/windows/mshtml/Common.rb', line 553

def handlers
  @handlers
end

Instance Method Details

#old_openObject



599
# File 'lib/fzeet/windows/mshtml/Common.rb', line 599

alias old_open open

#on(event, &block) ⇒ Object



555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
# File 'lib/fzeet/windows/mshtml/Common.rb', line 555

def on(event, &block)
	((@handlers ||= {})[event] ||= []) << block
	@dcallbacks ||= []

	__send__("put_on#{event}", VARIANT.new.tap { |v|
		v[:vt] = VT_DISPATCH

		v[:pdispVal] = @dcallbacks.push(DCallback.new.tap { |dcb|
			dcb.instance_variable_set(:@xrequest, self)
			dcb.instance_variable_set(:@event, event)

			def dcb.Invoke(*args)
				@xrequest.handlers[@event].each { |handler|
					(handler.arity == 0) ? handler.call : handler.call(*args)
				}

				S_OK
			end
		}).last
	}) unless @handlers[event].length > 1

	self
end

#open(url, method = 'get') ⇒ Object



601
602
603
604
605
606
607
608
609
610
611
# File 'lib/fzeet/windows/mshtml/Common.rb', line 601

def open(url, method = 'get')
	old_open(
		bstr = Windows.SysAllocString("#{method}\0".encode('utf-16le')),
		bstr2 = Windows.SysAllocString("#{url}\0".encode('utf-16le'))
	)

	self
ensure
	Windows.SysFreeString(bstr)
	Windows.SysFreeString(bstr2)
end