24 #ifndef PXR_BASE_TF_PY_OPTIONAL_H
25 #define PXR_BASE_TF_PY_OPTIONAL_H
32 #include <hboost/noncopyable.hpp>
33 #include <hboost/optional.hpp>
34 #include <hboost/python/converter/from_python.hpp>
35 #include <hboost/python/extract.hpp>
36 #include <hboost/python/to_python_converter.hpp>
37 #include <hboost/python/to_python_value.hpp>
46 namespace TfPyOptional {
48 template <
typename T,
typename TfromPy>
52 hboost::python::converter::registry::push_back
53 (&TfromPy::convertible, &TfromPy::construct,
54 hboost::python::type_id<T>());
58 template <
typename T,
typename TtoPy,
typename TfromPy>
62 hboost::python::to_python_converter<T, TtoPy>();
70 template <
typename Optional>
80 return hboost::python::detail::none();
84 template <
typename Optional>
89 using namespace hboost::python::converter;
91 if ((source == Py_None) || hboost::python::extract<T>(source).check())
98 hboost::python::converter::rvalue_from_python_stage1_data *
data)
100 using namespace hboost::python::converter;
103 ((rvalue_from_python_storage<T> *)data)->storage.bytes;
105 if (data->convertible == Py_None) {
108 new (
storage) Optional(hboost::python::extract<T>(source));
131 #endif // PXR_BASE_TF_PY_OPTIONAL_H
getFileOption("OpenEXR:storage") storage
GLsizei GLsizei GLchar * source
static PyObject * convert(const Optional &value)
hboost::python::object TfPyObject(T const &t, bool complainOnFailure=true)
register_python_conversion()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
static void construct(PyObject *source, hboost::python::converter::rvalue_from_python_stage1_data *data)
#define PXR_NAMESPACE_CLOSE_SCOPE
static void * convertible(PyObject *source)