[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / lldb / source / API / SBStringList.cpp
blobac07b8faac4dffb26b531240377d6704c5ea3192
1 //===-- SBStringList.cpp ----------------------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBStringList.h"
10 #include "SBReproducerPrivate.h"
11 #include "Utils.h"
12 #include "lldb/Utility/StringList.h"
14 using namespace lldb;
15 using namespace lldb_private;
17 SBStringList::SBStringList() : m_opaque_up() {
18 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBStringList);
21 SBStringList::SBStringList(const lldb_private::StringList *lldb_strings_ptr)
22 : m_opaque_up() {
23 if (lldb_strings_ptr)
24 m_opaque_up = std::make_unique<StringList>(*lldb_strings_ptr);
27 SBStringList::SBStringList(const SBStringList &rhs) : m_opaque_up() {
28 LLDB_RECORD_CONSTRUCTOR(SBStringList, (const lldb::SBStringList &), rhs);
30 m_opaque_up = clone(rhs.m_opaque_up);
33 const SBStringList &SBStringList::operator=(const SBStringList &rhs) {
34 LLDB_RECORD_METHOD(const lldb::SBStringList &,
35 SBStringList, operator=,(const lldb::SBStringList &), rhs);
37 if (this != &rhs)
38 m_opaque_up = clone(rhs.m_opaque_up);
39 return LLDB_RECORD_RESULT(*this);
42 SBStringList::~SBStringList() {}
44 const lldb_private::StringList *SBStringList::operator->() const {
45 return m_opaque_up.get();
48 const lldb_private::StringList &SBStringList::operator*() const {
49 return *m_opaque_up;
52 bool SBStringList::IsValid() const {
53 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStringList, IsValid);
54 return this->operator bool();
56 SBStringList::operator bool() const {
57 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStringList, operator bool);
59 return (m_opaque_up != nullptr);
62 void SBStringList::AppendString(const char *str) {
63 LLDB_RECORD_METHOD(void, SBStringList, AppendString, (const char *), str);
65 if (str != nullptr) {
66 if (IsValid())
67 m_opaque_up->AppendString(str);
68 else
69 m_opaque_up.reset(new lldb_private::StringList(str));
73 void SBStringList::AppendList(const char **strv, int strc) {
74 LLDB_RECORD_METHOD(void, SBStringList, AppendList, (const char **, int), strv,
75 strc);
77 if ((strv != nullptr) && (strc > 0)) {
78 if (IsValid())
79 m_opaque_up->AppendList(strv, strc);
80 else
81 m_opaque_up.reset(new lldb_private::StringList(strv, strc));
85 void SBStringList::AppendList(const SBStringList &strings) {
86 LLDB_RECORD_METHOD(void, SBStringList, AppendList,
87 (const lldb::SBStringList &), strings);
89 if (strings.IsValid()) {
90 if (!IsValid())
91 m_opaque_up.reset(new lldb_private::StringList());
92 m_opaque_up->AppendList(*(strings.m_opaque_up));
96 void SBStringList::AppendList(const StringList &strings) {
97 if (!IsValid())
98 m_opaque_up.reset(new lldb_private::StringList());
99 m_opaque_up->AppendList(strings);
102 uint32_t SBStringList::GetSize() const {
103 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBStringList, GetSize);
105 if (IsValid()) {
106 return m_opaque_up->GetSize();
108 return 0;
111 const char *SBStringList::GetStringAtIndex(size_t idx) {
112 LLDB_RECORD_METHOD(const char *, SBStringList, GetStringAtIndex, (size_t),
113 idx);
115 if (IsValid()) {
116 return m_opaque_up->GetStringAtIndex(idx);
118 return nullptr;
121 const char *SBStringList::GetStringAtIndex(size_t idx) const {
122 LLDB_RECORD_METHOD_CONST(const char *, SBStringList, GetStringAtIndex,
123 (size_t), idx);
125 if (IsValid()) {
126 return m_opaque_up->GetStringAtIndex(idx);
128 return nullptr;
131 void SBStringList::Clear() {
132 LLDB_RECORD_METHOD_NO_ARGS(void, SBStringList, Clear);
134 if (IsValid()) {
135 m_opaque_up->Clear();
139 namespace lldb_private {
140 namespace repro {
142 template <>
143 void RegisterMethods<SBStringList>(Registry &R) {
144 LLDB_REGISTER_CONSTRUCTOR(SBStringList, ());
145 LLDB_REGISTER_CONSTRUCTOR(SBStringList, (const lldb::SBStringList &));
146 LLDB_REGISTER_METHOD(const lldb::SBStringList &,
147 SBStringList, operator=,(const lldb::SBStringList &));
148 LLDB_REGISTER_METHOD_CONST(bool, SBStringList, IsValid, ());
149 LLDB_REGISTER_METHOD_CONST(bool, SBStringList, operator bool, ());
150 LLDB_REGISTER_METHOD(void, SBStringList, AppendString, (const char *));
151 LLDB_REGISTER_METHOD(void, SBStringList, AppendList, (const char **, int));
152 LLDB_REGISTER_METHOD(void, SBStringList, AppendList,
153 (const lldb::SBStringList &));
154 LLDB_REGISTER_METHOD_CONST(uint32_t, SBStringList, GetSize, ());
155 LLDB_REGISTER_METHOD(const char *, SBStringList, GetStringAtIndex,
156 (size_t));
157 LLDB_REGISTER_METHOD_CONST(const char *, SBStringList, GetStringAtIndex,
158 (size_t));
159 LLDB_REGISTER_METHOD(void, SBStringList, Clear, ());