Skip to content
Snippets Groups Projects
Commit f2600596 authored by Dmitriy A. Gerasimov's avatar Dmitriy A. Gerasimov
Browse files

[*] Bind fixed

parent 25a90c2c
No related branches found
No related tags found
No related merge requests found
project(dap_app_cli_python_module C)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_C_STANDARD 11)
#set(SUBMODULES_NO_BUILD ON)
add_definitions("-fpic")
add_definitions("-DDAP_LOG_MT")
if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON))
if (NOT (TARGET dap_core))
add_subdirectory(libdap)
target_compile_options(
dap_core PRIVATE
"-fpic"
)
endif()
endif()
file(GLOB APP_CLI_PYTHON_SRCS src/*.c)
file(GLOB APP_CLI_PYTHON_HEADERS include/*.h)
set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4)
find_package (PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIR} include/)
add_library(${PROJECT_NAME} STATIC ${APP_CLI_PYTHON_SRCS} ${APP_CLI_PYTHON_HEADERS})
target_link_libraries(${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} dap_core dap_app_cli )
target_include_directories(${PROJECT_NAME} PUBLIC include/ )
#pragma once
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "dap_common.h"
#include "dap_app_cli.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct PyAppCli{
PyObject_HEAD
}PyAppCliObject;
PyObject* dap_app_cli_main_py(PyObject *self, PyObject *args);
static PyMethodDef AppCliMethods[] = {
{"main", dap_app_cli_main_py, METH_VARARGS | METH_STATIC, "Main CLI function"},
{NULL, NULL, 0, NULL}
};
static PyTypeObject DapAppCli_dapAppCliType = {
PyVarObject_HEAD_INIT(NULL, 0)
"CellFrame.AppCli", /* tp_name */
sizeof(PyAppCliObject), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT |
Py_TPFLAGS_BASETYPE, /* tp_flags */
"AppCli object", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
AppCliMethods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew, /* tp_new */
0, /* tp_free */
0, /* tp_is_gc*/
0, /* tp_bases*/
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
0, /* tp_version_tag*/
0, /* tp_finalize*/
};
#ifdef __cplusplus
}
#endif
#include "dap_common.h"
#include "libdap-app-cli-python.h"
#define LOG_TAG "libdap-app-cli-crypto"
/**
* @brief dap_app_cli_main_py
* @param self
* @param args
* @return
*/
PyObject* dap_app_cli_main_py(PyObject *self, PyObject *args)
{
(void) self;
char *l_app_name = NULL;
int l_argc = 0;
char ** l_argv = NULL;
PyObject* l_args_py = NULL;
if (!PyArg_ParseTuple(args, "sI", &l_app_name, &l_args_py))
return NULL;
Py_ssize_t l_args_py_size = PyList_Size(l_args_py);
if ( l_args_py_size ){
l_argc = l_args_py_size;
l_argv = DAP_NEW_Z_SIZE(char*, sizeof(char**)*l_argc );
for ( int i = 0; i< l_argc; i++){
l_argv[i] = PyBytes_AsString(PyList_GetItem(l_args_py, i));
}
}
return PyLong_FromLong((long) dap_app_cli_main(l_app_name,l_argc,l_argv));
}
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