- add ePython::call return support (only int)
authorFelix Domke <tmbinc@elitedvb.net>
Fri, 2 Sep 2005 01:30:26 +0000 (01:30 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Fri, 2 Sep 2005 01:30:26 +0000 (01:30 +0000)
lib/python/python.cpp
lib/python/python.h

index 14e32af6a743f8e76d571ca27e754c16622a1b6a..a1ef1508a2005ac9dd5a3cb481feaf061a70e586 100644 (file)
@@ -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)
index 94359176ba5623194f83bc30230ab7dcc1c74cf4..e9a2b8db558a643cf46b8bc629ae7de73d07d902 100644 (file)
@@ -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:
 };