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 "pxr/external/boost/python/override.hpp"
16#include "pxr/external/boost/python/type.hpp"
18PXR_NAMESPACE_OPEN_SCOPE
52 pxr_boost::python::converter::return_from_python<T> converter;
53 return converter(m_obj.release());
60 pxr_boost::python::converter::return_from_python<T&> converter;
62 const_cast<pxr_boost::python::handle<>&
>(m_obj).release());
66 T as(pxr_boost::python::type<T>* = 0)
69 pxr_boost::python::converter::return_from_python<T> converter;
70 return converter(m_obj.release());
74 T unchecked(pxr_boost::python::type<T>* = 0)
77 return pxr_boost::python::extract<T>(m_obj)();
81 mutable pxr_boost::python::handle<> m_obj;
101 template <
typename Arg>
102 constexpr static char _PyObjArg()
115 template <
typename... Args>
122 static const char pyCallFormat[] =
123 {
'(', _PyObjArg<Args>()...,
')',
'\0' };
128 const_cast<char*
>(pyCallFormat),
129 pxr_boost::python::converter::arg_to_python<Args>(args).get()...));
134PXR_NAMESPACE_CLOSE_SCOPE
Convenience class for accessing the Python Global Interpreter Lock.
A reimplementation of pxr_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 pxr_boost::python::override.
TfPyOverride(pxr_boost::python::handle<> callable)
Clients must hold the GIL to construct.
TfPyMethodResult operator()(Args const &... args) const
Call the override.