Class: LLDB::ValueList

Inherits:
Object
  • Object
show all
Includes:
Enumerable, NativeLifecycle
Defined in:
lib/lldb/value_list.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from NativeLifecycle

#close, #closed?, #context, #context!, #ensure_open!, #initialize_native_object

Constructor Details

#initialize(ptr, parent:, context: parent.context) ⇒ ValueList

Returns a new instance of ValueList.

RBS:

  • ptr: FFI::Pointer

  • parent: Frame | Value

  • return: void



16
17
18
19
20
21
22
23
# File 'lib/lldb/value_list.rb', line 16

def initialize(ptr, parent:, context: parent.context)
  @parent = parent
  initialize_native_object(
    ptr,
    release: ->(released) { FFIBindings.lldb_value_list_destroy(released) },
    context: context
  )
end

Instance Attribute Details

#parentObject (readonly)

RBS:

  • return: Frame | Value



11
12
13
# File 'lib/lldb/value_list.rb', line 11

def parent
  @parent
end

Class Method Details

.release(ptr) ⇒ Object

RBS:

  • ptr: FFI::Pointer

  • return: ^(Integer) -> void



27
28
29
# File 'lib/lldb/value_list.rb', line 27

def self.release(ptr)
  ->(_id) { FFIBindings.lldb_value_list_destroy(ptr) unless ptr.null? }
end

Instance Method Details

#each(&block) ⇒ Object

RBS:

  • &block: (Value) -> void

  • return: Enumerator[Value, void] | void



76
77
78
79
80
# File 'lib/lldb/value_list.rb', line 76

def each(&block)
  return enum_for(:each) unless block_given?

  to_a.each(&block)
end

#empty?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


83
84
85
# File 'lib/lldb/value_list.rb', line 83

def empty?
  size.zero?
end

#first_value_by_name(name) ⇒ Object

RBS:

  • name: String

  • return: Value?

Raises:



60
61
62
63
64
65
66
67
# File 'lib/lldb/value_list.rb', line 60

def first_value_by_name(name)
  raise InvalidObjectError, 'ValueList is not valid' unless valid?

  value_ptr = FFIBindings.lldb_value_list_get_first_value_by_name(@ptr, name)
  return nil if value_ptr.nil? || value_ptr.null?

  Value.new(value_ptr, parent: @parent, context: context)
end

#sizeObject Also known as: length

RBS:

  • return: Integer



37
38
39
40
41
# File 'lib/lldb/value_list.rb', line 37

def size
  return 0 unless valid?

  FFIBindings.lldb_value_list_get_size(@ptr)
end

#to_aObject

RBS:

  • return: Array[Value]



70
71
72
# File 'lib/lldb/value_list.rb', line 70

def to_a
  (0...size).map { |i| value_at_index(i) }.compact
end

#to_ptrObject

RBS:

  • return: FFI::Pointer



88
89
90
# File 'lib/lldb/value_list.rb', line 88

def to_ptr
  @ptr
end

#valid?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


32
33
34
# File 'lib/lldb/value_list.rb', line 32

def valid?
  !@ptr.null? && FFIBindings.lldb_value_list_is_valid(@ptr) != 0
end

#value_at_index(index) ⇒ Object Also known as: []

RBS:

  • index: Integer

  • return: Value?

Raises:



47
48
49
50
51
52
53
54
# File 'lib/lldb/value_list.rb', line 47

def value_at_index(index)
  raise InvalidObjectError, 'ValueList is not valid' unless valid?

  value_ptr = FFIBindings.lldb_value_list_get_value_at_index(@ptr, index)
  return nil if value_ptr.nil? || value_ptr.null?

  Value.new(value_ptr, parent: @parent, context: context)
end