Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Compatibility.h
Go to the documentation of this file.
1#ifndef CPYRT_COMPATIBILITY_H
2#define CPYRT_COMPATIBILITY_H
3
4#include "Python.h"
5
6#include "cppjit_interop.h"
7
8#include <string>
9
11
13#ifdef CPPJIT_USE_CLING
14 static PyObject* printValue = nullptr;
15 if (printValue)
16 return printValue;
17
18 PyObject* gbl =
19 PyDict_GetItemString(PySys_GetObject((char*)"modules"), "cppjit.gbl");
20 PyObject* cling = gbl ? PyObject_GetAttrString(gbl, (char*)"cling") : nullptr;
21 printValue =
22 cling ? PyObject_GetAttrString(cling, (char*)"printValue") : nullptr;
23 Py_XDECREF(cling);
24
25 if (printValue) {
26 Py_DECREF(printValue); // make borrowed
27 if (!PyCallable_Check(printValue))
28 printValue = nullptr;
29 }
30
31 if (!printValue)
32 PyErr_Clear();
33
34 return printValue;
35#else
36 return nullptr;
37#endif
38}
39
40// Interpreter::toString is an assert(0) stub (CppInterOp#1100); skip it.
41inline std::string ObjToString(interop::TCppScope_t /*klass*/,
42 interop::TCppObject_t /*obj*/) {
43 return "";
44}
45
46} // namespace cppjit::cpyrt::compat
47
48#endif // CPYRT_COMPATIBILITY_H
_object PyObject
PyObject * GetClingPrintValue()
std::string ObjToString(interop::TCppScope_t, interop::TCppObject_t)
Cpp::ObjectRef TCppObject_t
Definition API.h:43
Cpp::DeclRef TCppScope_t
Definition API.h:41