comparison oct-py-eval.cc @ 359:4c2b748eaea0

Use py_find_function where specifically searching for a function by name * oct-py-eval.cc (pytave::py_call_function): Use py_find_function to look up Python function by name. * pycall.cc (Fpycall): Likewise, when argument is a string.
author Mike Miller <mtmiller@octave.org>
date Wed, 24 Aug 2016 13:01:15 -0700
parents 040aff46e4db
children 445df7f96fbc
comparison
equal deleted inserted replaced
358:d41fc23d4b9f 359:4c2b748eaea0
37 { 37 {
38 38
39 PyObject * 39 PyObject *
40 py_call_function (const std::string& func, const octave_value_list& args) 40 py_call_function (const std::string& func, const octave_value_list& args)
41 { 41 {
42 // FIXME: factor out parsing of string into a function reference 42 PyObject *func_obj = py_find_function (func);
43 boost::python::object obj; 43 PyObject *retval = py_call_function (func_obj, args);
44 get_object_from_python (func, obj); 44 Py_DECREF (func_obj);
45 return py_call_function (obj.ptr (), args); 45 return retval;
46 } 46 }
47 47
48 PyObject * 48 PyObject *
49 py_call_function (const std::string& func, PyObject *args, PyObject *kwargs) 49 py_call_function (const std::string& func, PyObject *args, PyObject *kwargs)
50 { 50 {
51 // FIXME: factor out parsing of string into a function reference 51 PyObject *func_obj = py_find_function (func);
52 boost::python::object obj; 52 PyObject *retval = py_call_function (func_obj, args, kwargs);
53 get_object_from_python (func, obj); 53 Py_DECREF (func_obj);
54 return py_call_function (obj.ptr (), args, kwargs); 54 return retval;
55 } 55 }
56 56
57 PyObject * 57 PyObject *
58 py_call_function (PyObject *callable, const octave_value_list& args) 58 py_call_function (PyObject *callable, const octave_value_list& args)
59 { 59 {