gst/pygstexception.*: gst.element_factory_make should raise ElementNotFoundError.
authorThomas Vander Stichele <thomas@apestaart.org>
Wed, 17 Jan 2007 07:30:11 +0000 (07:30 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Wed, 17 Jan 2007 07:30:11 +0000 (07:30 +0000)
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

ChangeLog
gst/gstelementfactory.override
gst/pygstexception.c
gst/pygstexception.h

index c303a2e..1570b48 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2007-01-17  Thomas Vander Stichele  <thomas at apestaart dot org>
 
+       * 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  <thomas at apestaart dot org>
+
        * gst/interfaces.defs:
        * gst/interfaces.override:
          wrap mixer get_volume
index b921424..e238f4f 100644 (file)
@@ -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);
index 5fec47b..0bc37a9 100644 (file)
@@ -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;
 }
index 5228703..f6d2297 100644 (file)
@@ -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);