Module: LLDB::NativeLifecycle

Instance Method Summary collapse

Instance Method Details

#closeObject

RBS:

  • return: bool



13
14
15
16
17
18
19
20
21
# File 'lib/lldb/native_lifecycle.rb', line 13

def close
  return false unless @native_handle
  return false if @native_handle.closed?

  send(:close_context) if respond_to?(:close_context, true)
  @native_handle.close
  @ptr = NativeHandle::NULL_POINTER
  true
end

#closed?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


8
9
10
# File 'lib/lldb/native_lifecycle.rb', line 8

def closed?
  @native_handle ? @native_handle.closed? : false
end

#contextObject

RBS:

  • return: Context?



48
49
50
# File 'lib/lldb/native_lifecycle.rb', line 48

def context
  @context
end

#context!Object

RBS:

  • return: Context



53
54
55
# File 'lib/lldb/native_lifecycle.rb', line 53

def context!
  context || raise(LifecycleError, 'LLDB object has no context')
end

#ensure_open!Object

RBS:

  • return: void

Raises:



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

def ensure_open!
  raise ClosedObjectError, "#{self.class} is closed" if closed?
  @context&.ensure_open!
end

#initialize_native_object(ptr, release:, context: nil) ⇒ Object

RBS:

  • ptr: FFI::Pointer

  • release: ^(FFI::Pointer) -> void

  • context: Context?

  • return: void



40
41
42
43
44
45
# File 'lib/lldb/native_lifecycle.rb', line 40

def initialize_native_object(ptr, release:, context: nil)
  @ptr = ptr
  @context = context
  @native_handle = NativeHandle.new(ptr, release: release)
  context&.register(@native_handle)
end

#to_ptrObject

RBS:

  • return: FFI::Pointer



24
25
26
27
28
# File 'lib/lldb/native_lifecycle.rb', line 24

def to_ptr
  return NativeHandle::NULL_POINTER if closed?

  super
end

#valid?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


58
59
60
61
62
# File 'lib/lldb/native_lifecycle.rb', line 58

def valid?
  return false if closed? || @context&.closed?

  super
end