blob: db632f2a00fd252602cb50e416aa4f9b03e3107c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include "config.h"
#include "interpreter.h"
#include <Python.h>
struct Config
{
PyObject *object;
};
PyObject *_object(Config *c)
{
return c ? c->object : NULL;
}
Config *createConfig(const char *argv[], int argc)
{
PyObject *pyargs = PyList_New(argc);
for (int i = 0; i < argc; i++)
{
PyObject *arg = PyBytes_FromString(argv[i]);
PyList_Insert(pyargs, i, arg);
}
PyObject *obj = executeFunction("layman.config", "Config", "O", pyargs);
Py_DECREF(pyargs);
if (!obj)
return NULL;
Config *ret = malloc(sizeof(Config));
ret->object = obj;
return ret;
}
|