/usr/include/openturns/swig/BaseFuncCollection.i is in libopenturns-dev 1.9-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | // SWIG file BaseFuncCollection.i
%{
#include "openturns/PythonEvaluation.hxx"
#include "openturns/PythonGradient.hxx"
#include "openturns/PythonHessian.hxx"
namespace OT {
template <>
struct traitsPythonType< OT::Function >
{
typedef _PyObject_ Type;
};
template <>
inline
bool
canConvert< _PyObject_, OT::Function >(PyObject * pyObj)
{
void * ptr = 0;
if (SWIG_IsOK(SWIG_ConvertPtr(pyObj, &ptr, SWIGTYPE_p_OT__Function, 0))) {
OT::Function * p_nmf = reinterpret_cast< OT::Function * >(ptr);
return p_nmf != NULL;
} else if (SWIG_IsOK(SWIG_ConvertPtr( pyObj, &ptr, SWIGTYPE_p_OT__FunctionImplementation, 0))) {
OT::FunctionImplementation * p_impl = reinterpret_cast< OT::FunctionImplementation * >(ptr);
return p_impl != NULL;
} else if (SWIG_IsOK(SWIG_ConvertPtr( pyObj, &ptr, SWIG_TypeQuery("OT::Pointer<OT::FunctionImplementation> *"), 0))) {
OT::Pointer<OT::FunctionImplementation> * p_impl = reinterpret_cast< OT::Pointer<OT::FunctionImplementation> * >(ptr);
return p_impl != NULL && !p_impl->isNull();
} else {
return PyCallable_Check(pyObj);
}
return false;
}
template <>
inline
OT::Function
convert< _PyObject_, OT::Function >(PyObject * pyObj)
{
void * ptr = 0;
if (SWIG_IsOK(SWIG_ConvertPtr(pyObj, &ptr, SWIGTYPE_p_OT__Function, 0))) {
OT::Function * p_nmf = reinterpret_cast< OT::Function * >(ptr);
return *p_nmf;
} else if (SWIG_IsOK(SWIG_ConvertPtr( pyObj, &ptr, SWIGTYPE_p_OT__FunctionImplementation, 0))) {
OT::FunctionImplementation * p_impl = reinterpret_cast< OT::FunctionImplementation * >(ptr);
return *p_impl;
} else if (SWIG_IsOK(SWIG_ConvertPtr( pyObj, &ptr, SWIG_TypeQuery("OT::Pointer<OT::FunctionImplementation> *"), 0))) {
OT::Pointer<OT::FunctionImplementation> * p_impl = reinterpret_cast< OT::Pointer<OT::FunctionImplementation> * >(ptr);
return **p_impl;
} else if (!PyCallable_Check(pyObj)) {
throw OT::InvalidArgumentException(HERE) << "Argument is not a callable object (function or class) - can not be convertible to a Function";
}
OT::Function pythonFunction(new OT::FunctionImplementation(new OT::PythonEvaluation(pyObj)));
if (PyObject_HasAttrString( pyObj, const_cast<char *>("_gradient")))
{
pythonFunction.setGradient(new OT::PythonGradient(pyObj));
}
if (PyObject_HasAttrString(pyObj, const_cast<char *>("_hessian")))
{
pythonFunction.setHessian(new OT::PythonHessian(pyObj));
}
return pythonFunction;
}
template <>
struct traitsPythonType< OT::Basis >
{
typedef _PyObject_ Type;
};
template <>
inline
bool
canConvert< _PyObject_, OT::Basis >(PyObject * pyObj)
{
void * ptr = 0;
if (SWIG_IsOK(SWIG_ConvertPtr(pyObj, &ptr, SWIGTYPE_p_OT__Basis, 0))) {
OT::Basis * p_nmf = reinterpret_cast< OT::Basis * >(ptr);
return p_nmf != NULL;
} else if (SWIG_IsOK(SWIG_ConvertPtr( pyObj, &ptr, SWIGTYPE_p_OT__BasisImplementation, 0 ))) {
OT::BasisImplementation * p_impl = reinterpret_cast< OT::BasisImplementation * >(ptr);
return p_impl != NULL;
} else if (SWIG_IsOK(SWIG_ConvertPtr( pyObj, &ptr, SWIG_TypeQuery("OT::Pointer<OT::BasisImplementation> *"), 0))) {
OT::Pointer<OT::BasisImplementation> * p_impl = reinterpret_cast< OT::Pointer<OT::BasisImplementation> * >(ptr);
return p_impl != NULL && !p_impl->isNull();
}
// Case of Collection<NMF>?
return false;
}
template <>
inline
OT::Basis
convert< _PyObject_, OT::Basis >(PyObject * pyObj)
{
void * ptr = 0;
if (SWIG_IsOK(SWIG_ConvertPtr( pyObj, &ptr, SWIGTYPE_p_OT__Basis, 0)))
{
OT::Basis * p_nmf = reinterpret_cast< OT::Basis * >(ptr);
return *p_nmf;
}
else if (SWIG_IsOK(SWIG_ConvertPtr( pyObj, &ptr, SWIGTYPE_p_OT__BasisImplementation, 0)))
{
OT::BasisImplementation * p_impl = reinterpret_cast< OT::BasisImplementation * >(ptr);
return *p_impl;
}
else if (SWIG_IsOK(SWIG_ConvertPtr( pyObj, &ptr, SWIG_TypeQuery("OT::Pointer<OT::BasisImplementation> *"), 0)))
{
OT::Pointer<OT::BasisImplementation> * p_impl = reinterpret_cast< OT::Pointer<OT::BasisImplementation> * >(ptr);
return **p_impl;
}
// Case of Collection<NMF>?
throw OT::NotYetImplementedException(HERE) << "convert< _PyObject_, OT::Basis >";
}
} /* namespace OT */
%}
|