void td_py_add_arg(PyObject *pArgs, int pos, td_val_t *arg) { PyObject* pValue; pValue = from_td_val(arg); if (pValue == NULL) { fprintf(stderr, "Error in Python value conversion\n"); return; } /* pValue reference stolen here: */ PyTuple_SetItem(pArgs, pos, 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_jl_invoke1(td_val_t *out, char *fname, td_val_t *arg) { jl_function_t *f = jl_get_function(jl_base_module, fname); jl_value_t *v = jl_call1(f, from_td_val(arg)); to_td_val(out, v); }