Mantid
Loading...
Searching...
No Matches
WrapperHelpers.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7//-----------------------------------------------------------------------------
8// Includes
9//-----------------------------------------------------------------------------
11
12using namespace boost::python;
13
15
32bool typeHasAttribute(PyObject *obj, const char *attr) {
33 PyObject *cls_dict = obj->ob_type->tp_dict;
34 object key(handle<>(to_python_value<char const *&>()(attr)));
35 return PyDict_Contains(cls_dict, key.ptr()) > 0;
36}
37
43bool typeHasAttribute(const boost::python::detail::wrapper_base &wrapper, const char *attr) {
44 using namespace boost::python::detail;
45 return typeHasAttribute(wrapper_base_::get_owner(wrapper), attr);
46}
47
48} // namespace Mantid::PythonInterface
double obj
the value of the quadratic function
bool MANTID_PYTHONINTERFACE_CORE_DLL typeHasAttribute(PyObject *obj, const char *attr)
This namespace contains helper functions for classes that are overridden in Python.