diff options
author | Zachary Turner <zturner@google.com> | 2015-11-11 17:59:49 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2015-11-11 17:59:49 +0000 |
commit | 7841efbb9255126763167b9d7d59242333c6f1bd (patch) | |
tree | 772ef04f6ea7c4bf9115b57228f2e8122164b55f /lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h | |
parent | 7d7814ae8a50999db77c0617989232d807c801a2 (diff) | |
download | llvm-7841efbb9255126763167b9d7d59242333c6f1bd.zip llvm-7841efbb9255126763167b9d7d59242333c6f1bd.tar.gz llvm-7841efbb9255126763167b9d7d59242333c6f1bd.tar.bz2 |
Add a `PythonModule` class, and a root-level method for resolving names.
llvm-svn: 252765
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h')
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h index 477a427..beeea4c 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h @@ -69,6 +69,7 @@ enum class PyObjectType Dictionary, List, String, + Module, File }; @@ -185,15 +186,6 @@ public: return result; } - PyObjectType - GetObjectType() const; - - PythonString - Repr (); - - PythonString - Str (); - PythonObject & operator=(const PythonObject &other) { @@ -201,6 +193,21 @@ public: return *this; } + PyObjectType + GetObjectType() const; + + PythonString + Repr() const; + + PythonString + Str() const; + + static PythonObject + ResolveNameGlobal(llvm::StringRef name); + + PythonObject + ResolveName(llvm::StringRef name) const; + bool HasAttribute(llvm::StringRef attribute) const; @@ -224,7 +231,8 @@ public: return T(PyRefType::Borrowed, m_py_obj); } - StructuredData::ObjectSP CreateStructuredObject() const; + StructuredData::ObjectSP + CreateStructuredObject() const; protected: PyObject* m_py_obj; @@ -338,6 +346,27 @@ public: StructuredData::DictionarySP CreateStructuredDictionary() const; }; +class PythonModule : public PythonObject +{ + public: + PythonModule(); + PythonModule(PyRefType type, PyObject *o); + PythonModule(const PythonModule &dict); + + ~PythonModule() override; + + static bool Check(PyObject *py_obj); + + static PythonModule MainModule(); + + // Bring in the no-argument base class version + using PythonObject::Reset; + + void Reset(PyRefType type, PyObject *py_obj) override; + + PythonDictionary GetDictionary() const; +}; + class PythonFile : public PythonObject { public: |