Class: LLDB::Type

Inherits:
Object
  • Object
show all
Includes:
NativeLifecycle
Defined in:
lib/lldb/type.rb

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, context: nil) ⇒ Type

Returns a new instance of Type.

RBS:

  • ptr: FFI::Pointer

  • return: void



11
12
13
14
15
16
17
# File 'lib/lldb/type.rb', line 11

def initialize(ptr, context: nil)
  initialize_native_object(
    ptr,
    release: ->(released) { FFIBindings.lldb_type_destroy(released) },
    context: context
  )
end

Class Method Details

.release(ptr) ⇒ Object

RBS:

  • ptr: FFI::Pointer

  • return: ^(Integer) -> void



21
22
23
# File 'lib/lldb/type.rb', line 21

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

Instance Method Details

#array_element_typeObject

RBS:

  • return: Type?

Raises:



161
162
163
164
165
166
167
168
# File 'lib/lldb/type.rb', line 161

def array_element_type
  raise InvalidObjectError, 'Type is not valid' unless valid?

  ptr = FFIBindings.lldb_type_get_array_element_type(@ptr)
  return nil if ptr.nil? || ptr.null?

  Type.new(ptr)
end

#array_sizeObject

RBS:

  • return: Integer



171
172
173
174
175
# File 'lib/lldb/type.rb', line 171

def array_size
  return 0 unless valid?

  FFIBindings.lldb_type_get_array_size(@ptr)
end

#array_type?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


66
67
68
69
70
# File 'lib/lldb/type.rb', line 66

def array_type?
  return false unless valid?

  FFIBindings.lldb_type_is_array_type(@ptr) != 0
end

#basic_typeObject

RBS:

  • return: Integer



217
218
219
220
221
# File 'lib/lldb/type.rb', line 217

def basic_type
  return BasicType::INVALID unless valid?

  FFIBindings.lldb_type_get_basic_type(@ptr)
end

#byte_sizeObject

RBS:

  • return: Integer



45
46
47
48
49
# File 'lib/lldb/type.rb', line 45

def byte_size
  return 0 unless valid?

  FFIBindings.lldb_type_get_byte_size(@ptr)
end

#canonical_typeObject

RBS:

  • return: Type?

Raises:



151
152
153
154
155
156
157
158
# File 'lib/lldb/type.rb', line 151

def canonical_type
  raise InvalidObjectError, 'Type is not valid' unless valid?

  ptr = FFIBindings.lldb_type_get_canonical_type(@ptr)
  return nil if ptr.nil? || ptr.null?

  Type.new(ptr)
end

#dereferenced_typeObject

RBS:

  • return: Type?

Raises:



131
132
133
134
135
136
137
138
# File 'lib/lldb/type.rb', line 131

def dereferenced_type
  raise InvalidObjectError, 'Type is not valid' unless valid?

  ptr = FFIBindings.lldb_type_get_dereferenced_type(@ptr)
  return nil if ptr.nil? || ptr.null?

  Type.new(ptr)
end

#direct_base_class_at_index(index) ⇒ Object

RBS:

  • index: Integer

  • return: TypeMember?



206
207
208
# File 'lib/lldb/type.rb', line 206

def direct_base_class_at_index(index)
  member_at(index, :lldb_type_get_direct_base_class_at_index)
end

#display_type_nameObject

RBS:

  • return: String?



38
39
40
41
42
# File 'lib/lldb/type.rb', line 38

def display_type_name
  return nil unless valid?

  FFIBindings.lldb_type_get_display_type_name(@ptr)
end

#field_at_index(index) ⇒ Object

RBS:

  • index: Integer

  • return: TypeMember?



200
201
202
# File 'lib/lldb/type.rb', line 200

def field_at_index(index)
  member_at(index, :lldb_type_get_field_at_index)
end

#function_type?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


87
88
89
90
91
# File 'lib/lldb/type.rb', line 87

def function_type?
  return false unless valid?

  FFIBindings.lldb_type_is_function_type(@ptr) != 0
end

#inspectObject

RBS:

  • return: String



229
230
231
# File 'lib/lldb/type.rb', line 229

def inspect
  "#<LLDB::Type name=#{name.inspect} byte_size=#{byte_size}>"
end

#nameObject

RBS:

  • return: String?



31
32
33
34
35
# File 'lib/lldb/type.rb', line 31

def name
  return nil unless valid?

  FFIBindings.lldb_type_get_name(@ptr)
end

#num_direct_base_classesObject

RBS:

  • return: Integer



185
186
187
188
189
# File 'lib/lldb/type.rb', line 185

def num_direct_base_classes
  return 0 unless valid?

  FFIBindings.lldb_type_get_num_direct_base_classes(@ptr)
end

#num_fieldsObject

RBS:

  • return: Integer



178
179
180
181
182
# File 'lib/lldb/type.rb', line 178

def num_fields
  return 0 unless valid?

  FFIBindings.lldb_type_get_num_fields(@ptr)
end

#num_virtual_base_classesObject

RBS:

  • return: Integer



192
193
194
195
196
# File 'lib/lldb/type.rb', line 192

def num_virtual_base_classes
  return 0 unless valid?

  FFIBindings.lldb_type_get_num_virtual_base_classes(@ptr)
end

#pointee_typeObject

RBS:

  • return: Type?

Raises:



111
112
113
114
115
116
117
118
# File 'lib/lldb/type.rb', line 111

def pointee_type
  raise InvalidObjectError, 'Type is not valid' unless valid?

  ptr = FFIBindings.lldb_type_get_pointee_type(@ptr)
  return nil if ptr.nil? || ptr.null?

  Type.new(ptr)
end

#pointer_typeObject

RBS:

  • return: Type?

Raises:



101
102
103
104
105
106
107
108
# File 'lib/lldb/type.rb', line 101

def pointer_type
  raise InvalidObjectError, 'Type is not valid' unless valid?

  ptr = FFIBindings.lldb_type_get_pointer_type(@ptr)
  return nil if ptr.nil? || ptr.null?

  Type.new(ptr)
end

#pointer_type?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


52
53
54
55
56
# File 'lib/lldb/type.rb', line 52

def pointer_type?
  return false unless valid?

  FFIBindings.lldb_type_is_pointer_type(@ptr) != 0
end

#polymorphic_class?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


94
95
96
97
98
# File 'lib/lldb/type.rb', line 94

def polymorphic_class?
  return false unless valid?

  FFIBindings.lldb_type_is_polymorphic_class(@ptr) != 0
end

#reference_typeObject

RBS:

  • return: Type?

Raises:



121
122
123
124
125
126
127
128
# File 'lib/lldb/type.rb', line 121

def reference_type
  raise InvalidObjectError, 'Type is not valid' unless valid?

  ptr = FFIBindings.lldb_type_get_reference_type(@ptr)
  return nil if ptr.nil? || ptr.null?

  Type.new(ptr)
end

#reference_type?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


59
60
61
62
63
# File 'lib/lldb/type.rb', line 59

def reference_type?
  return false unless valid?

  FFIBindings.lldb_type_is_reference_type(@ptr) != 0
end

#to_ptrObject

RBS:

  • return: FFI::Pointer



234
235
236
# File 'lib/lldb/type.rb', line 234

def to_ptr
  @ptr
end

#to_sObject

RBS:

  • return: String



224
225
226
# File 'lib/lldb/type.rb', line 224

def to_s
  display_type_name || name || '(unknown type)'
end

#typedef_type?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


80
81
82
83
84
# File 'lib/lldb/type.rb', line 80

def typedef_type?
  return false unless valid?

  FFIBindings.lldb_type_is_typedef_type(@ptr) != 0
end

#unqualified_typeObject

RBS:

  • return: Type?

Raises:



141
142
143
144
145
146
147
148
# File 'lib/lldb/type.rb', line 141

def unqualified_type
  raise InvalidObjectError, 'Type is not valid' unless valid?

  ptr = FFIBindings.lldb_type_get_unqualified_type(@ptr)
  return nil if ptr.nil? || ptr.null?

  Type.new(ptr)
end

#valid?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


26
27
28
# File 'lib/lldb/type.rb', line 26

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

#vector_type?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


73
74
75
76
77
# File 'lib/lldb/type.rb', line 73

def vector_type?
  return false unless valid?

  FFIBindings.lldb_type_is_vector_type(@ptr) != 0
end

#virtual_base_class_at_index(index) ⇒ Object

RBS:

  • index: Integer

  • return: TypeMember?



212
213
214
# File 'lib/lldb/type.rb', line 212

def virtual_base_class_at_index(index)
  member_at(index, :lldb_type_get_virtual_base_class_at_index)
end