From: Thomas Vander Stichele Date: Wed, 17 Jan 2007 07:30:11 +0000 (+0000) Subject: gst/pygstexception.*: gst.element_factory_make should raise ElementNotFoundError. X-Git-Tag: 1.19.3~485^2~716 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=10fe9ba7f4edac45af681633a6e05f4e4ebf6ef0;p=platform%2Fupstream%2Fgstreamer.git gst/pygstexception.*: gst.element_factory_make should raise ElementNotFoundError. Original commit message from CVS: * gst/pygstexception.c: (element_not_found_error_init), (pygst_exceptions_register_classes): * gst/pygstexception.h: gst.element_factory_make should raise ElementNotFoundError. Subclass it from PluginNotFoundError so we can add it compatibly and remove the wrong one later. * gst/gstelementfactory.override: raise ElementNotFoundError --- diff --git a/ChangeLog b/ChangeLog index c303a2e..1570b48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2007-01-17 Thomas Vander Stichele + * gst/pygstexception.c: (element_not_found_error_init), + (pygst_exceptions_register_classes): + * gst/pygstexception.h: + gst.element_factory_make should raise ElementNotFoundError. + Subclass it from PluginNotFoundError so we can add it compatibly + and remove the wrong one later. + * gst/gstelementfactory.override: + raise ElementNotFoundError + +2007-01-17 Thomas Vander Stichele + * gst/interfaces.defs: * gst/interfaces.override: wrap mixer get_volume diff --git a/gst/gstelementfactory.override b/gst/gstelementfactory.override index b921424..e238f4f 100644 --- a/gst/gstelementfactory.override +++ b/gst/gstelementfactory.override @@ -35,7 +35,7 @@ _wrap_gst_element_factory_make(PyObject *self, PyObject *args, PyObject *kwargs) return NULL; ret = gst_element_factory_make(factoryname, name); if (ret == NULL) { - PyErr_SetString(PyGstExc_PluginNotFoundError, factoryname); + PyErr_SetString(PyGstExc_ElementNotFoundError, factoryname); return NULL; } py_ret = pygobject_new((GObject *)ret); diff --git a/gst/pygstexception.c b/gst/pygstexception.c index 5fec47b..0bc37a9 100644 --- a/gst/pygstexception.c +++ b/gst/pygstexception.c @@ -29,6 +29,7 @@ PyObject *PyGstExc_AddError = NULL; PyObject *PyGstExc_QueryError = NULL; PyObject *PyGstExc_RemoveError = NULL; PyObject *PyGstExc_PluginNotFoundError = NULL; +PyObject *PyGstExc_ElementNotFoundError = NULL; static PyObject * @@ -115,21 +116,21 @@ link_error_init(PyObject *self, PyObject *args) } static PyObject * -plugin_not_found_error_init(PyObject *self, PyObject *args) +element_not_found_error_init(PyObject *self, PyObject *args) { - PyObject *plugin_name = NULL; + PyObject *element_name = NULL; int status; - if (!PyArg_ParseTuple(args, "O|O:__init__", &self, &plugin_name)) + if (!PyArg_ParseTuple(args, "O|O:__init__", &self, &element_name)) return NULL; - if (plugin_name == NULL) - plugin_name = Py_None; - Py_INCREF(plugin_name); + if (element_name == NULL) + element_name = Py_None; + Py_INCREF(element_name); /* set self.name */ - status = PyObject_SetAttrString(self, "name", plugin_name); - Py_DECREF(plugin_name); + status = PyObject_SetAttrString(self, "name", element_name); + Py_DECREF(element_name); if (status < 0) return NULL; @@ -140,8 +141,8 @@ static PyMethodDef link_error_init_method = {"__init__", link_error_init, METH_VARARGS }; -static PyMethodDef plugin_not_found_error_init_method = {"__init__", - plugin_not_found_error_init, METH_VARARGS +static PyMethodDef element_not_found_error_init_method = {"__init__", + element_not_found_error_init, METH_VARARGS }; void @@ -202,6 +203,8 @@ pygst_exceptions_register_classes(PyObject *d) Py_DECREF(PyGstExc_QueryError); +/* FIXME: remove this method in 0.11; element_factory_make deals with element + factories, not plug-ins */ /* register gst.PluginNotFoundError */ dict = PyDict_New(); @@ -214,7 +217,7 @@ pygst_exceptions_register_classes(PyObject *d) goto exception; if (add_method(PyGstExc_PluginNotFoundError, - dict, &plugin_not_found_error_init_method) < 0) + dict, &element_not_found_error_init_method) < 0) goto exception; Py_DECREF(dict); @@ -224,7 +227,31 @@ pygst_exceptions_register_classes(PyObject *d) goto exception; Py_DECREF(PyGstExc_PluginNotFoundError); + + /* register gst.ElementNotFoundError */ + dict = PyDict_New(); + if (dict == NULL) + goto exception; + + PyGstExc_ElementNotFoundError = \ + PyErr_NewException("gst.ElementNotFoundError", PyGstExc_PluginNotFoundError, dict); + if (PyGstExc_ElementNotFoundError == NULL) + goto exception; + + if (add_method(PyGstExc_ElementNotFoundError, + dict, &element_not_found_error_init_method) < 0) + goto exception; + + Py_DECREF(dict); + if (PyDict_SetItemString(d, "ElementNotFoundError", + PyGstExc_ElementNotFoundError) < 0) + goto exception; + + Py_DECREF(PyGstExc_ElementNotFoundError); + + return; + return; exception: @@ -234,6 +261,7 @@ exception: Py_XDECREF(PyGstExc_RemoveError); Py_XDECREF(PyGstExc_QueryError); Py_XDECREF(PyGstExc_PluginNotFoundError); + Py_XDECREF(PyGstExc_ElementNotFoundError); return; } diff --git a/gst/pygstexception.h b/gst/pygstexception.h index 5228703..f6d2297 100644 --- a/gst/pygstexception.h +++ b/gst/pygstexception.h @@ -29,6 +29,7 @@ extern PyObject *PyGstExc_AddError; extern PyObject *PyGstExc_RemoveError; extern PyObject *PyGstExc_QueryError; extern PyObject *PyGstExc_PluginNotFoundError; +extern PyObject *PyGstExc_ElementNotFoundError; void pygst_exceptions_register_classes(PyObject *d);