Class: Fzeet::Windows::SAFEARRAY
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- Fzeet::Windows::SAFEARRAY
- Includes:
- Enumerable
- Defined in:
- lib/fzeet/windows/oleaut/SafeArray.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](i) ⇒ Object (also: #get)
- #[]=(i, v) ⇒ Object (also: #put)
- #destroy ⇒ Object (also: #dispose)
- #each ⇒ Object
- #length(dim = 0) ⇒ Object
- #old_get ⇒ Object
- #old_put ⇒ Object
- #vt ⇒ Object
Class Method Details
.vector(length, vt = :variant) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fzeet/windows/oleaut/SafeArray.rb', line 22 def self.vector(length, vt = :variant) raise 'Not implemented.' if vt != :variant raise 'SafeArrayCreateVector failed.' if (psa = Windows.SafeArrayCreateVector(Windows.const_get("VT_#{vt.upcase}"), 0, length)).null? sa = new(psa) if block_given? yield sa; sa.dispose; return nil end sa end |
Instance Method Details
#[](i) ⇒ Object Also known as: get
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fzeet/windows/oleaut/SafeArray.rb', line 49 def [](i) return old_get(i) if i.kind_of?(Symbol) FFI::MemoryPointer.new(:long) { |pi| pi.put_long(0, i) Windows.DetonateHresult(:SafeArrayGetElement, self, pi, v = VARIANT.new) return v } end |
#[]=(i, v) ⇒ Object Also known as: put
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fzeet/windows/oleaut/SafeArray.rb', line 65 def []=(i, v) return old_put(i, v) if i.kind_of?(Symbol) FFI::MemoryPointer.new(:long) { |pi| pi.put_long(0, i) Windows.DetonateHresult(:SafeArrayPutElement, self, pi, v) } self end |
#destroy ⇒ Object Also known as: dispose
79 |
# File 'lib/fzeet/windows/oleaut/SafeArray.rb', line 79 def destroy; Windows.DetonateHresult(:SafeArrayDestroy, self) end |
#each ⇒ Object
82 |
# File 'lib/fzeet/windows/oleaut/SafeArray.rb', line 82 def each; length.times { |i| yield self[i] }; self end |
#length(dim = 0) ⇒ Object
37 |
# File 'lib/fzeet/windows/oleaut/SafeArray.rb', line 37 def length(dim = 0) raise 'Not implemented.' if dim != 0; self[:rgsabound][dim][:cElements] end |
#old_get ⇒ Object
47 |
# File 'lib/fzeet/windows/oleaut/SafeArray.rb', line 47 alias old_get [] |
#old_put ⇒ Object
63 |
# File 'lib/fzeet/windows/oleaut/SafeArray.rb', line 63 alias old_put []= |
#vt ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/fzeet/windows/oleaut/SafeArray.rb', line 39 def vt FFI::MemoryPointer.new(:ushort) { |pvt| Windows.DetonateHresult(:SafeArrayGetVartype, self, pvt) return pvt.get_ushort(0) } end |