コード例 #1
0
ファイル: td_python.c プロジェクト: aterrel/xlang
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);
}
コード例 #2
0
ファイル: td_python.c プロジェクト: gvidaver/xlang
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);
}
コード例 #3
0
ファイル: td_julia.c プロジェクト: dieface/xlang
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);
}