Class: LLDB::CommandInterpreter

Inherits:
Object
  • Object
show all
Includes:
NativeLifecycle
Defined in:
lib/lldb/command_interpreter.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, debugger:, context: debugger.context) ⇒ CommandInterpreter

Returns a new instance of CommandInterpreter.

RBS:

  • ptr: FFI::Pointer

  • debugger: Debugger

  • return: void



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

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

Instance Attribute Details

#debuggerObject (readonly)

RBS:

  • return: Debugger



10
11
12
# File 'lib/lldb/command_interpreter.rb', line 10

def debugger
  @debugger
end

Class Method Details

.release(ptr) ⇒ Object

RBS:

  • ptr: FFI::Pointer

  • return: ^(Integer) -> void



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

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

Instance Method Details

#alias_exists?(alias_name) ⇒ Boolean

RBS:

  • alias_name: String

  • return: bool

Returns:

  • (Boolean)


56
57
58
59
60
# File 'lib/lldb/command_interpreter.rb', line 56

def alias_exists?(alias_name)
  return false unless valid?

  FFIBindings.lldb_command_interpreter_alias_exists(@ptr, alias_name) != 0
end

#command_exists?(command) ⇒ Boolean

RBS:

  • command: String

  • return: bool

Returns:

  • (Boolean)


48
49
50
51
52
# File 'lib/lldb/command_interpreter.rb', line 48

def command_exists?(command)
  return false unless valid?

  FFIBindings.lldb_command_interpreter_command_exists(@ptr, command) != 0
end

#handle_command(command, add_to_history: true) ⇒ Object

RBS:

  • command: String

  • add_to_history: bool

  • return: CommandReturnObject

Raises:



38
39
40
41
42
43
44
# File 'lib/lldb/command_interpreter.rb', line 38

def handle_command(command, add_to_history: true)
  raise InvalidObjectError, 'CommandInterpreter is not valid' unless valid?

  result = CommandReturnObject.create(context: context)
  FFIBindings.lldb_command_interpreter_handle_command(@ptr, command, result.to_ptr, add_to_history ? 1 : 0)
  result
end

#to_ptrObject

RBS:

  • return: FFI::Pointer



63
64
65
# File 'lib/lldb/command_interpreter.rb', line 63

def to_ptr
  @ptr
end

#valid?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


31
32
33
# File 'lib/lldb/command_interpreter.rb', line 31

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