Added Repr() and Str() member functions to our PythonObject class to allow easy conversion to-string of every PythonObject
llvm-svn: 186205
This commit is contained in:
@@ -66,6 +66,28 @@ PythonObject::Dump (Stream &strm) const
|
||||
strm.PutCString ("NULL");
|
||||
}
|
||||
|
||||
PythonString
|
||||
PythonObject::Repr ()
|
||||
{
|
||||
if (!m_py_obj)
|
||||
return PythonString ();
|
||||
PyObject *repr = PyObject_Repr(m_py_obj);
|
||||
if (!repr)
|
||||
return PythonString ();
|
||||
return PythonString(repr);
|
||||
}
|
||||
|
||||
PythonString
|
||||
PythonObject::Str ()
|
||||
{
|
||||
if (!m_py_obj)
|
||||
return PythonString ();
|
||||
PyObject *str = PyObject_Str(m_py_obj);
|
||||
if (!str)
|
||||
return PythonString ();
|
||||
return PythonString(str);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// PythonString
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user