1 //===-- SBSymbolContextList.cpp ---------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBSymbolContextList.h"
10 #include "SBReproducerPrivate.h"
12 #include "lldb/API/SBStream.h"
13 #include "lldb/Symbol/SymbolContext.h"
16 using namespace lldb_private
;
18 SBSymbolContextList::SBSymbolContextList()
19 : m_opaque_up(new SymbolContextList()) {
20 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSymbolContextList
);
23 SBSymbolContextList::SBSymbolContextList(const SBSymbolContextList
&rhs
)
25 LLDB_RECORD_CONSTRUCTOR(SBSymbolContextList
,
26 (const lldb::SBSymbolContextList
&), rhs
);
28 m_opaque_up
= clone(rhs
.m_opaque_up
);
31 SBSymbolContextList::~SBSymbolContextList() {}
33 const SBSymbolContextList
&SBSymbolContextList::
34 operator=(const SBSymbolContextList
&rhs
) {
36 const lldb::SBSymbolContextList
&,
37 SBSymbolContextList
, operator=,(const lldb::SBSymbolContextList
&), rhs
);
40 m_opaque_up
= clone(rhs
.m_opaque_up
);
41 return LLDB_RECORD_RESULT(*this);
44 uint32_t SBSymbolContextList::GetSize() const {
45 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBSymbolContextList
, GetSize
);
48 return m_opaque_up
->GetSize();
52 SBSymbolContext
SBSymbolContextList::GetContextAtIndex(uint32_t idx
) {
53 LLDB_RECORD_METHOD(lldb::SBSymbolContext
, SBSymbolContextList
,
54 GetContextAtIndex
, (uint32_t), idx
);
56 SBSymbolContext sb_sc
;
59 if (m_opaque_up
->GetContextAtIndex(idx
, sc
)) {
60 sb_sc
.SetSymbolContext(&sc
);
63 return LLDB_RECORD_RESULT(sb_sc
);
66 void SBSymbolContextList::Clear() {
67 LLDB_RECORD_METHOD_NO_ARGS(void, SBSymbolContextList
, Clear
);
73 void SBSymbolContextList::Append(SBSymbolContext
&sc
) {
74 LLDB_RECORD_METHOD(void, SBSymbolContextList
, Append
,
75 (lldb::SBSymbolContext
&), sc
);
77 if (sc
.IsValid() && m_opaque_up
.get())
78 m_opaque_up
->Append(*sc
);
81 void SBSymbolContextList::Append(SBSymbolContextList
&sc_list
) {
82 LLDB_RECORD_METHOD(void, SBSymbolContextList
, Append
,
83 (lldb::SBSymbolContextList
&), sc_list
);
85 if (sc_list
.IsValid() && m_opaque_up
.get())
86 m_opaque_up
->Append(*sc_list
);
89 bool SBSymbolContextList::IsValid() const {
90 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbolContextList
, IsValid
);
91 return this->operator bool();
93 SBSymbolContextList::operator bool() const {
94 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbolContextList
, operator bool);
96 return m_opaque_up
!= nullptr;
99 lldb_private::SymbolContextList
*SBSymbolContextList::operator->() const {
100 return m_opaque_up
.get();
103 lldb_private::SymbolContextList
&SBSymbolContextList::operator*() const {
104 assert(m_opaque_up
.get());
108 bool SBSymbolContextList::GetDescription(lldb::SBStream
&description
) {
109 LLDB_RECORD_METHOD(bool, SBSymbolContextList
, GetDescription
,
110 (lldb::SBStream
&), description
);
112 Stream
&strm
= description
.ref();
114 m_opaque_up
->GetDescription(&strm
, lldb::eDescriptionLevelFull
, nullptr);
118 namespace lldb_private
{
122 void RegisterMethods
<SBSymbolContextList
>(Registry
&R
) {
123 LLDB_REGISTER_CONSTRUCTOR(SBSymbolContextList
, ());
124 LLDB_REGISTER_CONSTRUCTOR(SBSymbolContextList
,
125 (const lldb::SBSymbolContextList
&));
126 LLDB_REGISTER_METHOD(
127 const lldb::SBSymbolContextList
&,
128 SBSymbolContextList
, operator=,(const lldb::SBSymbolContextList
&));
129 LLDB_REGISTER_METHOD_CONST(uint32_t, SBSymbolContextList
, GetSize
, ());
130 LLDB_REGISTER_METHOD(lldb::SBSymbolContext
, SBSymbolContextList
,
131 GetContextAtIndex
, (uint32_t));
132 LLDB_REGISTER_METHOD(void, SBSymbolContextList
, Clear
, ());
133 LLDB_REGISTER_METHOD(void, SBSymbolContextList
, Append
,
134 (lldb::SBSymbolContext
&));
135 LLDB_REGISTER_METHOD(void, SBSymbolContextList
, Append
,
136 (lldb::SBSymbolContextList
&));
137 LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContextList
, IsValid
, ());
138 LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContextList
, operator bool, ());
139 LLDB_REGISTER_METHOD(bool, SBSymbolContextList
, GetDescription
,