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

Function check_method

libsigrokdecode4DSL/decoder.c:659–688  ·  view source on GitHub ↗

Check whether the Decoder class defines the named method. */

Source from the content-addressed store, hash-verified

657
658/* Check whether the Decoder class defines the named method. */
659static int check_method(PyObject *py_dec, const char *mod_name,
660 const char *method_name)
661{
662 PyObject *py_method;
663 int is_callable;
664 PyGILState_STATE gstate;
665
666 gstate = PyGILState_Ensure();
667
668 py_method = PyObject_GetAttrString(py_dec, method_name);
669 if (!py_method) {
670 srd_exception_catch(NULL, "Protocol decoder %s Decoder class "
671 "has no %s() method", mod_name, method_name);
672 PyGILState_Release(gstate);
673 return SRD_ERR_PYTHON;
674 }
675
676 is_callable = PyCallable_Check(py_method);
677 Py_DECREF(py_method);
678
679 PyGILState_Release(gstate);
680
681 if (!is_callable) {
682 srd_err("Protocol decoder %s Decoder class attribute '%s' "
683 "is not a method.", mod_name, method_name);
684 return SRD_ERR_PYTHON;
685 }
686
687 return SRD_OK;
688}
689
690/**
691 * Get the API version of the specified decoder.

Callers 1

srd_decoder_loadFunction · 0.85

Calls 1

srd_exception_catchFunction · 0.85

Tested by

no test coverage detected