Logo ROOT   6.08/07
Reference Guide
PyStrings.cxx
Go to the documentation of this file.
1 // Author: Wim Lavrijsen, Nov 2008
2 
3 // Bindings
4 #include "PyROOT.h"
5 #include "PyStrings.h"
6 
7 
8 //- data _____________________________________________________________________
30 
35 
46 
53 
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 
57 #define PYROOT_INITIALIZE_STRING( var, str ) \
58  if ( ! ( PyStrings::var = PyROOT_PyUnicode_InternFromString( (char*)#str ) ) ) \
59  return kFALSE
60 
62 // Build cache of commonly used python strings (the cache is python intern, so
63 // all strings are shared python-wide, not just in PyROOT).
64  PYROOT_INITIALIZE_STRING( gBases, __bases__ );
65  PYROOT_INITIALIZE_STRING( gBase, __base__ );
66  PYROOT_INITIALIZE_STRING( gClass, __class__ );
67  PYROOT_INITIALIZE_STRING( gCppEq, __cpp_eq__ );
68  PYROOT_INITIALIZE_STRING( gCppNe, __cpp_ne__ );
69  PYROOT_INITIALIZE_STRING( gDeref, __deref__ );
70  PYROOT_INITIALIZE_STRING( gDict, __dict__ );
71  if ( ! ( PyStrings::gEmptyString = PyROOT_PyUnicode_FromString( (char*)"" ) ) )
72  return kFALSE;
73  PYROOT_INITIALIZE_STRING( gEq, __eq__ );
74  PYROOT_INITIALIZE_STRING( gFollow, __follow__ );
75  PYROOT_INITIALIZE_STRING( gGetItem, __getitem__ );
76  PYROOT_INITIALIZE_STRING( gInit, __init__ );
77  PYROOT_INITIALIZE_STRING( gIter, __iter__ );
78  PYROOT_INITIALIZE_STRING( gLen, __len__ );
79  PYROOT_INITIALIZE_STRING( gLifeLine, __lifeline );
80  PYROOT_INITIALIZE_STRING( gModule, __module__ );
81  PYROOT_INITIALIZE_STRING( gMRO, __mro__ );
82  PYROOT_INITIALIZE_STRING( gName, __name__ );
83  PYROOT_INITIALIZE_STRING( gCppName, __cppname__ );
84  PYROOT_INITIALIZE_STRING( gNe, __ne__ );
86 
87  PYROOT_INITIALIZE_STRING( gAdd, __add__ );
88  PYROOT_INITIALIZE_STRING( gSub, __sub__ );
89  PYROOT_INITIALIZE_STRING( gMul, __mul__ );
91 
100  PYROOT_INITIALIZE_STRING( gTemplate, Template );
101  PYROOT_INITIALIZE_STRING( gVectorAt, _vector__at );
102 
106  PYROOT_INITIALIZE_STRING( gSetBranchAddress, SetBranchAddress );
108  PYROOT_INITIALIZE_STRING( gTClassDynCast, _TClass__DynamicCast );
109 
110  return kTRUE;
111 }
112 
113 ////////////////////////////////////////////////////////////////////////////////
114 /// Remove all cached python strings.
115 
117  Py_DECREF( PyStrings::gBases ); PyStrings::gBases = 0;
118  Py_DECREF( PyStrings::gBase ); PyStrings::gBase = 0;
119  Py_DECREF( PyStrings::gClass ); PyStrings::gClass = 0;
120  Py_DECREF( PyStrings::gCppEq ); PyStrings::gCppEq = 0;
121  Py_DECREF( PyStrings::gCppNe ); PyStrings::gCppNe = 0;
122  Py_DECREF( PyStrings::gDeref ); PyStrings::gDeref = 0;
123  Py_DECREF( PyStrings::gDict ); PyStrings::gDict = 0;
125  Py_DECREF( PyStrings::gEq ); PyStrings::gEq = 0;
126  Py_DECREF( PyStrings::gFollow ); PyStrings::gFollow = 0;
127  Py_DECREF( PyStrings::gGetItem ); PyStrings::gGetItem = 0;
128  Py_DECREF( PyStrings::gInit ); PyStrings::gInit = 0;
129  Py_DECREF( PyStrings::gIter ); PyStrings::gIter = 0;
130  Py_DECREF( PyStrings::gLen ); PyStrings::gLen = 0;
131  Py_DECREF( PyStrings::gLifeLine ); PyStrings::gLifeLine = 0;
132  Py_DECREF( PyStrings::gModule ); PyStrings::gModule = 0;
133  Py_DECREF( PyStrings::gMRO ); PyStrings::gMRO = 0;
134  Py_DECREF( PyStrings::gName ); PyStrings::gName = 0;
135  Py_DECREF( PyStrings::gCppName ); PyStrings::gCppName = 0;
136  Py_DECREF( PyStrings::gNe ); PyStrings::gNe = 0;
137  Py_DECREF( PyStrings::gTypeCode ); PyStrings::gTypeCode = 0;
138 
139  Py_DECREF( PyStrings::gAdd ); PyStrings::gAdd = 0;
140  Py_DECREF( PyStrings::gSub ); PyStrings::gSub = 0;
141  Py_DECREF( PyStrings::gMul ); PyStrings::gMul = 0;
142  Py_DECREF( PyStrings::gDiv ); PyStrings::gDiv = 0;
143 
144  Py_DECREF( PyStrings::gAt ); PyStrings::gAt = 0;
145  Py_DECREF( PyStrings::gBegin ); PyStrings::gBegin = 0;
146  Py_DECREF( PyStrings::gEnd ); PyStrings::gEnd = 0;
147  Py_DECREF( PyStrings::gFirst ); PyStrings::gFirst = 0;
148  Py_DECREF( PyStrings::gSecond ); PyStrings::gSecond = 0;
149  Py_DECREF( PyStrings::gSize ); PyStrings::gSize = 0;
150  Py_DECREF( PyStrings::gGetSize ); PyStrings::gGetSize = 0;
151  Py_DECREF( PyStrings::ggetSize ); PyStrings::ggetSize = 0;
152  Py_DECREF( PyStrings::gTemplate ); PyStrings::gTemplate = 0;
153  Py_DECREF( PyStrings::gVectorAt ); PyStrings::gVectorAt = 0;
154 
155  Py_DECREF( PyStrings::gBranch ); PyStrings::gBranch = 0;
156  Py_DECREF( PyStrings::gFitFCN ); PyStrings::gFitFCN = 0;
157  Py_DECREF( PyStrings::gROOTns ); PyStrings::gROOTns = 0;
159  Py_DECREF( PyStrings::gSetFCN ); PyStrings::gSetFCN = 0;
161 
162  Py_INCREF( Py_None );
163  return Py_None;
164 }
R__EXTERN PyObject * gFirst
Definition: PyStrings.h:46
R__EXTERN PyObject * gCppEq
Definition: PyStrings.h:19
R__EXTERN PyObject * gInit
Definition: PyStrings.h:27
#define PyROOT_PyUnicode_FromString
Definition: PyROOT.h:71
R__EXTERN PyObject * gIter
Definition: PyStrings.h:28
R__EXTERN PyObject * gDict
Definition: PyStrings.h:22
R__EXTERN PyObject * gEq
Definition: PyStrings.h:24
R__EXTERN PyObject * gGetSize
Definition: PyStrings.h:49
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
R__EXTERN PyObject * gDiv
Definition: PyStrings.h:41
R__EXTERN PyObject * gTClassDynCast
Definition: PyStrings.h:59
R__EXTERN PyObject * gSize
Definition: PyStrings.h:48
R__EXTERN PyObject * gFollow
Definition: PyStrings.h:25
R__EXTERN PyObject * gSetFCN
Definition: PyStrings.h:58
R__EXTERN PyObject * gTemplate
Definition: PyStrings.h:51
R__EXTERN PyObject * gBranch
Definition: PyStrings.h:54
R__EXTERN PyObject * gFitFCN
Definition: PyStrings.h:55
bool Bool_t
Definition: RtypesCore.h:59
R__EXTERN PyObject * gEnd
Definition: PyStrings.h:45
const Bool_t kFALSE
Definition: Rtypes.h:92
R__EXTERN PyObject * gCppNe
Definition: PyStrings.h:20
R__EXTERN PyObject * gVectorAt
Definition: PyStrings.h:52
R__EXTERN PyObject * gDeref
Definition: PyStrings.h:21
R__EXTERN PyObject * gAdd
Definition: PyStrings.h:38
R__EXTERN PyObject * gBase
Definition: PyStrings.h:17
R__EXTERN PyObject * gMRO
Definition: PyStrings.h:32
R__EXTERN PyObject * gModule
Definition: PyStrings.h:31
R__EXTERN PyObject * gAt
Definition: PyStrings.h:43
#define PYROOT_INITIALIZE_STRING(var, str)
Definition: PyStrings.cxx:57
R__EXTERN PyObject * gBases
Definition: PyStrings.h:16
R__EXTERN PyObject * gClass
Definition: PyStrings.h:18
R__EXTERN PyObject * gBegin
Definition: PyStrings.h:44
R__EXTERN PyObject * gROOTns
Definition: PyStrings.h:56
PyObject * DestroyPyStrings()
Remove all cached python strings.
Definition: PyStrings.cxx:116
#define PYROOT__div__
Definition: PyROOT.h:91
Bool_t CreatePyStrings()
Definition: PyStrings.cxx:61
R__EXTERN PyObject * gGetItem
Definition: PyStrings.h:26
R__EXTERN PyObject * gName
Definition: PyStrings.h:33
R__EXTERN PyObject * gLifeLine
Definition: PyStrings.h:30
R__EXTERN PyObject * gTypeCode
Definition: PyStrings.h:36
R__EXTERN PyObject * gLen
Definition: PyStrings.h:29
R__EXTERN PyObject * gNe
Definition: PyStrings.h:35
R__EXTERN PyObject * gSub
Definition: PyStrings.h:39
R__EXTERN PyObject * gCppName
Definition: PyStrings.h:34
R__EXTERN PyObject * gSecond
Definition: PyStrings.h:47
R__EXTERN PyObject * ggetSize
Definition: PyStrings.h:50
Definition: first.py:1
R__EXTERN PyObject * gSetBranchAddress
Definition: PyStrings.h:57
const Bool_t kTRUE
Definition: Rtypes.h:91
_object PyObject
Definition: TPyArg.h:22
R__EXTERN PyObject * gEmptyString
Definition: PyStrings.h:23
R__EXTERN PyObject * gMul
Definition: PyStrings.h:40