From d9a31945a92a76e590657dc2e65bb20b6ea95d90 Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Thu, 11 Feb 2016 10:37:24 +0100 Subject: Merge script and transform view. Add get register and properties info to python wrap. --- pcilib/py.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'pcilib/py.h') diff --git a/pcilib/py.h b/pcilib/py.h index 21c31e9..8fd749c 100644 --- a/pcilib/py.h +++ b/pcilib/py.h @@ -1,7 +1,10 @@ #ifndef _PCILIB_PY_H #define _PCILIB_PY_H +#include "pcilib.h" + typedef struct pcilib_py_s pcilib_py_t; +typedef struct pcilib_script_s pcilib_script_t; #ifdef __cplusplus extern "C" { @@ -11,6 +14,12 @@ int pcilib_init_py(pcilib_t *ctx); int pcilib_py_eval_string(pcilib_t *ctx, const char *codestr, pcilib_value_t *value); void pcilib_free_py(pcilib_t *ctx); + +int pcilib_init_py_script(pcilib_t *ctx, char* module_name, pcilib_script_t **module, pcilib_access_mode_t *mode); +int pcilib_free_py_script(pcilib_script_t *module); +int pcilib_script_read(pcilib_t *ctx, pcilib_script_t *module, pcilib_value_t *val); +int pcilib_script_write(pcilib_t *ctx, pcilib_script_t *module, pcilib_value_t *val); + #ifdef __cplusplus } #endif -- cgit v1.2.3 From f526c4a5a3e4f35bb1c4b03af1f3244a8c0db48a Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Thu, 11 Feb 2016 12:00:54 +0100 Subject: Change error logging method in Python wrap. Move functions, that converts values between PyObject and pcilib_value_t to py.c --- pcilib/py.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'pcilib/py.h') diff --git a/pcilib/py.h b/pcilib/py.h index 8fd749c..d0f1328 100644 --- a/pcilib/py.h +++ b/pcilib/py.h @@ -20,6 +20,26 @@ int pcilib_free_py_script(pcilib_script_t *module); int pcilib_script_read(pcilib_t *ctx, pcilib_script_t *module, pcilib_value_t *val); int pcilib_script_write(pcilib_t *ctx, pcilib_script_t *module, pcilib_value_t *val); + +/*! + * \brief Converts pcilib_value_t to PyObject. + * \param ctx pointer to pcilib_t context + * \param val pointer to pcilib_value_t to convert + * \return PyObject, containing value. NULL with error message, sended to errstream. + */ +void* pcilib_convert_val_to_pyobject(pcilib_t* ctx, pcilib_value_t *val); + + +/*! + * \brief Converts PyObject to pcilib_value_t. + * \param ctx pcilib context + * \param pyVal python object, containing value + * \param val initialized polymorphic value + * \return 0 on success or memory error + */ +int pcilib_convert_pyobject_to_val(pcilib_t* ctx, void* pyVal, pcilib_value_t *val); + + #ifdef __cplusplus } #endif -- cgit v1.2.3 From 55eab7196d0104c71e40136b3b22e9501d234e17 Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Fri, 12 Feb 2016 14:43:20 +0100 Subject: 1. Cmakelists - move copy xml folder command to root file 2. - Move set python paths code to python module init funtction - pci.c move python module init block code after checking model to get paths before it runs. - Fix set python path code to work with PYTHONPATH - Update pci run script to work with PYTHONPATH - Fix python finalize code 3. Change pcilib_script_s interacting method. Now it stores in hash. 4. Change names of some fucntions to more unified ones 5. Remove old unused function pcilib_xml_create_script_or_transform_view 6. cli - disable reading register after set if write_verification flag is off 7. Remove uninformative error messages fro Python wrap. 8. - Server.py - add read/write property/register command handling - Add help message - Correcting paths --- pcilib/py.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'pcilib/py.h') diff --git a/pcilib/py.h b/pcilib/py.h index d0f1328..09e2b87 100644 --- a/pcilib/py.h +++ b/pcilib/py.h @@ -4,7 +4,6 @@ #include "pcilib.h" typedef struct pcilib_py_s pcilib_py_t; -typedef struct pcilib_script_s pcilib_script_t; #ifdef __cplusplus extern "C" { @@ -15,10 +14,10 @@ int pcilib_py_eval_string(pcilib_t *ctx, const char *codestr, pcilib_value_t *va void pcilib_free_py(pcilib_t *ctx); -int pcilib_init_py_script(pcilib_t *ctx, char* module_name, pcilib_script_t **module, pcilib_access_mode_t *mode); -int pcilib_free_py_script(pcilib_script_t *module); -int pcilib_script_read(pcilib_t *ctx, pcilib_script_t *module, pcilib_value_t *val); -int pcilib_script_write(pcilib_t *ctx, pcilib_script_t *module, pcilib_value_t *val); +int pcilib_py_init_script(pcilib_t *ctx, char* module_name, pcilib_access_mode_t *mode); +int pcilib_py_free_script(char* module_name); +int pcilib_script_read(pcilib_t *ctx, char* module_name, pcilib_value_t *val); +int pcilib_script_write(pcilib_t *ctx, char* module_name, pcilib_value_t *val); /*! @@ -27,7 +26,7 @@ int pcilib_script_write(pcilib_t *ctx, pcilib_script_t *module, pcilib_value_t * * \param val pointer to pcilib_value_t to convert * \return PyObject, containing value. NULL with error message, sended to errstream. */ -void* pcilib_convert_val_to_pyobject(pcilib_t* ctx, pcilib_value_t *val); +void* pcilib_get_value_as_pyobject(pcilib_t* ctx, pcilib_value_t *val); /*! @@ -37,7 +36,7 @@ void* pcilib_convert_val_to_pyobject(pcilib_t* ctx, pcilib_value_t *val); * \param val initialized polymorphic value * \return 0 on success or memory error */ -int pcilib_convert_pyobject_to_val(pcilib_t* ctx, void* pyVal, pcilib_value_t *val); +int pcilib_set_value_from_pyobject(pcilib_t* ctx, void* pyVal, pcilib_value_t *val); #ifdef __cplusplus -- cgit v1.2.3 From ed9d8f285f4d81e1ce8bb5e7a5b9e471a73c1590 Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Tue, 16 Feb 2016 16:30:40 +0100 Subject: 1. Add python thread initialization to pcilib_init_py() -Fix pcilib_script_run_func() work in multithread mode 2. pcilib_close() - Move free_py() code after free views to make view destructors work properly 3. Move script hash to pcilib_py_s 4. Move pcilib_get_logger() pcilib_get_logger_min_prio() and pcilib_get_logger_argument() declarations to error.h 5. Refactor pcilib_get_value_as_pyobject pcilib_set_value_from_pyobject to more unified form 6. Add more memory checks. Fix some string memory allocations. 7. Refactor pcilib_py_s member names. 8. Merge pcilib_script_read() and pcilib_script_write() to pcilib_script_run_func() 9. Update test_pywrap views scripts --- pcilib/py.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'pcilib/py.h') diff --git a/pcilib/py.h b/pcilib/py.h index 09e2b87..9703706 100644 --- a/pcilib/py.h +++ b/pcilib/py.h @@ -4,6 +4,7 @@ #include "pcilib.h" typedef struct pcilib_py_s pcilib_py_t; +typedef void pcilib_py_object; #ifdef __cplusplus extern "C" { @@ -15,10 +16,9 @@ void pcilib_free_py(pcilib_t *ctx); int pcilib_py_init_script(pcilib_t *ctx, char* module_name, pcilib_access_mode_t *mode); -int pcilib_py_free_script(char* module_name); -int pcilib_script_read(pcilib_t *ctx, char* module_name, pcilib_value_t *val); -int pcilib_script_write(pcilib_t *ctx, char* module_name, pcilib_value_t *val); - +int pcilib_py_free_script(pcilib_t *ctx,char* module_name); +int pcilib_script_run_func(pcilib_t *ctx, char* module_name, + const char* func_name, pcilib_value_t *val); /*! * \brief Converts pcilib_value_t to PyObject. @@ -26,7 +26,7 @@ int pcilib_script_write(pcilib_t *ctx, char* module_name, pcilib_value_t *val); * \param val pointer to pcilib_value_t to convert * \return PyObject, containing value. NULL with error message, sended to errstream. */ -void* pcilib_get_value_as_pyobject(pcilib_t* ctx, pcilib_value_t *val); +pcilib_py_object* pcilib_get_value_as_pyobject(pcilib_t* ctx, pcilib_value_t *val, int *err); /*! @@ -36,7 +36,7 @@ void* pcilib_get_value_as_pyobject(pcilib_t* ctx, pcilib_value_t *val); * \param val initialized polymorphic value * \return 0 on success or memory error */ -int pcilib_set_value_from_pyobject(pcilib_t* ctx, void* pyVal, pcilib_value_t *val); +int pcilib_set_value_from_pyobject(pcilib_t* ctx, pcilib_value_t *val, pcilib_py_object* pyObjVal); #ifdef __cplusplus -- cgit v1.2.3 From 3269dce32883e14b45cc490a0cc0037b4c808a68 Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Wed, 17 Feb 2016 11:01:22 +0100 Subject: 1. Add cmake BUILD_PYTHON_MODULES option. 2. Rename log options getting functions. 3. py: - pcilib_init_py() - extract pcilib_py_add_script_dir() - pcilib_py_init_script() - extract view-specialized code to pcilib_py_get_transform_script_properties() 3. pcilib_open(): - move pcilib_init_py() to previous position. - add extract pcilib_py_add_script_dir() 4. pcilib_script_s - change hash key. Now it is (const char*) and contains script file name with extension 5. pcipywrap: - Add pcipywrap.h to remove swig generated file complile warnings - remove -includeall swig flag to prevent crash in multi-thread scripts - change set python expetion mechanic --- pcilib/py.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'pcilib/py.h') diff --git a/pcilib/py.h b/pcilib/py.h index 9703706..04b4e8b 100644 --- a/pcilib/py.h +++ b/pcilib/py.h @@ -11,14 +11,19 @@ extern "C" { #endif int pcilib_init_py(pcilib_t *ctx); +int pcilib_py_add_script_dir(pcilib_t *ctx); int pcilib_py_eval_string(pcilib_t *ctx, const char *codestr, pcilib_value_t *value); void pcilib_free_py(pcilib_t *ctx); -int pcilib_py_init_script(pcilib_t *ctx, char* module_name, pcilib_access_mode_t *mode); -int pcilib_py_free_script(pcilib_t *ctx,char* module_name); -int pcilib_script_run_func(pcilib_t *ctx, char* module_name, +int pcilib_py_init_script(pcilib_t *ctx, const char* module_name); +int pcilib_py_free_script(pcilib_t *ctx, const char* module_name); +int pcilib_script_run_func(pcilib_t *ctx, const char* module_name, const char* func_name, pcilib_value_t *val); + +int pcilib_py_get_transform_script_properties(pcilib_t *ctx, + const char* module_name, + pcilib_access_mode_t *mode); /*! * \brief Converts pcilib_value_t to PyObject. -- cgit v1.2.3