37 if (
auto clInfo = cl->GetClassInfo()) {
48 static std::map<ULong64_t, void *> declIDPrinterMap;
53 return PyObject_Repr((
PyObject*)self);
59 if (0 == declIDPrinterMap.size()) {
60 std::string printerCode =
"namespace ROOT::Internal::Pythonizations::ValuePrinters"
62 " template<class T, ULong64_t> std::string ValuePrinter(void *obj)"
64 " return cling::printValue((T *)obj);"
70 const std::string className =
GetCppName(self);
72 std::string printResult;
74 if (
const auto classID =
GetClassID(className.c_str())) {
81 auto &printerFuncrPtr = declIDPrinterMap[classID];
83 if (!printerFuncrPtr) {
84 std::string printFuncName =
"ROOT::Internal::Pythonizations::ValuePrinters::ValuePrinter<" + className +
", " +
85 std::to_string(classID) +
">";
86 printerFuncrPtr = (
void *)
gInterpreter->Calc(printFuncName.c_str());
88 printResult = ((std::string(*)(
void *))printerFuncrPtr)(cppObj);
91 printResult =
gInterpreter->ToString(className.c_str(), cppObj);
94 if (printResult.find(
"@0x") == 0) {
96 return PyObject_Repr((
PyObject*)self);
113 PyObject *pyclass = PyTuple_GetItem(args, 0);
#define CPyCppyy_PyText_FromString
static ULong64_t GetClassID(const char *clName)
static std::string GetCppName(const CPPInstance *self)
PyObject * ClingPrintValue(CPPInstance *self, PyObject *)
unsigned long long ULong64_t
Cppyy::TCppType_t ObjectIsA(bool check_smart=true) const
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
bool AddToClass(PyObject *pyclass, const char *label, PyCFunction cfunc, int flags=METH_VARARGS)
Set of helper functions that are invoked from the pythonizors, on the Python side.
RPY_EXPORTED std::string GetScopedFinalName(TCppType_t type)
PyObject * AddPrettyPrintingPyz(PyObject *self, PyObject *args)
Add pretty printing pythonization.