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 166 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 168 of file ShPtrFixes.hpp.

169 {
170 converter::registry::insert(
171 &convertible, &construct, type_id<SP<T>>()
172#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
173 ,
174 &converter::expected_from_python_type_direct<T>::get_pytype
175#endif
176 );
177 }
static void construct(PyObject *source, rvalue_from_python_stage1_data *data)
Definition: ShPtrFixes.hpp:188

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 188 of file ShPtrFixes.hpp.

190 {
191 void *const storage =
192 ((converter::rvalue_from_python_storage<SP<T>> *)data)
193 ->storage.bytes;
194 // Deal with the "None" case.
195 if (data->convertible == source)
196 new (storage) SP<T>();
197 else
198 {
199 SP<void> hold_convertible_ref_count(
200 (void *)0, shared_ptr_deleter(handle<>(borrowed(source))));
201 // use aliasing constructor
202 new (storage) SP<T>(hold_convertible_ref_count,
203 static_cast<T *>(data->convertible));
204 }
205
206 data->convertible = storage;
207 }

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 180 of file ShPtrFixes.hpp.

181 {
182 if (p == Py_None)
183 return p;
184
185 return converter::get_lvalue_from_python(p, registered<T>::converters);
186 }

References CellMLToNektar.cellml_metadata::p.

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