Logo ROOT  
Reference Guide
PyResult.h
Go to the documentation of this file.
1 #ifndef CPYCPPYY_PYRESULT_H
2 #define CPYCPPYY_PYRESULT_H
3 
4 //////////////////////////////////////////////////////////////////////////////
5 // //
6 // TPyResult //
7 // //
8 // Morphing return type from evaluating python expressions. //
9 // //
10 //////////////////////////////////////////////////////////////////////////////
11 
12 // Python
13 struct _object;
14 typedef _object PyObject;
15 
16 // Bindings
17 #include "CPyCppyy/CommonDefs.h"
18 
19 
20 namespace CPyCppyy {
21 
23 public:
24  PyResult();
25  PyResult(PyObject* pyobject);
26  PyResult(const PyResult&);
27  PyResult& operator=(const PyResult&);
28  virtual ~PyResult();
29 
30 // conversions to standard types, may fail if unconvertible
31  operator char*() const;
32  operator const char*() const;
33  operator char() const;
34 
35  operator long() const;
36  operator int() const { return (int)operator long(); }
37  operator short() const { return (short)operator long(); }
38 
39  operator unsigned long() const;
40  operator unsigned int() const {
41  return (unsigned int)operator unsigned long();
42  }
43  operator unsigned short() const {
44  return (unsigned short)operator unsigned long();
45  }
46 
47  operator double() const;
48  operator float() const { return (float)operator double(); }
49 
50 // used for both general object type and PyObject conversions
51  operator void*() const;
52 
53  template<class T>
54  operator T*() const { return (T*)(void*)*this; }
55 
56 // used strictly for PyObject conversions
57  operator PyObject*() const;
58 
59 private:
60  PyObject* fPyObject; //! actual python object
61 };
62 
63 } // namespace CPyCppyy
64 
65 #endif // !CPYCPPYY_PYRESULT_H
double
Definition: Converters.cxx:921
double T(double x)
Definition: ChebyshevPol.h:34
l unsigned short
Definition: Converters.cxx:862
#define CPYCPPYY_CLASS_EXTERN
Definition: CommonDefs.h:29
PyObject * fPyObject
Definition: PyResult.h:60
_object PyObject
Definition: PyMethodBase.h:41
Binding & operator=(OUT(*fun)(void))
long
Definition: Converters.cxx:858
_object PyObject
Definition: PyResult.h:13