This patch adds the ability to pass native types from the script
interpreter to methods that use a {SB,}StructuredData argument.
To do so, this patch changes the `ScriptedObject` struture that holds
the pointer to the script object as well as the originating script
interpreter language. It also exposes that to the SB API via a new class
called `SBScriptObject`.
This structure allows the debugger to parse the script object and
convert it to a StructuredData object. If the type is not compatible
with the StructuredData types, we will store its pointer in a
`StructuredData::Generic` object.
This patch also adds some SWIG typemaps that checks the input argument to
ensure it's either an SBStructuredData object, in which case it just
passes it throught, or a python object that is NOT another SB type, to
provide some guardrails for the user.
rdar://111467140
Differential Revision: https://reviews.llvm.org/D155161
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
56 lines
1.3 KiB
C++
56 lines
1.3 KiB
C++
//===-- SBScriptObject.h ----------------------------------------*- C++ -*-===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLDB_API_SBSCRIPTOBJECT_H
|
|
#define LLDB_API_SBSCRIPTOBJECT_H
|
|
|
|
#include "lldb/API/SBDefines.h"
|
|
|
|
namespace lldb_private {
|
|
class ScriptObject;
|
|
}
|
|
|
|
namespace lldb {
|
|
|
|
class LLDB_API SBScriptObject {
|
|
public:
|
|
SBScriptObject(const ScriptObjectPtr ptr, lldb::ScriptLanguage lang);
|
|
|
|
SBScriptObject(const lldb::SBScriptObject &rhs);
|
|
|
|
~SBScriptObject();
|
|
|
|
const lldb::SBScriptObject &operator=(const lldb::SBScriptObject &rhs);
|
|
|
|
explicit operator bool() const;
|
|
|
|
bool operator!=(const SBScriptObject &rhs) const;
|
|
|
|
bool IsValid() const;
|
|
|
|
lldb::ScriptObjectPtr GetPointer() const;
|
|
|
|
lldb::ScriptLanguage GetLanguage() const;
|
|
|
|
protected:
|
|
friend class SBStructuredData;
|
|
|
|
lldb_private::ScriptObject *get();
|
|
|
|
lldb_private::ScriptObject &ref();
|
|
|
|
const lldb_private::ScriptObject &ref() const;
|
|
|
|
private:
|
|
std::unique_ptr<lldb_private::ScriptObject> m_opaque_up;
|
|
};
|
|
|
|
} // namespace lldb
|
|
|
|
#endif // LLDB_API_SBSCRIPTOBJECT_H
|