20 TLP_PYTHON_SCOPE
void decrefPyObject(PyObject *obj);
23 bool PythonInterpreter::evalSingleStatementAndGetValue(
const QString &pythonStatement, T &value) {
26 PyObject *ret = evalPythonStatement(pythonStatement);
31 PyObjectToCppObjectConvertor<T> convertor;
32 ok = convertor.convert(ret, value);
41 template<
typename PARAM_TYPE>
42 bool PythonInterpreter::callFunctionOneParam(
const QString &module,
const QString &
function,
const PARAM_TYPE ¶meter) {
44 parameters.
set(
"param1", parameter);
45 return callFunction(module,
function, parameters);
48 template<
typename PARAM1_TYPE,
typename PARAM2_TYPE>
49 bool PythonInterpreter::callFunctionTwoParams(
const QString &module,
const QString &
function,
const PARAM1_TYPE ¶meter1,
const PARAM2_TYPE ¶meter2) {
51 parameters.
set(
"param1", parameter1);
52 parameters.
set(
"param2", parameter2);
53 return callFunction(module,
function, parameters);
56 template<
typename PARAM1_TYPE,
typename PARAM2_TYPE,
typename PARAM3_TYPE>
57 bool PythonInterpreter::callFunctionThreeParams(
const QString &module,
const QString &
function,
const PARAM1_TYPE ¶meter1,
const PARAM2_TYPE ¶meter2,
58 const PARAM3_TYPE ¶meter3) {
60 parameters.
set(
"param1", parameter1);
61 parameters.
set(
"param2", parameter2);
62 parameters.
set(
"param3", parameter3);
63 return callFunction(module,
function, parameters);
66 template<
typename PARAM1_TYPE,
typename PARAM2_TYPE,
typename PARAM3_TYPE,
typename PARAM4_TYPE>
67 bool PythonInterpreter::callFunctionFourParams(
const QString &module,
const QString &
function,
const PARAM1_TYPE ¶meter1,
const PARAM2_TYPE ¶meter2,
68 const PARAM3_TYPE ¶meter3,
const PARAM4_TYPE ¶meter4) {
70 parameters.
set(
"param1", parameter1);
71 parameters.
set(
"param2", parameter2);
72 parameters.
set(
"param3", parameter3);
73 parameters.
set(
"param4", parameter4);
74 return callFunction(module,
function, parameters);
77 template<
typename PARAM_TYPE,
typename RETURN_TYPE>
78 bool PythonInterpreter::callFunctionOneParamAndGetReturnValue(
const QString &module,
const QString &
function,
const PARAM_TYPE ¶meter, RETURN_TYPE &returnValue) {
80 parameters.
set(
"param1", parameter);
81 return callFunctionAndGetReturnValue(module,
function, parameters, returnValue);
84 template<
typename PARAM1_TYPE,
typename PARAM2_TYPE,
typename RETURN_TYPE>
85 bool PythonInterpreter::callFunctionTwoParamsAndGetReturnValue(
const QString &module,
const QString &
function,
const PARAM1_TYPE ¶meter1,
86 const PARAM2_TYPE ¶meter2, RETURN_TYPE &returnValue) {
89 parameters.
set(
"param1", parameter1);
90 parameters.
set(
"param2", parameter2);
91 return callFunctionAndGetReturnValue(module,
function, parameters, returnValue);
94 template<
typename PARAM1_TYPE,
typename PARAM2_TYPE,
typename PARAM3_TYPE,
typename RETURN_TYPE>
95 bool PythonInterpreter::callFunctionThreeParamsAndGetReturnValue(
const QString &module,
const QString &
function,
const PARAM1_TYPE ¶meter1,
96 const PARAM2_TYPE ¶meter2,
const PARAM3_TYPE ¶meter3, RETURN_TYPE &returnValue) {
99 parameters.
set(
"param1", parameter1);
100 parameters.
set(
"param2", parameter2);
101 parameters.
set(
"param3", parameter3);
102 return callFunctionAndGetReturnValue(module,
function, parameters, returnValue);
105 template<
typename PARAM1_TYPE,
typename PARAM2_TYPE,
typename PARAM3_TYPE,
typename PARAM4_TYPE,
typename RETURN_TYPE>
106 bool PythonInterpreter::callFunctionFourParamsAndGetReturnValue(
const QString &module,
const QString &
function,
const PARAM1_TYPE ¶meter1,
107 const PARAM2_TYPE ¶meter2,
const PARAM3_TYPE ¶meter3,
const PARAM4_TYPE ¶meter4,
108 RETURN_TYPE &returnValue) {
111 parameters.
set(
"param1", parameter1);
112 parameters.
set(
"param2", parameter2);
113 parameters.
set(
"param3", parameter3);
114 parameters.
set(
"param4", parameter4);
115 return callFunctionAndGetReturnValue(module,
function, parameters, returnValue);
118 template<
typename RETURN_TYPE>
119 bool PythonInterpreter::callFunctionAndGetReturnValue(
const QString &module,
const QString &
function,
const tlp::DataSet ¶meters, RETURN_TYPE &returnValue) {
122 PyObject *ret = callPythonFunction(module,
function, parameters);
123 PyObjectToCppObjectConvertor<RETURN_TYPE> retConvertor;
125 if (ret && retConvertor.convert(ret, returnValue)) {