Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPyArg.cxx
Go to the documentation of this file.
1// Bindings
2#include "CPyCppyy.h"
3#define CPYCPPYY_INTERNAL 1
4#include "CPyCppyy/TPyArg.h"
5#undef CPYCPPYY_INTERNAL
6
7
8//______________________________________________________________________________
9// Generic wrapper for arguments
10// =============================
11//
12// Transport class for bringing C++ values and objects from Cling to Python. It
13// provides, from the selected constructor, the proper conversion to a PyObject.
14// In principle, there should be no need to use this class directly: it relies
15// on implicit conversions.
16
17
18//- constructor dispatcher ---------------------------------------------------
20 PyObject*& pyself, PyObject* pyclass, const std::vector<TPyArg>& args)
21{
22 int nArgs = (int)args.size();
24 for (int i = 0; i < nArgs; ++i)
25 PyTuple_SET_ITEM(pyargs, i, (PyObject*)args[i]);
28}
29
30//----------------------------------------------------------------------------
37
38//- generic dispatcher -------------------------------------------------------
39PyObject* TPyArg::CallMethod(PyObject* pymeth, const std::vector<TPyArg>& args)
40{
41 int nArgs = (int)args.size();
43 for (int i = 0; i < nArgs; ++i)
44 PyTuple_SET_ITEM(pyargs, i, (PyObject*)args[i]);
47 return result;
48}
49
50//- destructor dispatcher ----------------------------------------------------
51void TPyArg::CallDestructor(PyObject*& pyself, PyObject*, const std::vector<TPyArg>&)
52{
53 Py_XDECREF(pyself); // calls actual dtor if ref-count down to 0
54}
55
56//----------------------------------------------------------------------------
58{
60}
61
62//- constructors/destructor --------------------------------------------------
64{
65// Construct a TPyArg from a python object.
68}
69
70//----------------------------------------------------------------------------
72{
73// Construct a TPyArg from an integer value.
75}
76
77//----------------------------------------------------------------------------
79{
80// Construct a TPyArg from an integer value.
82}
83
84//----------------------------------------------------------------------------
86{
87// Construct a TPyArg from a double value.
89}
90
91//----------------------------------------------------------------------------
92TPyArg::TPyArg(const char* value)
93{
94// Construct a TPyArg from a C-string.
96}
97
98//----------------------------------------------------------------------------
99TPyArg::TPyArg(const TPyArg& s)
100{
101// Copy constructor.
104}
105
106//----------------------------------------------------------------------------
108{
109// Assignment operator.
110 if (this != &s) {
113 }
114 return *this;
115}
116
117//----------------------------------------------------------------------------
119{
120// Done with held PyObject.
122 fPyObject = nullptr;
123}
124
125//- public members -----------------------------------------------------------
126TPyArg::operator PyObject*() const
127{
128// Extract the python object.
129 Py_XINCREF(fPyObject);
130 return fPyObject;
131}
#define CPyCppyy_PyText_FromString
Definition CPyCppyy.h:81
_object PyObject
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
static PyObject * CallMethod(PyObject *pymeth, const std::vector< TPyArg > &args)
Definition TPyArg.cxx:49
static void CallDestructor(PyObject *&pyself, PyObject *pymeth, const std::vector< TPyArg > &args)
Definition TPyArg.cxx:61
PyObject * fPyObject
Definition TPyArg.h:59
TPyArg(PyObject *)
Definition TPyArg.cxx:73
TPyArg & operator=(const TPyArg &)
Assignment operator.
Definition TPyArg.cxx:124
virtual ~TPyArg()
Done with held PyObject.
Definition TPyArg.cxx:136
static void CallConstructor(PyObject *&pyself, PyObject *pyclass, const std::vector< TPyArg > &args)
Definition TPyArg.cxx:30
void CallConstructor(PyObject *&pyself, PyObject *pyclass)
Definition TPyArg.cxx:31