]> sigrok.org Git - libsigrokdecode.git/commitdiff
srd: Some more (optional) consistency renames.
authorUwe Hermann <redacted>
Sun, 25 Mar 2012 13:08:16 +0000 (15:08 +0200)
committerUwe Hermann <redacted>
Tue, 27 Mar 2012 23:19:27 +0000 (01:19 +0200)
controller.c
decoder.c
exception.c
sigrokdecode-internal.h
type_decoder.c
util.c

index 277897c546abecc7199c96972dffb1c54d30f214..8a01d32e6d570968fff5177c012a3ab481830c0f 100644 (file)
@@ -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;
 
index ad16846775b02c163f937af290a7c0a3243bea87..6290add071b64865cb36c9a392d15e7da6440d1f 100644 (file)
--- 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;
        }
 
index de31c5fa37f67fb5856b4303af1cd1c1db494214..0c248e169e4c4b45502a8d781df86b532e47801c 100644 (file)
@@ -24,7 +24,7 @@
 #include <glib.h>
 #include <frameobject.h> /* 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;
index 42e9118e915052a08a11bdc727a9ae03cafc6add..5e455919841f2fef6fde923370642cec43ab824e 100644 (file)
 
 /*--- 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 -----------------------------------------------------------------*/
 
index 19fd3508bd723a3ed965f9c8a8b25ae165a23578..9cf77708dee62982fe6117db67f15afaab1767aa 100644 (file)
@@ -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 a4268ec176315e92181da6b85da07cd387b02d30..6dbeb2f249acce02fe953340c146f847d6a1cf6c 100644 (file)
--- 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;