Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPyReturn.h
Go to the documentation of this file.
1// Author: Enric Tejedor CERN 08/2019
2// Original PyROOT code by Wim Lavrijsen, LBL
3//
4// /*************************************************************************
5// * Copyright (C) 1995-2019, 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#ifndef ROOT_TPyReturn
13#define ROOT_TPyReturn
14
15// ROOT
16#include "Rtypes.h"
17
18// Python
19struct _object;
20typedef _object PyObject;
21
22/// Morphing return type from evaluating python expressions.
23class TPyReturn {
24public:
25 TPyReturn();
27 TPyReturn(const TPyReturn &);
29 virtual ~TPyReturn();
30
31 // conversions to standard types, may fail if unconvertible
32 operator char *() const;
33 operator const char *() const;
34 operator Char_t() const;
35
36 operator Long_t() const;
37 operator Int_t() const { return (Int_t) operator Long_t(); }
38 operator Short_t() const { return (Short_t) operator Long_t(); }
39
40 operator ULong_t() const;
41 operator UInt_t() const { return (UInt_t) operator ULong_t(); }
42 operator UShort_t() const { return (UShort_t) operator ULong_t(); }
43
44 operator Double_t() const;
45 operator Float_t() const { return (Float_t) operator Double_t(); }
46
47 // used for both TObject and PyObject conversions
48 operator void *() const;
49
50 template <class T>
51 operator T *() const
52 {
53 return (T *)(void *)*this;
54 }
55
56 // used strictly for PyObject conversions
57 operator PyObject *() const;
58
59 ClassDef(TPyReturn, 1) // Python morphing return object
60
62 PyObject *fPyObject; //! actual python object
63};
64
65#endif
_object PyObject
unsigned short UShort_t
Definition RtypesCore.h:40
int Int_t
Definition RtypesCore.h:45
char Char_t
Definition RtypesCore.h:37
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
short Short_t
Definition RtypesCore.h:39
double Double_t
Definition RtypesCore.h:59
#define ClassDef(name, id)
Definition Rtypes.h:342
_object PyObject
Definition TPyReturn.h:20
Morphing return type from evaluating python expressions.
Definition TPyReturn.h:23
TPyReturn & operator=(const TPyReturn &)
Assignment operator. Applies python object reference counting.
Definition TPyReturn.cxx:93
virtual ~TPyReturn()
Destructor. Reference counting for the held python object is in effect.
PyObject * fPyObject
Definition TPyReturn.h:62