reindent the gst way

Original commit message from CVS:
reindent the gst way
This commit is contained in:
Thomas Vander Stichele 2005-10-27 15:54:32 +00:00
parent 9f09254291
commit 5f81d50344

View file

@ -1,4 +1,4 @@
/* -*- Mode: C; ; c-file-style: "python" -*- */ /* -*- Mode: C -*- */
/* gst-python /* gst-python
* Copyright (C) 2005 Edward Hervey * Copyright (C) 2005 Edward Hervey
* *
@ -31,12 +31,11 @@ override-attr GstObject.__gstrefcount__
/* keep this attribute around even after 2.8 for compatibility reasons */ /* keep this attribute around even after 2.8 for compatibility reasons */
static PyObject * static PyObject *
_wrap_gst_object__get___gstrefcount__(PyGObject *self, void *closure) _wrap_gst_object__get___gstrefcount__ (PyGObject * self, void *closure)
{ {
return PyInt_FromLong(GST_OBJECT_REFCOUNT_VALUE(self->obj)); return PyInt_FromLong (GST_OBJECT_REFCOUNT_VALUE (self->obj));
} }
/* < GLib 2.8 */ /* < GLib 2.8 */
/* because of our gst_object_ref/_unref, we do our own GC-related /* because of our gst_object_ref/_unref, we do our own GC-related
@ -55,134 +54,142 @@ override-slot GstObject.tp_flags
%% %%
override-slot GstObject.tp_traverse override-slot GstObject.tp_traverse
static int static int
_wrap_gst_object_tp_traverse(PyGObject *self, visitproc visit, void *arg) _wrap_gst_object_tp_traverse (PyGObject * self, visitproc visit, void *arg)
{ {
int ret = 0; int ret = 0;
GSList *tmp; GSList *tmp;
GST_LOG_OBJECT(self->obj, "gst.Object.tp_traverse, arg:%p", arg); GST_LOG_OBJECT (self->obj, "gst.Object.tp_traverse, arg:%p", arg);
if (self->inst_dict) ret = visit(self->inst_dict, arg);
if (ret != 0) return ret;
GST_LOG_OBJECT(self->obj, "visited self->inst_dict");
for (tmp = self->closures; tmp != NULL; tmp = tmp->next) {
PyGClosure *closure = tmp->data;
GST_DEBUG_OBJECT (self->obj, "visiting closures");
if (closure->callback) ret = visit(closure->callback, arg);
if (ret != 0) return ret;
if (closure->extra_args) ret = visit(closure->extra_args, arg);
if (ret != 0) return ret;
if (closure->swap_data) ret = visit(closure->swap_data, arg);
if (ret != 0) return ret;
}
if (self->obj && GST_OBJECT_REFCOUNT_VALUE(self->obj) == 1) {
GST_DEBUG_OBJECT(self->obj,
"gst.Object.tp_traverse: GstObject refcount of %p is 1, visit",
self->obj);
ret = visit((PyObject *)self, arg);
GST_LOG_OBJECT(self->obj,
"gst.Object.tp_traverse: GstObject %p visited, ret %d, refcount %d",
self->obj, ret, GST_OBJECT_REFCOUNT_VALUE(self->obj));
}
if (self->inst_dict) {
ret = visit (self->inst_dict, arg);
GST_LOG_OBJECT (self->obj, "visited self->inst_dict, ret %d", ret);
}
if (ret != 0)
return ret; return ret;
for (tmp = self->closures; tmp != NULL; tmp = tmp->next) {
PyGClosure *closure = tmp->data;
GST_DEBUG_OBJECT (self->obj, "visiting closures");
if (closure->callback)
ret = visit (closure->callback, arg);
if (ret != 0)
return ret;
if (closure->extra_args)
ret = visit (closure->extra_args, arg);
if (ret != 0)
return ret;
if (closure->swap_data)
ret = visit (closure->swap_data, arg);
if (ret != 0)
return ret;
}
if (self->obj && GST_OBJECT_REFCOUNT_VALUE (self->obj) == 1) {
GST_DEBUG_OBJECT (self->obj,
"gst.Object.tp_traverse: GstObject refcount of %p is 1, visit",
self->obj);
ret = visit ((PyObject *) self, arg);
GST_LOG_OBJECT (self->obj,
"gst.Object.tp_traverse: GstObject %p visited, ret %d, refcount %d",
self->obj, ret, GST_OBJECT_REFCOUNT_VALUE (self->obj));
}
return ret;
} }
%% %%
override-slot GstObject.tp_clear override-slot GstObject.tp_clear
int int
_wrap_gst_object_tp_clear(PyGObject *self) _wrap_gst_object_tp_clear (PyGObject * self)
{ {
int ret; int ret;
GObject *obj = self->obj; GObject *obj = self->obj;
/* if we're a GstObject, we want to monkeypatch the GObject.tp_clear's /* if we're a GstObject, we want to monkeypatch the GObject.tp_clear's
* g_object_unref and "replace" it with a gst_object_unref */ * g_object_unref and "replace" it with a gst_object_unref */
if (! GST_IS_OBJECT (obj)) if (!GST_IS_OBJECT (obj))
obj = NULL; obj = NULL;
else { else {
GST_DEBUG_OBJECT (obj, GST_DEBUG_OBJECT (obj,
"gst.Object.tp_clear, pyo %p, pyo rc %d, gsto %p, gst rc %d", "gst.Object.tp_clear, pyo %p, pyo rc %d, gsto %p, gst rc %d",
self, ((PyObject *) self)->ob_refcnt, obj, self, ((PyObject *) self)->ob_refcnt, obj,
GST_OBJECT_REFCOUNT_VALUE (obj)); GST_OBJECT_REFCOUNT_VALUE (obj));
g_object_ref (obj); g_object_ref (obj);
} }
ret = PyGObject_Type.tp_clear((PyObject *) self); ret = PyGObject_Type.tp_clear ((PyObject *) self);
if (obj) if (obj)
gst_object_unref (obj); gst_object_unref (obj);
return ret; return ret;
} }
%% %%
override-slot GstObject.tp_dealloc override-slot GstObject.tp_dealloc
void void
_wrap_gst_object_tp_dealloc(PyGObject *self) _wrap_gst_object_tp_dealloc (PyGObject * self)
{ {
GObject *obj = self->obj; GObject *obj = self->obj;
/* if we're a GstObject, we want to monkeypatch the GObject.tp_dealloc's /* if we're a GstObject, we want to monkeypatch the GObject.tp_dealloc's
* g_object_unref and "replace" it with a gst_object_unref */ * g_object_unref and "replace" it with a gst_object_unref */
if (GST_IS_OBJECT (obj)) { if (GST_IS_OBJECT (obj)) {
GST_DEBUG_OBJECT (obj, "gst.Object.tp_dealloc, go rc %d, gsto rc %d", GST_DEBUG_OBJECT (obj, "gst.Object.tp_dealloc, go rc %d, gsto rc %d",
obj->ref_count, GST_OBJECT_REFCOUNT_VALUE (obj)); obj->ref_count, GST_OBJECT_REFCOUNT_VALUE (obj));
if (GST_OBJECT_REFCOUNT_VALUE (obj) == 0) { if (GST_OBJECT_REFCOUNT_VALUE (obj) == 0) {
/* already being finalized, can't resurrect object */ /* already being finalized, can't resurrect object */
obj = NULL; obj = NULL;
self->obj = NULL; self->obj = NULL;
} else {
g_object_ref (obj);
}
} else { } else {
obj = NULL; g_object_ref (obj);
} }
} else {
obj = NULL;
}
PyGObject_Type.tp_dealloc((PyObject *) self); PyGObject_Type.tp_dealloc ((PyObject *) self);
if (obj) if (obj)
gst_object_unref (obj); gst_object_unref (obj);
} }
%% %%
override-slot GstObject.tp_repr override-slot GstObject.tp_repr
static PyObject * static PyObject *
_wrap_gst_object_tp_repr(PyObject *self) _wrap_gst_object_tp_repr (PyObject * self)
{ {
gchar *repr; gchar *repr;
PyObject *ret; PyObject *ret;
GstObject *object = GST_OBJECT (pygobject_get (self)); GstObject *object = GST_OBJECT (pygobject_get (self));
repr = g_strdup_printf ("<%s object (%s) at 0x%lx>", repr = g_strdup_printf ("<%s object (%s) at 0x%lx>",
self->ob_type->tp_name, self->ob_type->tp_name,
GST_OBJECT_NAME(object) ? GST_OBJECT_NAME(object) : "unnamed", GST_OBJECT_NAME (object) ? GST_OBJECT_NAME (object) : "unnamed",
(long)self); (long) self);
ret = PyString_FromString(repr); ret = PyString_FromString (repr);
g_free (repr); g_free (repr);
return ret; return ret;
} }
%% %%
override-slot GstObject.tp_str override-slot GstObject.tp_str
static PyObject * static PyObject *
_wrap_gst_object_tp_str(PyObject *self) _wrap_gst_object_tp_str (PyObject * self)
{ {
gchar *repr, *path; gchar *repr, *path;
PyObject *ret; PyObject *ret;
GstObject *object = GST_OBJECT (pygobject_get (self)); GstObject *object = GST_OBJECT (pygobject_get (self));
path = gst_object_get_path_string (object); path = gst_object_get_path_string (object);
repr = g_strdup_printf ("%s (%s)", repr = g_strdup_printf ("%s (%s)", path, self->ob_type->tp_name);
path, self->ob_type->tp_name); ret = PyString_FromString (repr);
ret = PyString_FromString(repr); g_free (repr);
g_free (repr); g_free (path);
g_free (path); return ret;
return ret;
} }