Skip to content
Snippets Groups Projects
Commit ae65108f authored by Stefan Wunsch's avatar Stefan Wunsch Committed by Enric Tejedor
Browse files

[Experimental PyROOT] Restructure generic pythonizations

parent 0b310c29
Branches
Tags
No related merge requests found
...@@ -10,7 +10,7 @@ set(sources ...@@ -10,7 +10,7 @@ set(sources
src/PyROOTStrings.cxx src/PyROOTStrings.cxx
src/PyROOTWrapper.cxx src/PyROOTWrapper.cxx
src/TTreePyz.cxx src/TTreePyz.cxx
src/GenericPyz.cxx src/PrettyPrintingPyz.cxx
) )
file(COPY python/ROOT DESTINATION ${localruntimedir}) file(COPY python/ROOT DESTINATION ${localruntimedir})
......
from libROOTPython import PythonizeGeneric from libROOTPython import AddPrettyPrintingPyz
from ROOT import pythonization from ROOT import pythonization
@pythonization @pythonization
...@@ -7,7 +7,7 @@ def pythonizegeneric(klass, name): ...@@ -7,7 +7,7 @@ def pythonizegeneric(klass, name):
# klass: class to be pythonized # klass: class to be pythonized
# name: string containing the name of the class # name: string containing the name of the class
# Add pythonizations generically to all classes # Add pretty printing via setting the __str__ special function
PythonizeGeneric(klass) AddPrettyPrintingPyz(klass)
return True return True
...@@ -31,15 +31,15 @@ PyObject *ClingPrintValue(CPPInstance *self) ...@@ -31,15 +31,15 @@ PyObject *ClingPrintValue(CPPInstance *self)
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
/// \brief Add generic features to any class /// \brief Add pretty printing pythonization
/// \param[in] self Always null, since this is a module function. /// \param[in] self Always null, since this is a module function.
/// \param[in] args Pointer to a Python tuple object containing the arguments /// \param[in] args Pointer to a Python tuple object containing the arguments
/// received from Python. /// received from Python.
/// ///
/// This function adds the following pythonizations: /// This function adds the following pythonizations to print the object more
/// - Prints the object more user-friendly than cppyy by using the output of /// user-friendly than cppyy by using the output of cling::printValue as the
/// cling::printValue as the return value of the special method __str__. /// return value of the special method __str__.
PyObject *PyROOT::PythonizeGeneric(PyObject * /* self */, PyObject *args) PyObject *PyROOT::AddPrettyPrintingPyz(PyObject * /* self */, PyObject *args)
{ {
PyObject *pyclass = PyTuple_GetItem(args, 0); PyObject *pyclass = PyTuple_GetItem(args, 0);
Utility::AddToClass(pyclass, "__str__", (PyCFunction)ClingPrintValue); Utility::AddToClass(pyclass, "__str__", (PyCFunction)ClingPrintValue);
......
...@@ -29,8 +29,8 @@ PyObject *gRootModule = 0; ...@@ -29,8 +29,8 @@ PyObject *gRootModule = 0;
// Methods offered by the interface // Methods offered by the interface
static PyMethodDef gPyROOTMethods[] = {{(char *)"PythonizeTTree", (PyCFunction)PyROOT::PythonizeTTree, METH_VARARGS, static PyMethodDef gPyROOTMethods[] = {{(char *)"PythonizeTTree", (PyCFunction)PyROOT::PythonizeTTree, METH_VARARGS,
(char *)"Pythonizations for class TTree"}, (char *)"Pythonizations for class TTree"},
{(char *)"PythonizeGeneric", (PyCFunction)PyROOT::PythonizeGeneric, METH_VARARGS, {(char *)"AddPrettyPrintingPyz", (PyCFunction)PyROOT::AddPrettyPrintingPyz, METH_VARARGS,
(char *)"Generic pythonizations for all classes"}, (char *)"Add pretty printing pythonization"},
{NULL, NULL, 0, NULL}}; {NULL, NULL, 0, NULL}};
#if PY_VERSION_HEX >= 0x03000000 #if PY_VERSION_HEX >= 0x03000000
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
namespace PyROOT { namespace PyROOT {
PyObject *PythonizeGeneric(PyObject *self, PyObject *args); PyObject *AddPrettyPrintingPyz(PyObject *self, PyObject *args);
PyObject *PythonizeTTree(PyObject *self, PyObject *args); PyObject *PythonizeTTree(PyObject *self, PyObject *args);
} // namespace PyROOT } // namespace PyROOT
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment