Add a PythonModule class, and a root-level method for resolving names.

llvm-svn: 252765
This commit is contained in:
Zachary Turner committed 2015-11-11 17:59:49 +00:00
1 parent 7d7814ae8a
commit 7841efbb92
3 files changed
+196 -12

No files matched your search

@@ -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: