ROOT  6.06/09
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 _____________________________________________________________________
29 
34 
45 
52 
53 
54 ////////////////////////////////////////////////////////////////////////////////
55 
56 #define PYROOT_INITIALIZE_STRING( var, str ) \
57  if ( ! ( PyStrings::var = PyROOT_PyUnicode_InternFromString( (char*)#str ) ) ) \
58  return kFALSE
59 
61 // Build cache of commonly used python strings (the cache is python intern, so
62 // all strings are shared python-wide, not just in PyROOT).
63  PYROOT_INITIALIZE_STRING( gBases, __bases__ );
64  PYROOT_INITIALIZE_STRING( gBase, __base__ );
65  PYROOT_INITIALIZE_STRING( gClass, __class__ );
66  PYROOT_INITIALIZE_STRING( gCppEq, __cpp_eq__ );
67  PYROOT_INITIALIZE_STRING( gCppNe, __cpp_ne__ );
68  PYROOT_INITIALIZE_STRING( gDeref, __deref__ );
69  PYROOT_INITIALIZE_STRING( gDict, __dict__ );
70  if ( ! ( PyStrings::gEmptyString = PyROOT_PyUnicode_FromString( (char*)"" ) ) )
71  return kFALSE;
72  PYROOT_INITIALIZE_STRING( gEq, __eq__ );
73  PYROOT_INITIALIZE_STRING( gFollow, __follow__ );
74  PYROOT_INITIALIZE_STRING( gGetItem, __getitem__ );
75  PYROOT_INITIALIZE_STRING( gInit, __init__ );
76  PYROOT_INITIALIZE_STRING( gIter, __iter__ );
77  PYROOT_INITIALIZE_STRING( gLen, __len__ );
78  PYROOT_INITIALIZE_STRING( gLifeLine, __lifeline );
79  PYROOT_INITIALIZE_STRING( gModule, __module__ );
80  PYROOT_INITIALIZE_STRING( gMRO, __mro__ );
81  PYROOT_INITIALIZE_STRING( gName, __name__ );
82  PYROOT_INITIALIZE_STRING( gNe, __ne__ );
84 
85  PYROOT_INITIALIZE_STRING( gAdd, __add__ );
86  PYROOT_INITIALIZE_STRING( gSub, __sub__ );
87  PYROOT_INITIALIZE_STRING( gMul, __mul__ );
89 
99  PYROOT_INITIALIZE_STRING( gVectorAt, _vector__at );
100 
104  PYROOT_INITIALIZE_STRING( gSetBranchAddress, SetBranchAddress );
106  PYROOT_INITIALIZE_STRING( gTClassDynCast, _TClass__DynamicCast );
107 
108  return kTRUE;
109 }
110 
111 ////////////////////////////////////////////////////////////////////////////////
112 /// Remove all cached python strings.
113 
115  Py_DECREF( PyStrings::gBases ); PyStrings::gBases = 0;
116  Py_DECREF( PyStrings::gBase ); PyStrings::gBase = 0;
117  Py_DECREF( PyStrings::gClass ); PyStrings::gClass = 0;
118  Py_DECREF( PyStrings::gCppEq ); PyStrings::gCppEq = 0;
119  Py_DECREF( PyStrings::gCppNe ); PyStrings::gCppNe = 0;
120  Py_DECREF( PyStrings::gDeref ); PyStrings::gDeref = 0;
121  Py_DECREF( PyStrings::gDict ); PyStrings::gDict = 0;
123  Py_DECREF( PyStrings::gEq ); PyStrings::gEq = 0;
124  Py_DECREF( PyStrings::gFollow ); PyStrings::gFollow = 0;
125  Py_DECREF( PyStrings::gGetItem ); PyStrings::gGetItem = 0;
126  Py_DECREF( PyStrings::gInit ); PyStrings::gInit = 0;
127  Py_DECREF( PyStrings::gIter ); PyStrings::gIter = 0;
128  Py_DECREF( PyStrings::gLen ); PyStrings::gLen = 0;
129  Py_DECREF( PyStrings::gLifeLine ); PyStrings::gLifeLine = 0;
130  Py_DECREF( PyStrings::gModule ); PyStrings::gModule = 0;
131  Py_DECREF( PyStrings::gMRO ); PyStrings::gMRO = 0;
132  Py_DECREF( PyStrings::gName ); PyStrings::gName = 0;
133  Py_DECREF( PyStrings::gNe ); PyStrings::gNe = 0;
134  Py_DECREF( PyStrings::gTypeCode ); PyStrings::gTypeCode = 0;
135 
136  Py_DECREF( PyStrings::gAdd ); PyStrings::gAdd = 0;
137  Py_DECREF( PyStrings::gSub ); PyStrings::gSub = 0;
138  Py_DECREF( PyStrings::gMul ); PyStrings::gMul = 0;
139  Py_DECREF( PyStrings::gDiv ); PyStrings::gDiv = 0;
140 
141  Py_DECREF( PyStrings::gAt ); PyStrings::gAt = 0;
142  Py_DECREF( PyStrings::gBegin ); PyStrings::gBegin = 0;
143  Py_DECREF( PyStrings::gEnd ); PyStrings::gEnd = 0;
144  Py_DECREF( PyStrings::gFirst ); PyStrings::gFirst = 0;
145  Py_DECREF( PyStrings::gSecond ); PyStrings::gSecond = 0;
146  Py_DECREF( PyStrings::gSize ); PyStrings::gSize = 0;
147  Py_DECREF( PyStrings::gGetSize ); PyStrings::gGetSize = 0;
148  Py_DECREF( PyStrings::ggetSize ); PyStrings::ggetSize = 0;
149  Py_DECREF( PyStrings::gTemplate ); PyStrings::gTemplate = 0;
150  Py_DECREF( PyStrings::gVectorAt ); PyStrings::gVectorAt = 0;
151 
152  Py_DECREF( PyStrings::gBranch ); PyStrings::gBranch = 0;
153  Py_DECREF( PyStrings::gFitFCN ); PyStrings::gFitFCN = 0;
154  Py_DECREF( PyStrings::gROOTns ); PyStrings::gROOTns = 0;
156  Py_DECREF( PyStrings::gSetFCN ); PyStrings::gSetFCN = 0;
158 
159  Py_INCREF( Py_None );
160  return Py_None;
161 }
R__EXTERN PyObject * gFirst
Definition: PyStrings.h:45
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:48
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
R__EXTERN PyObject * gDiv
Definition: PyStrings.h:40
R__EXTERN PyObject * gTClassDynCast
Definition: PyStrings.h:58
R__EXTERN PyObject * gSize
Definition: PyStrings.h:47
R__EXTERN PyObject * gFollow
Definition: PyStrings.h:25
R__EXTERN PyObject * gSetFCN
Definition: PyStrings.h:57
R__EXTERN PyObject * gTemplate
Definition: PyStrings.h:50
R__EXTERN PyObject * gBranch
Definition: PyStrings.h:53
R__EXTERN PyObject * gFitFCN
Definition: PyStrings.h:54
bool Bool_t
Definition: RtypesCore.h:59
R__EXTERN PyObject * gEnd
Definition: PyStrings.h:44
const Bool_t kFALSE
Definition: Rtypes.h:92
R__EXTERN PyObject * gCppNe
Definition: PyStrings.h:20
R__EXTERN PyObject * gVectorAt
Definition: PyStrings.h:51
R__EXTERN PyObject * gDeref
Definition: PyStrings.h:21
TObject Int_t at
R__EXTERN PyObject * gAdd
Definition: PyStrings.h:37
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:42
#define PYROOT_INITIALIZE_STRING(var, str)
Definition: PyStrings.cxx:56
R__EXTERN PyObject * gBases
Definition: PyStrings.h:16
R__EXTERN PyObject * gClass
Definition: PyStrings.h:18
R__EXTERN PyObject * gBegin
Definition: PyStrings.h:43
R__EXTERN PyObject * gROOTns
Definition: PyStrings.h:55
PyObject * DestroyPyStrings()
Remove all cached python strings.
Definition: PyStrings.cxx:114
#define PYROOT__div__
Definition: PyROOT.h:91
Bool_t CreatePyStrings()
Definition: PyStrings.cxx:60
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:35
R__EXTERN PyObject * gLen
Definition: PyStrings.h:29
R__EXTERN PyObject * gNe
Definition: PyStrings.h:34
R__EXTERN PyObject * gSub
Definition: PyStrings.h:38
R__EXTERN PyObject * gSecond
Definition: PyStrings.h:46
R__EXTERN PyObject * ggetSize
Definition: PyStrings.h:49
R__EXTERN PyObject * gSetBranchAddress
Definition: PyStrings.h:56
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:39