Skip to content
Snippets Groups Projects
Commit c1b52fde authored by Enric Tejedor Saavedra's avatar Enric Tejedor Saavedra
Browse files

[Exp PyROOT] Use TInterpreter::ToString also in pretty printing experimental

parent cdd47a27
No related branches found
No related tags found
No related merge requests found
// Author: Stefan Wunsch CERN 06/2018
// Author: Stefan Wunsch, Enric Tejedor CERN 06/2018
// Original PyROOT code by Wim Lavrijsen, LBL
/*************************************************************************
......@@ -16,9 +16,6 @@
#include "TInterpreter.h"
#include "TInterpreterValue.h"
#include <sstream>
#include <algorithm>
using namespace CPyCppyy;
std::string GetCppName(CPPInstance *self)
......@@ -29,15 +26,8 @@ std::string GetCppName(CPPInstance *self)
PyObject *ClingPrintValue(CPPInstance *self)
{
const std::string className = GetCppName(self);
std::stringstream code;
code << "*((" << className << "*)" << self->GetObject() << ")";
auto value = gInterpreter->MakeInterpreterValue();
std::string pprint = "";
if (gInterpreter->Evaluate(code.str().c_str(), *value) == 1 /*success*/)
pprint = value->ToTypeAndValueString().second;
pprint.erase(std::remove(pprint.begin(), pprint.end(), '\n'), pprint.end());
return CPyCppyy_PyUnicode_FromString(pprint.c_str());
auto printResult = gInterpreter->ToString(className.c_str(), self->GetObject());
return CPyCppyy_PyUnicode_FromString(printResult.c_str());
}
////////////////////////////////////////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment