Nektar++
Static Public Member Functions | List of all members
VarCoeffEntryToPython Struct Reference

Static Public Member Functions

static PyObject * convert (VarCoeffEntry const &entry)
 

Detailed Description

Definition at line 59 of file VarCoeffEntry.cpp.

Member Function Documentation

◆ convert()

static PyObject * VarCoeffEntryToPython::convert ( VarCoeffEntry const &  entry)
inlinestatic

Definition at line 61 of file VarCoeffEntry.cpp.

62 {
63 // Create a Python capsule to hold a pointer that contains a lightweight
64 // copy of arr. That way we guarantee Python will still have access to
65 // the memory allocated inside arr even if arr is deallocated in C++.
66#if PY_MAJOR_VERSION == 2
67 py::object capsule(py::handle<>(PyCObject_FromVoidPtr(
68 new VarCoeffEntry(entry), CapsuleDestructor)));
69#else
70 py::object capsule(py::handle<>(
71 PyCapsule_New(new VarCoeffEntry(entry), nullptr,
72 (PyCapsule_Destructor)&CapsuleDestructor)));
73#endif
74 PyObject *tmp =
75 py::incref(np::from_data(entry.GetValue().data(),
76 np::dtype::get_builtin<NekDouble>(),
77 py::make_tuple(entry.GetValue().size()),
78 py::make_tuple(sizeof(NekDouble)), capsule)
79 .ptr());
80
81 return tmp;
82 }
void CapsuleDestructor(PyObject *ptr)
double NekDouble
Representation of a variable coefficient.
Definition: StdRegions.hpp:265

References CapsuleDestructor(), and Nektar::StdRegions::VarCoeffEntry::GetValue().