From 5c55017c401002c18b1d43dad61200df17ab3321 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Sat, 24 Apr 2010 01:04:20 +0200 Subject: Various Python decoder infrastructure improvements. - Introduce 'struct sigrokdecode_decoder'. - Decoders are now handled via two C functions: - sigrokdecode_load_decoder(): Fills a 'struct sigrokdecode_decoder'. - sigrokdecode_run_decoder(): Runs a decoder function. - There are now two decoder API functions a script needs to implement: - register(): Returns a Python dict with certain metadata. - decode(): Runs the actual decoder code. - libsigrokdecode: Add and use some more #defines for errors: - SIGROKDECODE_ERR_ARGS - SIGROKDECODE_ERR_PYTHON - Various other smaller Python decode script infrastructure issues. --- sigrokdecode.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'sigrokdecode.h') diff --git a/sigrokdecode.h b/sigrokdecode.h index be3ab98..5112e09 100644 --- a/sigrokdecode.h +++ b/sigrokdecode.h @@ -23,6 +23,7 @@ #include /* First, so we avoid a _POSIX_C_SOURCE warning. */ #include +#include /* * Status/error codes returned by libsigrokdecode functions. @@ -44,20 +45,25 @@ #define SIGROKDECODE_OK 0 /* No error */ #define SIGROKDECODE_ERR -1 /* Generic/unspecified error */ #define SIGROKDECODE_ERR_MALLOC -2 /* Malloc/calloc/realloc error */ +#define SIGROKDECODE_ERR_ARGS -3 /* Function argument error */ +#define SIGROKDECODE_ERR_PYTHON -4 /* Python C API error */ /* TODO: Documentation. */ -struct sigrokdecode_decoder_info { +struct sigrokdecode_decoder { char *id; char *name; - char *description; - char *function; - char *inputformats; /* FIXME: Should be a list. */ - char *outputformats; /* FIXME: Should be a list. */ + char *desc; + char *func; + GSList *inputformats; + GSList *outputformats; + + PyObject *py_mod; + PyObject *py_func; }; int sigrokdecode_init(void); -int sigrokdecode_load_decoder_file(const char *name); -int sigrokdecode_run_decoder(const char *modulename, const char *decodername, +int sigrokdecode_load_decoder(const char *name, struct sigrokdecode_decoder **dec); +int sigrokdecode_run_decoder(struct sigrokdecode_decoder *dec, uint8_t *inbuf, uint64_t inbuflen, uint8_t **outbuf, uint64_t *outbuflen); int sigrokdecode_shutdown(void); -- cgit v1.2.3-70-g09d2