diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 | 
| commit | 5f29bb8a675e8f96452b632e7129113f7dec850e (patch) | |
| tree | 3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /source/API/SBStructuredData.cpp | |
| parent | 88c643b6fec27eec436c8d138fee6346e92337d6 (diff) | |
Notes
Diffstat (limited to 'source/API/SBStructuredData.cpp')
| -rw-r--r-- | source/API/SBStructuredData.cpp | 141 | 
1 files changed, 123 insertions, 18 deletions
| diff --git a/source/API/SBStructuredData.cpp b/source/API/SBStructuredData.cpp index 277193424e99b..6b973e82c858b 100644 --- a/source/API/SBStructuredData.cpp +++ b/source/API/SBStructuredData.cpp @@ -1,13 +1,13 @@  //===-- SBStructuredData.cpp ------------------------------------*- C++ -*-===//  // -//                     The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception  //  //===----------------------------------------------------------------------===//  #include "lldb/API/SBStructuredData.h" +#include "SBReproducerPrivate.h"  #include "lldb/API/SBStream.h"  #include "lldb/API/SBStringList.h" @@ -24,26 +24,43 @@ using namespace lldb_private;  #pragma mark--  #pragma mark SBStructuredData -SBStructuredData::SBStructuredData() : m_impl_up(new StructuredDataImpl()) {} +SBStructuredData::SBStructuredData() : m_impl_up(new StructuredDataImpl()) { +  LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBStructuredData); +}  SBStructuredData::SBStructuredData(const lldb::SBStructuredData &rhs) -    : m_impl_up(new StructuredDataImpl(*rhs.m_impl_up.get())) {} +    : m_impl_up(new StructuredDataImpl(*rhs.m_impl_up.get())) { +  LLDB_RECORD_CONSTRUCTOR(SBStructuredData, (const lldb::SBStructuredData &), +                          rhs); +}  SBStructuredData::SBStructuredData(const lldb::EventSP &event_sp) -    : m_impl_up(new StructuredDataImpl(event_sp)) {} +    : m_impl_up(new StructuredDataImpl(event_sp)) { +  LLDB_RECORD_CONSTRUCTOR(SBStructuredData, (const lldb::EventSP &), event_sp); +}  SBStructuredData::SBStructuredData(lldb_private::StructuredDataImpl *impl) -    : m_impl_up(impl) {} +    : m_impl_up(impl) { +  LLDB_RECORD_CONSTRUCTOR(SBStructuredData, +                          (lldb_private::StructuredDataImpl *), impl); +}  SBStructuredData::~SBStructuredData() {}  SBStructuredData &SBStructuredData::  operator=(const lldb::SBStructuredData &rhs) { +  LLDB_RECORD_METHOD( +      lldb::SBStructuredData &, +      SBStructuredData, operator=,(const lldb::SBStructuredData &), rhs); +    *m_impl_up = *rhs.m_impl_up; -  return *this; +  return LLDB_RECORD_RESULT(*this);  }  lldb::SBError SBStructuredData::SetFromJSON(lldb::SBStream &stream) { +  LLDB_RECORD_METHOD(lldb::SBError, SBStructuredData, SetFromJSON, +                     (lldb::SBStream &), stream); +    lldb::SBError error;    std::string json_str(stream.GetData()); @@ -52,35 +69,61 @@ lldb::SBError SBStructuredData::SetFromJSON(lldb::SBStream &stream) {    if (!json_obj || json_obj->GetType() != eStructuredDataTypeDictionary)      error.SetErrorString("Invalid Syntax"); -  return error; +  return LLDB_RECORD_RESULT(error);  } -bool SBStructuredData::IsValid() const { return m_impl_up->IsValid(); } +bool SBStructuredData::IsValid() const { +  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStructuredData, IsValid); +  return this->operator bool(); +} +SBStructuredData::operator bool() const { +  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStructuredData, operator bool); + +  return m_impl_up->IsValid(); +} -void SBStructuredData::Clear() { m_impl_up->Clear(); } +void SBStructuredData::Clear() { +  LLDB_RECORD_METHOD_NO_ARGS(void, SBStructuredData, Clear); + +  m_impl_up->Clear(); +}  SBError SBStructuredData::GetAsJSON(lldb::SBStream &stream) const { +  LLDB_RECORD_METHOD_CONST(lldb::SBError, SBStructuredData, GetAsJSON, +                           (lldb::SBStream &), stream); +    SBError error;    error.SetError(m_impl_up->GetAsJSON(stream.ref())); -  return error; +  return LLDB_RECORD_RESULT(error);  }  lldb::SBError SBStructuredData::GetDescription(lldb::SBStream &stream) const { +  LLDB_RECORD_METHOD_CONST(lldb::SBError, SBStructuredData, GetDescription, +                           (lldb::SBStream &), stream); +    Status error = m_impl_up->GetDescription(stream.ref());    SBError sb_error;    sb_error.SetError(error); -  return sb_error; +  return LLDB_RECORD_RESULT(sb_error);  }  StructuredDataType SBStructuredData::GetType() const { +  LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::StructuredDataType, SBStructuredData, +                                   GetType); +    return (m_impl_up ? m_impl_up->GetType() : eStructuredDataTypeInvalid);  }  size_t SBStructuredData::GetSize() const { +  LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBStructuredData, GetSize); +    return (m_impl_up ? m_impl_up->GetSize() : 0);  }  bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const { +  LLDB_RECORD_METHOD_CONST(bool, SBStructuredData, GetKeys, +                           (lldb::SBStringList &), keys); +    if (!m_impl_up)      return false; @@ -108,35 +151,97 @@ bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const {  }  lldb::SBStructuredData SBStructuredData::GetValueForKey(const char *key) const { +  LLDB_RECORD_METHOD_CONST(lldb::SBStructuredData, SBStructuredData, +                           GetValueForKey, (const char *), key); +    if (!m_impl_up) -    return SBStructuredData(); +    return LLDB_RECORD_RESULT(SBStructuredData());    SBStructuredData result;    result.m_impl_up->SetObjectSP(m_impl_up->GetValueForKey(key)); -  return result; +  return LLDB_RECORD_RESULT(result);  }  lldb::SBStructuredData SBStructuredData::GetItemAtIndex(size_t idx) const { +  LLDB_RECORD_METHOD_CONST(lldb::SBStructuredData, SBStructuredData, +                           GetItemAtIndex, (size_t), idx); +    if (!m_impl_up) -    return SBStructuredData(); +    return LLDB_RECORD_RESULT(SBStructuredData());    SBStructuredData result;    result.m_impl_up->SetObjectSP(m_impl_up->GetItemAtIndex(idx)); -  return result; +  return LLDB_RECORD_RESULT(result);  }  uint64_t SBStructuredData::GetIntegerValue(uint64_t fail_value) const { +  LLDB_RECORD_METHOD_CONST(uint64_t, SBStructuredData, GetIntegerValue, +                           (uint64_t), fail_value); +    return (m_impl_up ? m_impl_up->GetIntegerValue(fail_value) : fail_value);  }  double SBStructuredData::GetFloatValue(double fail_value) const { +  LLDB_RECORD_METHOD_CONST(double, SBStructuredData, GetFloatValue, (double), +                           fail_value); +    return (m_impl_up ? m_impl_up->GetFloatValue(fail_value) : fail_value);  }  bool SBStructuredData::GetBooleanValue(bool fail_value) const { +  LLDB_RECORD_METHOD_CONST(bool, SBStructuredData, GetBooleanValue, (bool), +                           fail_value); +    return (m_impl_up ? m_impl_up->GetBooleanValue(fail_value) : fail_value);  }  size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const { +  LLDB_RECORD_METHOD_CONST(size_t, SBStructuredData, GetStringValue, +                           (char *, size_t), dst, dst_len); +    return (m_impl_up ? m_impl_up->GetStringValue(dst, dst_len) : 0);  } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBStructuredData>(Registry &R) { +  LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, ()); +  LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, +                            (const lldb::SBStructuredData &)); +  LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, (const lldb::EventSP &)); +  LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, +                            (lldb_private::StructuredDataImpl *)); +  LLDB_REGISTER_METHOD( +      lldb::SBStructuredData &, +      SBStructuredData, operator=,(const lldb::SBStructuredData &)); +  LLDB_REGISTER_METHOD(lldb::SBError, SBStructuredData, SetFromJSON, +                       (lldb::SBStream &)); +  LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, IsValid, ()); +  LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, operator bool, ()); +  LLDB_REGISTER_METHOD(void, SBStructuredData, Clear, ()); +  LLDB_REGISTER_METHOD_CONST(lldb::SBError, SBStructuredData, GetAsJSON, +                             (lldb::SBStream &)); +  LLDB_REGISTER_METHOD_CONST(lldb::SBError, SBStructuredData, GetDescription, +                             (lldb::SBStream &)); +  LLDB_REGISTER_METHOD_CONST(lldb::StructuredDataType, SBStructuredData, +                             GetType, ()); +  LLDB_REGISTER_METHOD_CONST(size_t, SBStructuredData, GetSize, ()); +  LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, GetKeys, +                             (lldb::SBStringList &)); +  LLDB_REGISTER_METHOD_CONST(lldb::SBStructuredData, SBStructuredData, +                             GetValueForKey, (const char *)); +  LLDB_REGISTER_METHOD_CONST(lldb::SBStructuredData, SBStructuredData, +                             GetItemAtIndex, (size_t)); +  LLDB_REGISTER_METHOD_CONST(uint64_t, SBStructuredData, GetIntegerValue, +                             (uint64_t)); +  LLDB_REGISTER_METHOD_CONST(double, SBStructuredData, GetFloatValue, +                             (double)); +  LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, GetBooleanValue, (bool)); +  LLDB_REGISTER_METHOD_CONST(size_t, SBStructuredData, GetStringValue, +                             (char *, size_t)); +} + +} +} | 
