Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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).
33 PYROOT_INITIALIZE_STRING(gBranch, Branch);
34 PYROOT_INITIALIZE_STRING(gFitFCN, FitFCN);
36 PYROOT_INITIALIZE_STRING(gSetBranchAddress, SetBranchAddress);
37 PYROOT_INITIALIZE_STRING(gSetFCN, SetFCN);
38 PYROOT_INITIALIZE_STRING(gTClassDynCast, _TClass__DynamicCast);
39 PYROOT_INITIALIZE_STRING(gClass, __class__);
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;
54 Py_DECREF(PyStrings::gSetBranchAddress);
55 PyStrings::gSetBranchAddress = nullptr;
56 Py_DECREF(PyStrings::gSetFCN);
57 PyStrings::gSetFCN = nullptr;
58 Py_DECREF(PyStrings::gTClassDynCast);
59 PyStrings::gTClassDynCast = nullptr;
60 Py_DECREF(PyStrings::gClass);
61 PyStrings::gClass = nullptr;
62
63 Py_INCREF(Py_None);
64 return Py_None;
65}
_object PyObject
#define PYROOT_INITIALIZE_STRING(var, str)
R__EXTERN PyObject * gSetFCN
R__EXTERN PyObject * gClass
R__EXTERN PyObject * gFitFCN
R__EXTERN PyObject * gROOTns
R__EXTERN PyObject * gTClassDynCast
R__EXTERN PyObject * gSetBranchAddress
R__EXTERN PyObject * gBranch
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...