Nektar++
Public Member Functions | Static Private Member Functions | List of all members
boost::python::converter::shared_ptr_from_python_new< T, SP > Struct Template Reference

#include <ShPtrFixes.hpp>

Public Member Functions

 shared_ptr_from_python_new ()
 

Static Private Member Functions

static void * convertible (PyObject *p)
 
static void construct (PyObject *source, rvalue_from_python_stage1_data *data)
 

Detailed Description

template<class T, template< typename > class SP>
struct boost::python::converter::shared_ptr_from_python_new< T, SP >

Definition at line 133 of file ShPtrFixes.hpp.

Constructor & Destructor Documentation

◆ shared_ptr_from_python_new()

template<class T , template< typename > class SP>
boost::python::converter::shared_ptr_from_python_new< T, SP >::shared_ptr_from_python_new ( )
inline

Definition at line 135 of file ShPtrFixes.hpp.

136  {
137  converter::registry::insert(&convertible, &construct, type_id<SP<T> >()
138 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
139  , &converter::expected_from_python_type_direct<T>::get_pytype
140 #endif
141  );
142  }
static void construct(PyObject *source, rvalue_from_python_stage1_data *data)
Definition: ShPtrFixes.hpp:153

References boost::python::converter::shared_ptr_from_python_new< T, SP >::construct(), and boost::python::converter::shared_ptr_from_python_new< T, SP >::convertible().

Member Function Documentation

◆ construct()

template<class T , template< typename > class SP>
static void boost::python::converter::shared_ptr_from_python_new< T, SP >::construct ( PyObject *  source,
rvalue_from_python_stage1_data *  data 
)
inlinestaticprivate

Definition at line 153 of file ShPtrFixes.hpp.

154  {
155  void* const storage = ((converter::rvalue_from_python_storage<SP<T> >*)data)->storage.bytes;
156  // Deal with the "None" case.
157  if (data->convertible == source)
158  new (storage) SP<T>();
159  else
160  {
161  SP<void> hold_convertible_ref_count(
162  (void*)0, shared_ptr_deleter(handle<>(borrowed(source))) );
163  // use aliasing constructor
164  new (storage) SP<T>(hold_convertible_ref_count,
165  static_cast<T*>(data->convertible));
166  }
167 
168  data->convertible = storage;
169  }

Referenced by boost::python::converter::shared_ptr_from_python_new< T, SP >::shared_ptr_from_python_new().

◆ convertible()

template<class T , template< typename > class SP>
static void* boost::python::converter::shared_ptr_from_python_new< T, SP >::convertible ( PyObject *  p)
inlinestaticprivate

Definition at line 145 of file ShPtrFixes.hpp.

146  {
147  if (p == Py_None)
148  return p;
149 
150  return converter::get_lvalue_from_python(p, registered<T>::converters);
151  }

References CellMLToNektar.cellml_metadata::p.

Referenced by boost::python::converter::shared_ptr_from_python_new< T, SP >::shared_ptr_from_python_new().