Class: WinFFI::WideInlineString

Inherits:
Object
  • Object
show all
Includes:
FFI::DataConverter
Defined in:
lib/win-ffi/core/wide_inline_string.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ WideInlineString

Returns a new instance of WideInlineString.



12
13
14
15
# File 'lib/win-ffi/core/wide_inline_string.rb', line 12

def initialize(size)
  @size = size
  @native_type = FFI::ArrayType.new(WinFFI.find_type(:tchar), size)
end

Instance Attribute Details

#native_typeObject (readonly)

Returns the value of attribute native_type.



10
11
12
# File 'lib/win-ffi/core/wide_inline_string.rb', line 10

def native_type
  @native_type
end

#sizeObject (readonly) Also known as: length

Returns the value of attribute size.



10
11
12
# File 'lib/win-ffi/core/wide_inline_string.rb', line 10

def size
  @size
end

Instance Method Details

#from_native(value, _context) ⇒ Object



22
23
24
# File 'lib/win-ffi/core/wide_inline_string.rb', line 22

def from_native(value, _context)
  String.from_byte_array(value.to_a)
end

#to_native(value, _context) ⇒ Object



18
19
20
# File 'lib/win-ffi/core/wide_inline_string.rb', line 18

def to_native(value, _context)
  value.to_byte_array
end