Skip to content
Snippets Groups Projects
Commit 4a15aca6 authored by dmitriy.gerasimov's avatar dmitriy.gerasimov
Browse files

Merge branch 'features-2564' into 'master'

[+] Added broadcasting dap_list to PyList and back.

See merge request !2
parents 0cddffd9 d0d62057
No related branches found
No related tags found
1 merge request!2[+] Added broadcasting dap_list to PyList and back.
...@@ -120,3 +120,25 @@ PyObject* py_m_dap_config_get_item_default(PyObject *self, PyObject *args){ ...@@ -120,3 +120,25 @@ PyObject* py_m_dap_config_get_item_default(PyObject *self, PyObject *args){
const char *res = dap_config_get_item_str_default(g_config, section_path, item_name, def); const char *res = dap_config_get_item_str_default(g_config, section_path, item_name, def);
return Py_BuildValue("s", res); return Py_BuildValue("s", res);
} }
PyObject *dapListToPyList(dap_list_t *list ){
unsigned int len = dap_list_length(list);
PyObject *obj = PyList_New((Py_ssize_t)len);
for (unsigned int l = 0; l <len; l++){
void *data = dap_list_nth_data(list, l);
PyObject *obj_data = PyBytes_FromString((const char*)data);
PyList_Append(obj, obj_data);
}
return obj;
}
dap_list_t *pyListToDapList(PyObject *list ){
Py_ssize_t len = PyList_Size(list);
dap_list_t *dap_list = dap_list_alloc();
for (Py_ssize_t i = 0; i < len; i++){
PyObject *obj = PyList_GetItem(list, i);
void *data = PyBytes_AsString(obj);
dap_list = dap_list_append(dap_list, data);
}
return dap_list;
}
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <Python.h> #include <Python.h>
#include "dap_config.h" #include "dap_config.h"
#include "dap_common.h" #include "dap_common.h"
#include "dap_list.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -78,6 +79,10 @@ static PyTypeObject DapObject_DapObjectType = { ...@@ -78,6 +79,10 @@ static PyTypeObject DapObject_DapObjectType = {
PyType_GenericNew, /* tp_new */ PyType_GenericNew, /* tp_new */
}; };
PyObject *dapListToPyList(dap_list_t *list);
dap_list_t *pyListToDapList(PyObject *list);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment