From cf3e9383de633c9305a950ba5896376b14e43e12 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Fri, 2 Sep 2005 01:30:26 +0000 Subject: [PATCH] - add ePython::call return support (only int) --- lib/python/python.cpp | 6 ++++-- lib/python/python.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/python/python.cpp b/lib/python/python.cpp index 14e32af6..a1ef1508 100644 --- a/lib/python/python.cpp +++ b/lib/python/python.cpp @@ -95,21 +95,23 @@ int ePython::execute(const std::string &pythonfile, const std::string &funcname) return 0; } -void ePython::call(PyObject *pFunc, PyObject *pArgs) +int ePython::call(PyObject *pFunc, PyObject *pArgs) { + int res = -1; PyObject *pValue; if (pFunc && PyCallable_Check(pFunc)) { pValue = PyObject_CallObject(pFunc, pArgs); if (pValue != NULL) { -// printf("Result of call: %ld\n", PyInt_AsLong(pValue)); + res = PyInt_AsLong(pValue); Py_DECREF(pValue); } else { PyErr_Print(); } } + return res; } PyObject *ePython::resolve(const std::string &pythonfile, const std::string &funcname) diff --git a/lib/python/python.h b/lib/python/python.h index 94359176..e9a2b8db 100644 --- a/lib/python/python.h +++ b/lib/python/python.h @@ -24,7 +24,7 @@ public: ePython(); ~ePython(); int execute(const std::string &pythonfile, const std::string &funcname); - static void call(PyObject *pFunc, PyObject *args); + static int call(PyObject *pFunc, PyObject *args); static PyObject *resolve(const std::string &pythonfile, const std::string &funcname); private: }; -- 2.30.2