7#ifndef PXR_BASE_TF_PY_OVERRIDE_H
8#define PXR_BASE_TF_PY_OVERRIDE_H
12#include "pxr/base/tf/pyLock.h"
13#include "pxr/base/tf/pyObjWrapper.h"
15#include <boost/python/override.hpp>
17PXR_NAMESPACE_OPEN_SCOPE
51 boost::python::converter::return_from_python<T> converter;
52 return converter(m_obj.release());
59 boost::python::converter::return_from_python<T&> converter;
61 const_cast<boost::python::handle<>&
>(m_obj).release());
65 T as(boost::type<T>* = 0)
68 boost::python::converter::return_from_python<T> converter;
69 return converter(m_obj.release());
73 T unchecked(boost::type<T>* = 0)
76 return boost::python::extract<T>(m_obj)();
80 mutable boost::python::handle<> m_obj;
100 template <
typename Arg>
101 constexpr static char _PyObjArg()
114 template <
typename... Args>
121 static const char pyCallFormat[] =
122 {
'(', _PyObjArg<Args>()...,
')',
'\0' };
127 const_cast<char*
>(pyCallFormat),
128 boost::python::converter::arg_to_python<Args>(args).get()...));
133PXR_NAMESPACE_CLOSE_SCOPE
Convenience class for accessing the Python Global Interpreter Lock.
A reimplementation of boost::python::detail::method_result.
TfPyMethodResult & operator=(TfPyMethodResult const &other)
Implement assign to do python refcounting while holding the GIL.
TfPyMethodResult(TfPyMethodResult const &other)
Implement copy to do python refcounting while holding the GIL.
~TfPyMethodResult()
Implement dtor to do python refcounting while holding the GIL.
Boost Python object wrapper.
TF_API PyObject * ptr() const
Underlying PyObject* access.
A reimplementation of boost::python::override.
TfPyOverride(boost::python::handle<> callable)
Clients must hold the GIL to construct.
TfPyMethodResult operator()(Args const &... args) const
Call the override.