Logo ROOT  
Reference Guide
PyROOTStrings.cxx
Go to the documentation of this file.
1// Author: Enric Tejedor CERN 06/2018
2// Original PyROOT code by Wim Lavrijsen, LBL
3
4/*************************************************************************
5 * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12// Bindings
13#include "CPyCppyy.h"
14#include "PyROOTStrings.h"
15
16// Define cached python strings
24
25#define PYROOT_INITIALIZE_STRING(var, str) \
26 if (!(PyStrings::var = CPyCppyy_PyText_InternFromString((char *)#str))) \
27 return false
28
30{
31 // Build cache of commonly used python strings (the cache is python intern, so
32 // all strings are shared python-wide, not just in PyROOT).
38 PYROOT_INITIALIZE_STRING(gTClassDynCast, _TClass__DynamicCast);
40
41 return true;
42}
43
44/// Remove all cached python strings.
45
47{
48 Py_DECREF(PyStrings::gBranch);
49 PyStrings::gBranch = nullptr;
50 Py_DECREF(PyStrings::gFitFCN);
51 PyStrings::gFitFCN = nullptr;
52 Py_DECREF(PyStrings::gROOTns);
53 PyStrings::gROOTns = nullptr;
56 Py_DECREF(PyStrings::gSetFCN);
57 PyStrings::gSetFCN = nullptr;
60 Py_DECREF(PyStrings::gClass);
61 PyStrings::gClass = nullptr;
62
63 Py_INCREF(Py_None);
64 return Py_None;
65}
_object PyObject
Definition: PyMethodBase.h:41
#define PYROOT_INITIALIZE_STRING(var, str)
R__EXTERN PyObject * gSetFCN
Definition: PyROOTStrings.h:28
R__EXTERN PyObject * gClass
Definition: PyROOTStrings.h:31
R__EXTERN PyObject * gFitFCN
Definition: PyROOTStrings.h:25
R__EXTERN PyObject * gROOTns
Definition: PyROOTStrings.h:26
R__EXTERN PyObject * gTClassDynCast
Definition: PyROOTStrings.h:29
R__EXTERN PyObject * gSetBranchAddress
Definition: PyROOTStrings.h:27
R__EXTERN PyObject * gBranch
Definition: PyROOTStrings.h:24
bool CreatePyStrings()
PyObject * DestroyPyStrings()
Remove all cached python strings.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21