Class: LLDB::NativeStringArray

Inherits:
Object
  • Object
show all
Defined in:
lib/lldb/native_string_array.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(strings) ⇒ NativeStringArray

Returns a new instance of NativeStringArray.

RBS:

  • strings: Array[String]

  • return: void



9
10
11
12
13
14
15
16
17
18
# File 'lib/lldb/native_string_array.rb', line 9

def initialize(strings)
  @strings = strings.map { |string| NativeStringArray.validate!(string) }
  @string_pointers = @strings.map { |string| FFI::MemoryPointer.from_string(string) }
  @pointer_array = FFI::MemoryPointer.new(:pointer, @string_pointers.length + 1)

  @string_pointers.each_with_index do |pointer, index|
    @pointer_array[index].put_pointer(0, pointer)
  end
  @pointer_array[@string_pointers.length].put_pointer(0, nil)
end

Class Method Details

.validate!(value) ⇒ Object

RBS:

  • value: String

  • return: String

Raises:

  • (ArgumentError)


22
23
24
25
26
27
# File 'lib/lldb/native_string_array.rb', line 22

def self.validate!(value)
  raise ArgumentError, 'native string values must be String' unless value.is_a?(String)
  raise ArgumentError, 'native strings must not contain NUL bytes' if value.include?("\0")

  value
end

Instance Method Details

#to_ptrObject

RBS:

  • return: FFI::Pointer



30
31
32
# File 'lib/lldb/native_string_array.rb', line 30

def to_ptr
  @pointer_array
end