Logo ROOT   6.12/07
Reference Guide
Namespaces | Macros | Typedefs | Functions | Variables
Converters.cxx File Reference
#include "PyROOT.h"
#include "PyStrings.h"
#include "Converters.h"
#include "TCallContext.h"
#include "ObjectProxy.h"
#include "TPyBufferFactory.h"
#include "TCustomPyTypes.h"
#include "TTupleOfInstances.h"
#include "Utility.h"
#include "RootWrapper.h"
#include "TClass.h"
#include "TClassEdit.h"
#include <limits.h>
#include <stddef.h>
#include <string.h>
#include <utility>
#include <sstream>
Include dependency graph for Converters.cxx:

Namespaces

 PyROOT
 

Macros

#define PYROOT_ARRAY_CONVERTER_FACTORY(name)
 
#define PYROOT_BASIC_CONVERTER_FACTORY(name)
 
#define PYROOT_IMPLEMENT_ARRAY_CONVERTER(name, type, code)
 
#define PYROOT_IMPLEMENT_BASIC_CHAR_CONVERTER(name, type, low, high)
 
#define PYROOT_IMPLEMENT_BASIC_CONST_CHAR_REF_CONVERTER(name, type, low, high)
 
#define PYROOT_IMPLEMENT_BASIC_CONST_REF_CONVERTER(name, type, F1)
 
#define PYROOT_IMPLEMENT_BASIC_CONVERTER(name, type, stype, F1, F2, tc)
 
#define PYROOT_IMPLEMENT_STRING_AS_PRIMITIVE_CONVERTER(name, type, F1, F2)
 

Typedefs

typedef TConverter *(* PyROOT::ConverterFactory_t) (Long_t size)
 
typedef std::map< std::string, ConverterFactory_t > PyROOT::ConvFactories_t
 

Functions

static Int_t ExtractChar (PyObject *pyobject, const char *tname, Int_t low, Int_t high)
 
 PYROOT_IMPLEMENT_ARRAY_CONVERTER (Bool, Bool_t, 'b') Bool_t PyROOT
 convert <pyobject> to C++ long long*, set arg for call More...
 
static Bool_t PyROOT_PyLong_AsBool (PyObject *pyobject)
 range-checking python integer to C++ bool conversion More...
 
static Short_t PyROOT_PyLong_AsShort (PyObject *pyobject)
 range-checking python integer to C++ short int conversion More...
 
static Long_t PyROOT_PyLong_AsStrictLong (PyObject *pyobject)
 strict python integer to C++ integer conversion More...
 
static UShort_t PyROOT_PyLong_AsUShort (PyObject *pyobject)
 range-checking python integer to C++ unsigend short int conversion More...
 
static Char_t PyROOT_PyUnicode_AsChar (PyObject *pyobject)
 python string to C++ char conversion More...
 

Variables

ConvFactories_t PyROOT::gConvFactories
 
R__EXTERN PyObjectPyROOT::gNullPtrObject = 0
 

Macro Definition Documentation

◆ PYROOT_ARRAY_CONVERTER_FACTORY

#define PYROOT_ARRAY_CONVERTER_FACTORY (   name)
Value:
TConverter* Create##name##Converter( Long_t size ) \
{ \
return new T##name##Converter( size ); \
}
double T(double x)
Definition: ChebyshevPol.h:34
long Long_t
Definition: RtypesCore.h:50
char name[80]
Definition: TGX11.cxx:109

Definition at line 1538 of file Converters.cxx.

◆ PYROOT_BASIC_CONVERTER_FACTORY

#define PYROOT_BASIC_CONVERTER_FACTORY (   name)
Value:
TConverter* Create##name##Converter( Long_t ) \
{ \
return new T##name##Converter(); \
}
double T(double x)
Definition: ChebyshevPol.h:34
long Long_t
Definition: RtypesCore.h:50
char name[80]
Definition: TGX11.cxx:109

Definition at line 1532 of file Converters.cxx.

◆ PYROOT_IMPLEMENT_ARRAY_CONVERTER

#define PYROOT_IMPLEMENT_ARRAY_CONVERTER (   name,
  type,
  code 
)

Definition at line 783 of file Converters.cxx.

◆ PYROOT_IMPLEMENT_BASIC_CHAR_CONVERTER

#define PYROOT_IMPLEMENT_BASIC_CHAR_CONVERTER (   name,
  type,
  low,
  high 
)

Definition at line 235 of file Converters.cxx.

◆ PYROOT_IMPLEMENT_BASIC_CONST_CHAR_REF_CONVERTER

#define PYROOT_IMPLEMENT_BASIC_CONST_CHAR_REF_CONVERTER (   name,
  type,
  low,
  high 
)
Value:
Bool_t PyROOT::TConst##name##RefConverter::SetArg( \
PyObject* pyobject, TParameter& para, TCallContext* /* ctxt */ ) \
{ \
/* convert <pyobject> to C++ <<type>>, set arg for call, allow int -> char */ \
type val = (type)ExtractChar( pyobject, #type, low, high ); \
if ( val == (type)-1 && PyErr_Occurred() ) \
return kFALSE; \
para.fValue.fLong = val; \
para.fTypeCode = 'l'; \
return kTRUE; \
}
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: RtypesCore.h:88
int type
Definition: TGX11.cxx:120
static Int_t ExtractChar(PyObject *pyobject, const char *tname, Int_t low, Int_t high)
Definition: Converters.cxx:181
const Bool_t kTRUE
Definition: RtypesCore.h:87
char name[80]
Definition: TGX11.cxx:109
_object PyObject
Definition: TPyArg.h:20

Definition at line 219 of file Converters.cxx.

◆ PYROOT_IMPLEMENT_BASIC_CONST_REF_CONVERTER

#define PYROOT_IMPLEMENT_BASIC_CONST_REF_CONVERTER (   name,
  type,
  F1 
)
Value:
Bool_t PyROOT::TConst##name##RefConverter::SetArg( \
PyObject* pyobject, TParameter& para, TCallContext* /* ctxt */ ) \
{ \
type val = (type)F1( pyobject ); \
if ( val == (type)-1 && PyErr_Occurred() ) \
return kFALSE; \
para.fValue.f##name = val; \
para.fRef = &para.fValue.f##name; \
para.fTypeCode = 'r'; \
return kTRUE; \
}
bool Bool_t
Definition: RtypesCore.h:59
#define F1(x, y, z)
Definition: TMD5.cxx:267
const Bool_t kFALSE
Definition: RtypesCore.h:88
int type
Definition: TGX11.cxx:120
const Bool_t kTRUE
Definition: RtypesCore.h:87
char name[80]
Definition: TGX11.cxx:109
_object PyObject
Definition: TPyArg.h:20

Definition at line 206 of file Converters.cxx.

◆ PYROOT_IMPLEMENT_BASIC_CONVERTER

#define PYROOT_IMPLEMENT_BASIC_CONVERTER (   name,
  type,
  stype,
  F1,
  F2,
  tc 
)
Value:
Bool_t PyROOT::T##name##Converter::SetArg( \
PyObject* pyobject, TParameter& para, TCallContext* /* ctxt */ ) \
{ \
/* convert <pyobject> to C++ 'type', set arg for call */ \
type val = (type)F2( pyobject ); \
if ( val == (type)-1 && PyErr_Occurred() ) \
return kFALSE; \
para.fValue.f##name = val; \
para.fTypeCode = tc; \
return kTRUE; \
} \
\
PyObject* PyROOT::T##name##Converter::FromMemory( void* address ) \
{ \
return F1( (stype)*((type*)address) ); \
} \
\
Bool_t PyROOT::T##name##Converter::ToMemory( PyObject* value, void* address ) \
{ \
type s = (type)F2( value ); \
if ( s == (type)-1 && PyErr_Occurred() ) \
return kFALSE; \
*((type*)address) = (type)s; \
return kTRUE; \
}
double T(double x)
Definition: ChebyshevPol.h:34
bool Bool_t
Definition: RtypesCore.h:59
#define F1(x, y, z)
Definition: TMD5.cxx:267
#define F2(x, y, z)
Definition: TMD5.cxx:268
const Bool_t kFALSE
Definition: RtypesCore.h:88
int type
Definition: TGX11.cxx:120
static constexpr double s
const Bool_t kTRUE
Definition: RtypesCore.h:87
char name[80]
Definition: TGX11.cxx:109
_object PyObject
Definition: TPyArg.h:20

Definition at line 153 of file Converters.cxx.

◆ PYROOT_IMPLEMENT_STRING_AS_PRIMITIVE_CONVERTER

#define PYROOT_IMPLEMENT_STRING_AS_PRIMITIVE_CONVERTER (   name,
  type,
  F1,
  F2 
)

Definition at line 849 of file Converters.cxx.

Function Documentation

◆ ExtractChar()

static Int_t ExtractChar ( PyObject pyobject,
const char *  tname,
Int_t  low,
Int_t  high 
)
inlinestatic

Definition at line 181 of file Converters.cxx.

◆ PYROOT_IMPLEMENT_ARRAY_CONVERTER()

PYROOT_IMPLEMENT_ARRAY_CONVERTER ( Bool  ,
Bool_t  ,
'b  
)

convert <pyobject> to C++ long long*, set arg for call

Definition at line 822 of file Converters.cxx.

◆ PyROOT_PyLong_AsBool()

static Bool_t PyROOT_PyLong_AsBool ( PyObject pyobject)
inlinestatic

range-checking python integer to C++ bool conversion

Definition at line 65 of file Converters.cxx.

◆ PyROOT_PyLong_AsShort()

static Short_t PyROOT_PyLong_AsShort ( PyObject pyobject)
inlinestatic

range-checking python integer to C++ short int conversion

Definition at line 102 of file Converters.cxx.

◆ PyROOT_PyLong_AsStrictLong()

static Long_t PyROOT_PyLong_AsStrictLong ( PyObject pyobject)
inlinestatic

strict python integer to C++ integer conversion

Definition at line 121 of file Converters.cxx.

◆ PyROOT_PyLong_AsUShort()

static UShort_t PyROOT_PyLong_AsUShort ( PyObject pyobject)
inlinestatic

range-checking python integer to C++ unsigend short int conversion

Definition at line 84 of file Converters.cxx.

◆ PyROOT_PyUnicode_AsChar()

static Char_t PyROOT_PyUnicode_AsChar ( PyObject pyobject)
inlinestatic

python string to C++ char conversion

Definition at line 78 of file Converters.cxx.