LLDB  mainline
SBTypeSynthetic.cpp
Go to the documentation of this file.
1 //===-- SBTypeSynthetic.cpp -----------------------------------------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
11 #include "SBReproducerPrivate.h"
12 
13 #include "lldb/API/SBStream.h"
14 
16 
17 using namespace lldb;
18 using namespace lldb_private;
19 
22 }
23 
25  uint32_t options) {
27  CreateWithClassName, (const char *, uint32_t), data,
28  options);
29 
30  if (!data || data[0] == 0)
32  return LLDB_RECORD_RESULT(SBTypeSynthetic(ScriptedSyntheticChildrenSP(
33  new ScriptedSyntheticChildren(options, data, ""))));
34 }
35 
37  uint32_t options) {
39  CreateWithScriptCode, (const char *, uint32_t),
40  data, options);
41 
42  if (!data || data[0] == 0)
44  return LLDB_RECORD_RESULT(SBTypeSynthetic(ScriptedSyntheticChildrenSP(
45  new ScriptedSyntheticChildren(options, "", data))));
46 }
47 
49  : m_opaque_sp(rhs.m_opaque_sp) {
51  rhs);
52 }
53 
55 
58  return this->operator bool();
59 }
60 SBTypeSynthetic::operator bool() const {
62 
63  return m_opaque_sp.get() != NULL;
64 }
65 
68 
69  if (!IsValid())
70  return false;
71  const char *code = m_opaque_sp->GetPythonCode();
72  return (code && *code);
73 }
74 
77 
78  if (!IsValid())
79  return false;
80  return !IsClassCode();
81 }
82 
83 const char *SBTypeSynthetic::GetData() {
85 
86  if (!IsValid())
87  return NULL;
88  if (IsClassCode())
89  return m_opaque_sp->GetPythonCode();
90  else
91  return m_opaque_sp->GetPythonClassName();
92 }
93 
94 void SBTypeSynthetic::SetClassName(const char *data) {
95  LLDB_RECORD_METHOD(void, SBTypeSynthetic, SetClassName, (const char *), data);
96 
97  if (IsValid() && data && *data)
98  m_opaque_sp->SetPythonClassName(data);
99 }
100 
101 void SBTypeSynthetic::SetClassCode(const char *data) {
102  LLDB_RECORD_METHOD(void, SBTypeSynthetic, SetClassCode, (const char *), data);
103 
104  if (IsValid() && data && *data)
105  m_opaque_sp->SetPythonCode(data);
106 }
107 
110 
111  if (!IsValid())
112  return lldb::eTypeOptionNone;
113  return m_opaque_sp->GetOptions();
114 }
115 
118 
119  if (!CopyOnWrite_Impl())
120  return;
121  m_opaque_sp->SetOptions(value);
122 }
123 
125  lldb::DescriptionLevel description_level) {
127  (lldb::SBStream &, lldb::DescriptionLevel), description,
128  description_level);
129 
130  if (m_opaque_sp) {
131  description.Printf("%s\n", m_opaque_sp->GetDescription().c_str());
132  return true;
133  }
134  return false;
135 }
136 
140  SBTypeSynthetic, operator=,(const lldb::SBTypeSynthetic &),
141  rhs);
142 
143  if (this != &rhs) {
144  m_opaque_sp = rhs.m_opaque_sp;
145  }
146  return LLDB_RECORD_RESULT(*this);
147 }
148 
151  bool, SBTypeSynthetic, operator==,(lldb::SBTypeSynthetic &), rhs);
152 
153  if (!IsValid())
154  return !rhs.IsValid();
155  return m_opaque_sp == rhs.m_opaque_sp;
156 }
157 
160  (lldb::SBTypeSynthetic &), rhs);
161 
162  if (!IsValid())
163  return !rhs.IsValid();
164 
165  if (m_opaque_sp->IsScripted() != rhs.m_opaque_sp->IsScripted())
166  return false;
167 
168  if (IsClassCode() != rhs.IsClassCode())
169  return false;
170 
171  if (strcmp(GetData(), rhs.GetData()))
172  return false;
173 
174  return GetOptions() == rhs.GetOptions();
175 }
176 
179  bool, SBTypeSynthetic, operator!=,(lldb::SBTypeSynthetic &), rhs);
180 
181  if (!IsValid())
182  return !rhs.IsValid();
183  return m_opaque_sp != rhs.m_opaque_sp;
184 }
185 
186 lldb::ScriptedSyntheticChildrenSP SBTypeSynthetic::GetSP() {
187  return m_opaque_sp;
188 }
189 
191  const lldb::ScriptedSyntheticChildrenSP &TypeSynthetic_impl_sp) {
192  m_opaque_sp = TypeSynthetic_impl_sp;
193 }
194 
196  const lldb::ScriptedSyntheticChildrenSP &TypeSynthetic_impl_sp)
197  : m_opaque_sp(TypeSynthetic_impl_sp) {}
198 
200  if (!IsValid())
201  return false;
202  if (m_opaque_sp.unique())
203  return true;
204 
205  ScriptedSyntheticChildrenSP new_sp(new ScriptedSyntheticChildren(
206  m_opaque_sp->GetOptions(), m_opaque_sp->GetPythonClassName(),
207  m_opaque_sp->GetPythonCode()));
208 
209  SetSP(new_sp);
210 
211  return true;
212 }
213 
214 namespace lldb_private {
215 namespace repro {
216 
217 template <>
221  CreateWithClassName, (const char *, uint32_t));
223  CreateWithScriptCode, (const char *, uint32_t));
226  LLDB_REGISTER_METHOD_CONST(bool, SBTypeSynthetic, operator bool, ());
229  LLDB_REGISTER_METHOD(const char *, SBTypeSynthetic, GetData, ());
230  LLDB_REGISTER_METHOD(void, SBTypeSynthetic, SetClassName, (const char *));
231  LLDB_REGISTER_METHOD(void, SBTypeSynthetic, SetClassCode, (const char *));
238  SBTypeSynthetic, operator=,(const lldb::SBTypeSynthetic &));
240  SBTypeSynthetic, operator==,(lldb::SBTypeSynthetic &));
244  SBTypeSynthetic, operator!=,(lldb::SBTypeSynthetic &));
245 }
246 
247 }
248 }
The registry contains a unique mapping between functions and their ID.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
lldb::ScriptedSyntheticChildrenSP m_opaque_sp
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
#define LLDB_RECORD_STATIC_METHOD(Result, Class, Method, Signature,...)
static SBTypeSynthetic CreateWithScriptCode(const char *data, uint32_t options=0)
#define LLDB_REGISTER_STATIC_METHOD(Result, Class, Method, Signature)
void SetClassName(const char *data)
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
void Printf(const char *format,...) __attribute__((format(printf
Definition: SBStream.cpp:62
void SetClassCode(const char *data)
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
bool operator==(lldb::SBTypeSynthetic &rhs)
static SBTypeSynthetic CreateWithClassName(const char *data, uint32_t options=0)
lldb::ScriptedSyntheticChildrenSP GetSP()
lldb::SBTypeSynthetic & operator=(const lldb::SBTypeSynthetic &rhs)
Definition: SBAddress.h:15
bool operator!=(lldb::SBTypeSynthetic &rhs)
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
void RegisterMethods< SBTypeSynthetic >(Registry &R)
void SetSP(const lldb::ScriptedSyntheticChildrenSP &typefilter_impl_sp)
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
bool IsEqualTo(lldb::SBTypeSynthetic &rhs)
#define LLDB_RECORD_RESULT(Result)
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)