LLDB  mainline
SBTypeEnumMember.cpp
Go to the documentation of this file.
1 //===-- SBTypeEnumMember.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 //===----------------------------------------------------------------------===//
8 
10 #include "SBReproducerPrivate.h"
11 #include "Utils.h"
12 #include "lldb/API/SBDefines.h"
13 #include "lldb/API/SBStream.h"
14 #include "lldb/API/SBType.h"
16 #include "lldb/Symbol/Type.h"
17 #include "lldb/Utility/Stream.h"
18 
19 #include <memory>
20 
21 using namespace lldb;
22 using namespace lldb_private;
23 
26 }
27 
29 
31  const lldb::TypeEnumMemberImplSP &enum_member_sp)
32  : m_opaque_sp(enum_member_sp) {}
33 
35  : m_opaque_sp() {
37  rhs);
38 
40 }
41 
45  SBTypeEnumMember, operator=,(const lldb::SBTypeEnumMember &), rhs);
46 
47  if (this != &rhs)
49  return LLDB_RECORD_RESULT(*this);
50 }
51 
54  return this->operator bool();
55 }
56 SBTypeEnumMember::operator bool() const {
58 
59  return m_opaque_sp.get();
60 }
61 
64 
65  if (m_opaque_sp.get())
66  return m_opaque_sp->GetName().GetCString();
67  return NULL;
68 }
69 
72 
73  if (m_opaque_sp.get())
74  return m_opaque_sp->GetValueAsSigned();
75  return 0;
76 }
77 
80 
81  if (m_opaque_sp.get())
82  return m_opaque_sp->GetValueAsUnsigned();
83  return 0;
84 }
85 
88 
89  SBType sb_type;
90  if (m_opaque_sp.get()) {
91  sb_type.SetSP(m_opaque_sp->GetIntegerType());
92  }
93  return LLDB_RECORD_RESULT(sb_type);
94 }
95 
97  m_opaque_sp.reset(type_member_impl);
98 }
99 
101  if (m_opaque_sp.get() == NULL)
102  m_opaque_sp = std::make_shared<TypeEnumMemberImpl>();
103  return *m_opaque_sp.get();
104 }
105 
107  return *m_opaque_sp.get();
108 }
109 
111  : m_opaque_up(new TypeEnumMemberListImpl()) {
113 }
114 
116  : m_opaque_up(new TypeEnumMemberListImpl()) {
118  (const lldb::SBTypeEnumMemberList &), rhs);
119 
120  for (uint32_t i = 0,
121  rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize();
122  i < rhs_size; i++)
123  Append(const_cast<SBTypeEnumMemberList &>(rhs).GetTypeEnumMemberAtIndex(i));
124 }
125 
128  return this->operator bool();
129 }
130 SBTypeEnumMemberList::operator bool() const {
132 
133  return (m_opaque_up != NULL);
134 }
135 
141  rhs);
142 
143  if (this != &rhs) {
144  m_opaque_up.reset(new TypeEnumMemberListImpl());
145  for (uint32_t i = 0,
146  rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize();
147  i < rhs_size; i++)
148  Append(
149  const_cast<SBTypeEnumMemberList &>(rhs).GetTypeEnumMemberAtIndex(i));
150  }
151  return LLDB_RECORD_RESULT(*this);
152 }
153 
156  (lldb::SBTypeEnumMember), enum_member);
157 
158  if (enum_member.IsValid())
159  m_opaque_up->Append(enum_member.m_opaque_sp);
160 }
161 
166 
167  if (m_opaque_up)
168  return LLDB_RECORD_RESULT(
169  SBTypeEnumMember(m_opaque_up->GetTypeEnumMemberAtIndex(index)));
171 }
172 
175 
176  return m_opaque_up->GetSize();
177 }
178 
180 
182  lldb::SBStream &description, lldb::DescriptionLevel description_level) {
183  LLDB_RECORD_METHOD(bool, SBTypeEnumMember, GetDescription,
184  (lldb::SBStream &, lldb::DescriptionLevel), description,
185  description_level);
186 
187  Stream &strm = description.ref();
188 
189  if (m_opaque_sp.get()) {
190  if (m_opaque_sp->GetIntegerType()->GetDescription(strm,
191  description_level)) {
192  strm.Printf(" %s", m_opaque_sp->GetName().GetCString());
193  }
194  } else {
195  strm.PutCString("No value");
196  }
197  return true;
198 }
199 
200 namespace lldb_private {
201 namespace repro {
202 
203 template <>
207  (const lldb::SBTypeEnumMember &));
210  SBTypeEnumMember, operator=,(const lldb::SBTypeEnumMember &));
212  LLDB_REGISTER_METHOD_CONST(bool, SBTypeEnumMember, operator bool, ());
213  LLDB_REGISTER_METHOD(const char *, SBTypeEnumMember, GetName, ());
214  LLDB_REGISTER_METHOD(int64_t, SBTypeEnumMember, GetValueAsSigned, ());
215  LLDB_REGISTER_METHOD(uint64_t, SBTypeEnumMember, GetValueAsUnsigned, ());
219  (const lldb::SBTypeEnumMemberList &));
221  LLDB_REGISTER_METHOD_CONST(bool, SBTypeEnumMemberList, operator bool, ());
224  SBTypeEnumMemberList, operator=,(const lldb::SBTypeEnumMemberList &));
230  LLDB_REGISTER_METHOD(bool, SBTypeEnumMember, GetDescription,
232 }
233 
234 }
235 }
SBTypeEnumMember & operator=(const SBTypeEnumMember &rhs)
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:61
The registry contains a unique mapping between functions and their ID.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
lldb_private::TypeEnumMemberImpl & ref()
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
void RegisterMethods< SBTypeEnumMember >(Registry &R)
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
lldb::TypeEnumMemberImplSP m_opaque_sp
SBTypeEnumMemberList & operator=(const SBTypeEnumMemberList &rhs)
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:106
lldb_private::Stream & ref()
Definition: SBStream.cpp:162
void Append(SBTypeEnumMember entry)
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
Definition: SBAddress.h:15
class LLDB_API SBTypeEnumMember
Definition: SBDefines.h:80
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
SBTypeEnumMember GetTypeEnumMemberAtIndex(uint32_t index)
void reset(lldb_private::TypeEnumMemberImpl *)
#define LLDB_RECORD_RESULT(Result)
void SetSP(const lldb::TypeImplSP &type_impl_sp)
Definition: SBType.cpp:78
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)