7 #ifndef PXR_BASE_TF_PY_OPTIONAL_H
8 #define PXR_BASE_TF_PY_OPTIONAL_H
15 #include "pxr/external/boost/python/converter/from_python.hpp"
16 #include "pxr/external/boost/python/extract.hpp"
17 #include "pxr/external/boost/python/to_python_converter.hpp"
18 #include "pxr/external/boost/python/to_python_value.hpp"
27 namespace TfPyOptional {
29 template <
typename T,
typename TfromPy>
33 pxr_boost::python::converter::registry::push_back
34 (&TfromPy::convertible, &TfromPy::construct,
35 pxr_boost::python::type_id<T>());
39 template <
typename T,
typename TtoPy,
typename TfromPy>
43 pxr_boost::python::to_python_converter<T, TtoPy>();
53 template <
typename Optional>
67 template <
typename Optional>
72 using namespace pxr_boost::python::converter;
74 if ((source == Py_None) || pxr_boost::python::extract<T>(source).check())
81 pxr_boost::python::converter::rvalue_from_python_stage1_data *
data)
83 using namespace pxr_boost::python::converter;
86 ((rvalue_from_python_storage<T> *)data)->storage.bytes;
88 if (data->convertible == Py_None) {
91 new (
storage) Optional(pxr_boost::python::extract<T>(source));
110 #endif // PXR_BASE_TF_PY_OPTIONAL_H
bool none(const vbool4 &v)
pxr_boost::python::object TfPyObject(T const &t, bool complainOnFailure=true)
getFileOption("OpenEXR:storage") storage
GLsizei const GLfloat * value
GLsizei GLsizei GLchar * source
static PyObject * convert(const Optional &value)
register_python_conversion()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
static void construct(PyObject *source, pxr_boost::python::converter::rvalue_from_python_stage1_data *data)
#define PXR_NAMESPACE_CLOSE_SCOPE
python_optional & operator=(const python_optional &)=delete
static void * convertible(PyObject *source)