k3stubproxy
An proxy implementation to be used by embedded c stub implementations
Stub generation
Use the cli tool k3stubproxy-generate-stub included in this package.
Requirements:
- Stub functions begin with extern
- In the code documnetation a parameter is labled in/out in the following style
- param [in] variableName
- param [out] variableName
Example CLI Usage
k3stubproxy-generate-stub -v ../Code/HAL/HAL_*.c --func_prefix HAL_ -o ../Code/HAL/high_level_stub/ --filename_suffix _teststub --file_header defheader.txt --stub_function_definition_out stub_function_definition.json
Other CLI Tools (Version 0.2.1)
- k3stubproxy-generate-target-stub (Generate a python target stub using the stub function definition created by k3stubproxy-generate-stub
- k3stubproxy-analyse-stub-function-definition (Given the stub function definition, show stub functions and used input, output and return types)
Example usage within C
C API usage
#include "Stub_Connector_Interface.h"
...
if initStubConnector(NULL) != 0
{
// error
return 1;
}
Provide Implementations for the following functions:
PyObject* convert_input_to_python_object(va_list valist, int parameterPos, char* typeString);
int convert_python_object_to_output(va_list valist, int parameterPos, char* typeString, PyObject* outputObject);
And include the files Stub_Connector_Implementation.c,Stub_Connector_Interface.h from within k3stubproxy/c_stub and the replace the standard implementation with generated stub when compiling and linking.
General Information About Embedding Python Within C
char* phDir = "/some/path/to/a/venv";
printf("INFO: Using virutalenv: %s", phDir);
// This should not be some hard code palth like /home/annoying_user/temp/project123
// For example in some usages of the k3stubproxy this is set dynamically to look
// beside the exe vor the venv
// Note: Need to check return of Py_DecodeLocale is != NULL
Py_SetPythonHome(Py_DecodeLocale(phDir, NULL));
//optional but recommended
wchar_t *program = Py_DecodeLocale("stub_program", NULL);
Py_SetProgramName(program);
Py_Initialize();
// Then any lib within the venv can be used via cpython
PyRun_SimpleString("import k3stubproxy;");
Release files for k3stubproxy 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| k3stubproxy-0.2.4.tar.gz | 9.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| k3stubproxy-0.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.7 kB
Release files / k3stubproxy-0.2.4.tar.gz
| Download URL | k3stubproxy-0.2.4.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
60c9ab6fd1a173776b75f63e17d06c04a7eb2d89b1c00a1ca3141380616a8e1d
|
|
BLAKE2b-256 checksum How to use checksums |
b54e93be8a84f7028ee0ca13a4c8686ac2a487c0bfcac314276943900c75a5d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3
|
Release files / k3stubproxy-0.2.4-py3-none-any.whl
| Download URL | k3stubproxy-0.2.4-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2881ab925c17a269221751eaaac297ff7f8fa95da027d96f3b44b190b80f730c
|
|
BLAKE2b-256 checksum How to use checksums |
3aa112d56722bf6e7afd2f4d8e1d267d3f8fbadf0e58e12a40995cc1475580e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3
|