void td_py_invoke0(td_val_t *out, char *fname) { PyObject *pFunc, *pArgs, *pValue; pFunc = td_py_get_callable(fname); if (pFunc == NULL) return; pArgs = PyTuple_New(0); pValue = PyObject_CallObject(pFunc, pArgs); if (pValue == NULL) { fprintf(stderr, "Error in Python call %s\n", fname); return; } to_td_val(out, pValue); }
void td_py_call(td_val_t *out, PyObject *pArgs, char *fname) { PyObject *pFunc, *pValue; pFunc = td_py_get_callable(fname); if (pFunc == NULL) return; pValue = PyObject_CallObject(pFunc, pArgs); if (pValue == NULL) { fprintf(stderr, "Error in Python call %s\n", fname); return; } to_td_val(out, pValue); Py_DECREF(pFunc); Py_DECREF(pValue); }
void td_py_invoke1(td_val_t *out, char *fname, td_val_t *arg) { PyObject *pFunc, *pArgs, *pValue; pFunc = td_py_get_callable(fname); if (pFunc == NULL) return; pArgs = PyTuple_New(1); pValue = from_td_val(arg); if (pValue == NULL) return; PyTuple_SetItem(pArgs, 0, pValue); Py_DECREF(pValue); pValue = PyObject_CallObject(pFunc, pArgs); Py_DECREF(pFunc); Py_DECREF(pArgs); if (pValue == NULL) { fprintf(stderr, "Error in Python call %s\n", fname); return; } to_td_val(out, pValue); Py_DECREF(pValue); }
void td_py_invoke_graph1(graph_t *out_graph, char *fname, graph_t *in_graph) { PyObject *pFunc, *pArgs, *pValue; pFunc = td_py_get_callable(fname); if (pFunc == NULL) { printf("Error getting pyhton function: %s\n", fname); return; } pArgs = PyTuple_New(2); pValue = PyLong_FromSize_t((size_t) out_graph); if (pValue == NULL) { printf("Error getting python args: in_graph\n"); return; } PyTuple_SetItem(pArgs, 0, pValue); pValue = PyLong_FromSize_t((size_t) in_graph); if (pValue == NULL) { printf("Error getting python args: in_graph\n"); return; } PyTuple_SetItem(pArgs, 1, pValue); pValue = PyObject_CallObject(pFunc, pArgs); Py_DECREF(pFunc); Py_DECREF(pArgs); if (pValue == NULL) { fprintf(stderr, "Error in Python call %s\n", fname); return; } Py_DECREF(pValue); }