Class: EverSdk::Interop::TcStringData

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/ever_sdk_client/interop.rb

Class Method Summary collapse

Class Method Details

.from_string(s) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/ever_sdk_client/interop.rb', line 20

def self.from_string(s)
  tcs = TcStringData.new
  bytes_count = s.unpack("C*").size
  ptr1 = FFI::MemoryPointer.new(:char, bytes_count)
  ptr1.put_bytes(0, s, 0, bytes_count)
  tcs[:content] = ptr1
  tcs[:len] = ptr1.size
  tcs
end