From aafeeaea1731a1e0c8322527ccb0e4cdcc5ffb01 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Sun, 25 Mar 2012 15:08:16 +0200 Subject: srd: Some more (optional) consistency renames. --- controller.c | 30 +++++++++++++++--------------- decoder.c | 4 ++-- exception.c | 2 +- sigrokdecode-internal.h | 8 ++++---- type_decoder.c | 6 +++--- util.c | 4 ++-- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/controller.c b/controller.c index 277897c..8a01d32 100644 --- a/controller.c +++ b/controller.c @@ -79,14 +79,14 @@ SRD_API int srd_init(const char *path) Py_Initialize(); /* Installed decoders. */ - if ((ret = add_modulepath(DECODERS_DIR)) != SRD_OK) { + if ((ret = srd_decoder_searchpath_add(DECODERS_DIR)) != SRD_OK) { Py_Finalize(); return ret; } /* Path specified by the user. */ if (path) { - if ((ret = add_modulepath(path)) != SRD_OK) { + if ((ret = srd_decoder_searchpath_add(path)) != SRD_OK) { Py_Finalize(); return ret; } @@ -94,7 +94,7 @@ SRD_API int srd_init(const char *path) /* Environment variable overrides everything, for debugging. */ if ((env_path = getenv("SIGROKDECODE_DIR"))) { - if ((ret = add_modulepath(env_path)) != SRD_OK) { + if ((ret = srd_decoder_searchpath_add(env_path)) != SRD_OK) { Py_Finalize(); return ret; } @@ -144,7 +144,7 @@ SRD_API int srd_exit(void) * * @return SRD_OK upon success, a (negative) error code otherwise. */ -SRD_PRIV int add_modulepath(const char *path) +SRD_PRIV int srd_decoder_searchpath_add(const char *path) { PyObject *py_cur_path, *py_item; GString *new_path; @@ -311,7 +311,7 @@ err_out: Py_XDECREF(py_dec_options); g_free(key); if (PyErr_Occurred()) - catch_exception("Stray exception in srd_inst_set_options()."); + srd_exception_catch("Stray exception in srd_inst_option_set()."); return ret; } @@ -453,8 +453,8 @@ SRD_API struct srd_decoder_inst *srd_inst_new(const char *decoder_id, /* Create a new instance of this decoder class. */ if (!(di->py_inst = PyObject_CallObject(dec->py_dec, NULL))) { if (PyErr_Occurred()) - catch_exception("failed to create %s instance: ", - decoder_id); + srd_exception_catch("failed to create %s instance: ", + decoder_id); g_free(di->dec_probemap); g_free(di); return NULL; @@ -569,15 +569,15 @@ SRD_PRIV int srd_inst_start(struct srd_decoder_inst *di, PyObject *args) if (!(py_name = PyUnicode_FromString("start"))) { srd_err("Unable to build Python object for 'start'."); - catch_exception("Protocol decoder instance %s: ", - di->inst_id); + srd_exception_catch("Protocol decoder instance %s: ", + di->inst_id); return SRD_ERR_PYTHON; } if (!(py_res = PyObject_CallMethodObjArgs(di->py_inst, py_name, args, NULL))) { - catch_exception("Protocol decoder instance %s: ", - di->inst_id); + srd_exception_catch("Protocol decoder instance %s: ", + di->inst_id); return SRD_ERR_PYTHON; } @@ -652,8 +652,8 @@ SRD_PRIV int srd_inst_decode(uint64_t start_samplenum, if (!(py_res = PyObject_CallMethod(di->py_inst, "decode", "KKO", logic->start_samplenum, end_samplenum, logic))) { - catch_exception("Protocol decoder instance %s: ", - di->inst_id); + srd_exception_catch("Protocol decoder instance %s: ", + di->inst_id); return SRD_ERR_PYTHON; /* TODO: More specific error? */ } Py_DecRef(py_res); @@ -822,8 +822,8 @@ SRD_PRIV void *srd_pd_output_callback_find(int output_type) } /* This is the backend function to Python sigrokdecode.add() call. */ -SRD_PRIV int pd_add(struct srd_decoder_inst *di, int output_type, - const char *proto_id) +SRD_PRIV int srd_inst_pd_output_add(struct srd_decoder_inst *di, + int output_type, const char *proto_id) { struct srd_pd_output *pdo; diff --git a/decoder.c b/decoder.c index ad16846..6290add 100644 --- a/decoder.c +++ b/decoder.c @@ -149,7 +149,7 @@ SRD_API int srd_decoder_load(const char *module_name) /* Import the Python module. */ if (!(d->py_mod = PyImport_ImportModule(module_name))) { - catch_exception("Import of '%s' failed.", module_name); + srd_exception_catch("Import of '%s' failed.", module_name); goto err_out; } @@ -298,7 +298,7 @@ SRD_API char *srd_decoder_doc_get(const struct srd_decoder *dec) return NULL; if (!(py_str = PyObject_GetAttrString(dec->py_mod, "__doc__"))) { - catch_exception(""); + srd_exception_catch(""); return NULL; } diff --git a/exception.c b/exception.c index de31c5f..0c248e1 100644 --- a/exception.c +++ b/exception.c @@ -24,7 +24,7 @@ #include #include /* Python header not pulled in by default. */ -SRD_PRIV void catch_exception(const char *format, ...) +SRD_PRIV void srd_exception_catch(const char *format, ...) { PyObject *etype, *evalue, *etb, *py_str; PyTracebackObject *py_tb; diff --git a/sigrokdecode-internal.h b/sigrokdecode-internal.h index 42e9118..5e45591 100644 --- a/sigrokdecode-internal.h +++ b/sigrokdecode-internal.h @@ -26,15 +26,15 @@ /*--- controller.c ----------------------------------------------------------*/ -SRD_PRIV int add_modulepath(const char *path); +SRD_PRIV int srd_decoder_searchpath_add(const char *path); SRD_PRIV int srd_inst_start(struct srd_decoder_inst *di, PyObject *args); SRD_PRIV int srd_inst_decode(uint64_t start_samplenum, const struct srd_decoder_inst *dec, const uint8_t *inbuf, uint64_t inbuflen); SRD_PRIV void srd_inst_free(struct srd_decoder_inst *di); SRD_PRIV void srd_inst_free_all(GSList *stack); -SRD_PRIV int pd_add(struct srd_decoder_inst *di, int output_type, - const char *output_id); +SRD_PRIV int srd_inst_pd_output_add(struct srd_decoder_inst *di, + int output_type, const char *output_id); /*--- decoder.c -------------------------------------------------------------*/ @@ -42,7 +42,7 @@ SRD_PRIV void *srd_pd_output_callback_find(int output_type); /*--- exception.c -----------------------------------------------------------*/ -SRD_PRIV void catch_exception(const char *format, ...); +SRD_PRIV void srd_exception_catch(const char *format, ...); /*--- log.c -----------------------------------------------------------------*/ diff --git a/type_decoder.c b/type_decoder.c index 19fd350..9cf7770 100644 --- a/type_decoder.c +++ b/type_decoder.c @@ -156,8 +156,8 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) if (!(py_res = PyObject_CallMethod( next_di->py_inst, "decode", "KKO", start_sample, end_sample, data))) { - catch_exception("Calling %s decode(): ", - next_di->inst_id); + srd_exception_catch("Calling %s decode(): ", + next_di->inst_id); } Py_XDECREF(py_res); } @@ -193,7 +193,7 @@ static PyObject *Decoder_add(PyObject *self, PyObject *args) return NULL; } - pdo_id = pd_add(di, output_type, proto_id); + pdo_id = srd_inst_pd_output_add(di, output_type, proto_id); if (pdo_id < 0) Py_RETURN_NONE; else diff --git a/util.c b/util.c index a4268ec..6dbeb2f 100644 --- a/util.c +++ b/util.c @@ -46,7 +46,7 @@ SRD_PRIV int py_attr_as_str(const PyObject *py_obj, const char *attr, } if (!(py_str = PyObject_GetAttrString((PyObject *)py_obj, attr))) { - catch_exception(""); + srd_exception_catch(""); return SRD_ERR_PYTHON; } @@ -150,7 +150,7 @@ err_out: Py_XDECREF(py_encstr); if (PyErr_Occurred()) { - catch_exception("string conversion failed"); + srd_exception_catch("string conversion failed"); } return ret; -- cgit v1.2.3-70-g09d2