Class: LLDB::ValueList
- Inherits:
-
Object
- Object
- LLDB::ValueList
- Includes:
- Enumerable, NativeLifecycle
- Defined in:
- lib/lldb/value_list.rb
Instance Attribute Summary collapse
- #parent ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #first_value_by_name(name) ⇒ Object
-
#initialize(ptr, parent:, context: parent.context) ⇒ ValueList
constructor
A new instance of ValueList.
- #size ⇒ Object (also: #length)
- #to_a ⇒ Object
- #to_ptr ⇒ Object
- #valid? ⇒ Boolean
- #value_at_index(index) ⇒ Object (also: #[])
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.
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
#parent ⇒ Object (readonly)
11 12 13 |
# File 'lib/lldb/value_list.rb', line 11 def parent @parent end |
Class Method Details
.release(ptr) ⇒ Object
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
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
83 84 85 |
# File 'lib/lldb/value_list.rb', line 83 def empty? size.zero? end |
#first_value_by_name(name) ⇒ Object
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 |
#size ⇒ Object Also known as: length
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_a ⇒ Object
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_ptr ⇒ Object
88 89 90 |
# File 'lib/lldb/value_list.rb', line 88 def to_ptr @ptr end |
#valid? ⇒ 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: []
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 |