[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / lldb / source / API / SBFileSpecList.cpp
blob3143964b38cbec1126315a6ef4dcd4ee8d61de8a
1 //===-- SBFileSpecList.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/SBFileSpecList.h"
10 #include "SBReproducerPrivate.h"
11 #include "Utils.h"
12 #include "lldb/API/SBFileSpec.h"
13 #include "lldb/API/SBStream.h"
14 #include "lldb/Core/FileSpecList.h"
15 #include "lldb/Host/PosixApi.h"
16 #include "lldb/Utility/FileSpec.h"
17 #include "lldb/Utility/Stream.h"
19 #include <limits.h>
21 using namespace lldb;
22 using namespace lldb_private;
24 SBFileSpecList::SBFileSpecList() : m_opaque_up(new FileSpecList()) {
25 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFileSpecList);
28 SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_up() {
29 LLDB_RECORD_CONSTRUCTOR(SBFileSpecList, (const lldb::SBFileSpecList &), rhs);
32 m_opaque_up = clone(rhs.m_opaque_up);
35 SBFileSpecList::~SBFileSpecList() {}
37 const SBFileSpecList &SBFileSpecList::operator=(const SBFileSpecList &rhs) {
38 LLDB_RECORD_METHOD(const lldb::SBFileSpecList &,
39 SBFileSpecList, operator=,(const lldb::SBFileSpecList &),
40 rhs);
42 if (this != &rhs)
43 m_opaque_up = clone(rhs.m_opaque_up);
44 return LLDB_RECORD_RESULT(*this);
47 uint32_t SBFileSpecList::GetSize() const {
48 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBFileSpecList, GetSize);
50 return m_opaque_up->GetSize();
53 void SBFileSpecList::Append(const SBFileSpec &sb_file) {
54 LLDB_RECORD_METHOD(void, SBFileSpecList, Append, (const lldb::SBFileSpec &),
55 sb_file);
57 m_opaque_up->Append(sb_file.ref());
60 bool SBFileSpecList::AppendIfUnique(const SBFileSpec &sb_file) {
61 LLDB_RECORD_METHOD(bool, SBFileSpecList, AppendIfUnique,
62 (const lldb::SBFileSpec &), sb_file);
64 return m_opaque_up->AppendIfUnique(sb_file.ref());
67 void SBFileSpecList::Clear() {
68 LLDB_RECORD_METHOD_NO_ARGS(void, SBFileSpecList, Clear);
70 m_opaque_up->Clear();
73 uint32_t SBFileSpecList::FindFileIndex(uint32_t idx, const SBFileSpec &sb_file,
74 bool full) {
75 LLDB_RECORD_METHOD(uint32_t, SBFileSpecList, FindFileIndex,
76 (uint32_t, const lldb::SBFileSpec &, bool), idx, sb_file,
77 full);
79 return m_opaque_up->FindFileIndex(idx, sb_file.ref(), full);
82 const SBFileSpec SBFileSpecList::GetFileSpecAtIndex(uint32_t idx) const {
83 LLDB_RECORD_METHOD_CONST(const lldb::SBFileSpec, SBFileSpecList,
84 GetFileSpecAtIndex, (uint32_t), idx);
86 SBFileSpec new_spec;
87 new_spec.SetFileSpec(m_opaque_up->GetFileSpecAtIndex(idx));
88 return LLDB_RECORD_RESULT(new_spec);
91 const lldb_private::FileSpecList *SBFileSpecList::operator->() const {
92 return m_opaque_up.get();
95 const lldb_private::FileSpecList *SBFileSpecList::get() const {
96 return m_opaque_up.get();
99 const lldb_private::FileSpecList &SBFileSpecList::operator*() const {
100 return *m_opaque_up;
103 const lldb_private::FileSpecList &SBFileSpecList::ref() const {
104 return *m_opaque_up;
107 bool SBFileSpecList::GetDescription(SBStream &description) const {
108 LLDB_RECORD_METHOD_CONST(bool, SBFileSpecList, GetDescription,
109 (lldb::SBStream &), description);
111 Stream &strm = description.ref();
113 if (m_opaque_up) {
114 uint32_t num_files = m_opaque_up->GetSize();
115 strm.Printf("%d files: ", num_files);
116 for (uint32_t i = 0; i < num_files; i++) {
117 char path[PATH_MAX];
118 if (m_opaque_up->GetFileSpecAtIndex(i).GetPath(path, sizeof(path)))
119 strm.Printf("\n %s", path);
121 } else
122 strm.PutCString("No value");
124 return true;
127 namespace lldb_private {
128 namespace repro {
130 template <>
131 void RegisterMethods<SBFileSpecList>(Registry &R) {
132 LLDB_REGISTER_CONSTRUCTOR(SBFileSpecList, ());
133 LLDB_REGISTER_CONSTRUCTOR(SBFileSpecList, (const lldb::SBFileSpecList &));
134 LLDB_REGISTER_METHOD(
135 const lldb::SBFileSpecList &,
136 SBFileSpecList, operator=,(const lldb::SBFileSpecList &));
137 LLDB_REGISTER_METHOD_CONST(uint32_t, SBFileSpecList, GetSize, ());
138 LLDB_REGISTER_METHOD(void, SBFileSpecList, Append,
139 (const lldb::SBFileSpec &));
140 LLDB_REGISTER_METHOD(bool, SBFileSpecList, AppendIfUnique,
141 (const lldb::SBFileSpec &));
142 LLDB_REGISTER_METHOD(void, SBFileSpecList, Clear, ());
143 LLDB_REGISTER_METHOD(uint32_t, SBFileSpecList, FindFileIndex,
144 (uint32_t, const lldb::SBFileSpec &, bool));
145 LLDB_REGISTER_METHOD_CONST(const lldb::SBFileSpec, SBFileSpecList,
146 GetFileSpecAtIndex, (uint32_t));
147 LLDB_REGISTER_METHOD_CONST(bool, SBFileSpecList, GetDescription,
148 (lldb::SBStream &));