forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TPyReturn.h
65 lines (48 loc) · 1.85 KB
/
TPyReturn.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// @(#)root/pyroot:$Id$
// Author: Wim Lavrijsen May 2004
#ifndef ROOT_TPyReturn
#define ROOT_TPyReturn
//////////////////////////////////////////////////////////////////////////////
// //
// TPyReturn //
// //
// Morphing return type from evaluating python expressions. //
// //
//////////////////////////////////////////////////////////////////////////////
// ROOT
#ifndef ROOT_Rtypes
#include "Rtypes.h"
#endif
// Python
struct _object;
typedef _object PyObject;
class TPyReturn {
public:
TPyReturn();
TPyReturn( PyObject* pyobject );
TPyReturn( const TPyReturn& );
TPyReturn& operator=( const TPyReturn& );
virtual ~TPyReturn();
// conversions to standard types, may fail if unconvertible
operator char*() const;
operator const char*() const;
operator Char_t() const;
operator Long_t() const;
operator Int_t() const { return (Int_t)operator Long_t(); }
operator Short_t() const { return (Short_t)operator Long_t(); }
operator ULong_t() const;
operator UInt_t() const { return (UInt_t)operator ULong_t(); }
operator UShort_t() const { return (UShort_t)operator ULong_t(); }
operator Double_t() const;
operator Float_t() const { return (Float_t)operator Double_t(); }
// used for both TObject and PyObject conversions
operator void*() const;
template<class T>
operator T*() const { return (T*)(void*)*this; }
// used strictly for PyObject conversions
operator PyObject*() const;
ClassDef(TPyReturn,1) //Python morphing return object
private:
PyObject* fPyObject; //! actual python object
};
#endif