MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / srd_decoder_doc_get

Function srd_decoder_doc_get

libsigrokdecode4DSL/decoder.c:943–978  ·  view source on GitHub ↗

* Return a protocol decoder's docstring. * * @param dec The loaded protocol decoder. * * @return A newly allocated buffer containing the protocol decoder's * documentation. The caller is responsible for free'ing the buffer. * * @since 0.1.0 */

Source from the content-addressed store, hash-verified

941 * @since 0.1.0
942 */
943SRD_API char *srd_decoder_doc_get(const struct srd_decoder *dec)
944{
945 PyObject *py_str;
946 char *doc;
947 PyGILState_STATE gstate;
948
949 if (!srd_check_init())
950 return NULL;
951
952 if (!dec)
953 return NULL;
954
955 gstate = PyGILState_Ensure();
956
957 if (!PyObject_HasAttrString(dec->py_mod, "__doc__"))
958 goto err;
959
960 if (!(py_str = PyObject_GetAttrString(dec->py_mod, "__doc__"))) {
961 srd_exception_catch(NULL, "Failed to get docstring");
962 goto err;
963 }
964
965 doc = NULL;
966 if (py_str != Py_None)
967 py_str_as_str(py_str, &doc);
968 Py_DECREF(py_str);
969
970 PyGILState_Release(gstate);
971
972 return doc;
973
974err:
975 PyGILState_Release(gstate);
976
977 return NULL;
978}
979
980/**
981 * Unload the specified protocol decoder.

Callers

nothing calls this directly

Calls 3

srd_check_initFunction · 0.85
srd_exception_catchFunction · 0.85
py_str_as_strFunction · 0.85

Tested by

no test coverage detected