codegen/codegen.py: Resync (add support for tp_as_buffer)

Original commit message from CVS:
* codegen/codegen.py: Resync (add support for tp_as_buffer)

* gst/gst.override: Support buffer interface for GstBuffer. Move
stuff into common.h, fix wrapping for
gst_pad_template_get_caps_by_name
This commit is contained in:
Johan Dahlin 2004-05-03 09:10:26 +00:00
parent 3eae754e99
commit f63c95390b
7 changed files with 122 additions and 44 deletions

View file

@ -1,3 +1,11 @@
2004-05-03 Johan Dahlin <johan@gnome.org>
* codegen/codegen.py: Resync (add support for tp_as_buffer)
* gst/gst.override: Support buffer interface for GstBuffer. Move
stuff into common.h, fix wrapping for
gst_pad_template_get_caps_by_name
2004-05-01 Johan Dahlin <johan@gnome.org> 2004-05-01 Johan Dahlin <johan@gnome.org>
* testsuite/runtests.py (gettestnames): Cleanup * testsuite/runtests.py (gettestnames): Cleanup

View file

@ -74,7 +74,7 @@ class Wrapper:
' (reprfunc)%(tp_str)s, /* tp_str */\n' \ ' (reprfunc)%(tp_str)s, /* tp_str */\n' \
' (getattrofunc)0, /* tp_getattro */\n' \ ' (getattrofunc)0, /* tp_getattro */\n' \
' (setattrofunc)0, /* tp_setattro */\n' \ ' (setattrofunc)0, /* tp_setattro */\n' \
' 0, /* tp_as_buffer */\n' \ ' (PyBufferProcs*)%(tp_as_buffer)s, /* tp_as_buffer */\n' \
' Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */\n' \ ' Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */\n' \
' NULL, /* Documentation string */\n' \ ' NULL, /* Documentation string */\n' \
' (traverseproc)0, /* tp_traverse */\n' \ ' (traverseproc)0, /* tp_traverse */\n' \
@ -100,7 +100,7 @@ class Wrapper:
slots_list = ['tp_getattr', 'tp_setattr', 'tp_compare', 'tp_repr', slots_list = ['tp_getattr', 'tp_setattr', 'tp_compare', 'tp_repr',
'tp_as_number', 'tp_as_sequence', 'tp_as_mapping', 'tp_hash', 'tp_as_number', 'tp_as_sequence', 'tp_as_mapping', 'tp_hash',
'tp_call', 'tp_str', 'tp_richcompare', 'tp_iter', 'tp_call', 'tp_str', 'tp_as_buffer', 'tp_richcompare', 'tp_iter',
'tp_iternext', 'tp_descr_get', 'tp_descr_set', 'tp_init', 'tp_iternext', 'tp_descr_get', 'tp_descr_set', 'tp_init',
'tp_alloc', 'tp_new', 'tp_free', 'tp_is_gc'] 'tp_alloc', 'tp_new', 'tp_free', 'tp_is_gc']

View file

@ -77,6 +77,7 @@ dnl AC_MSG_RESULT($PYGTK_CODEGEN)
PYGTK_CODEGEN="$PYTHON \$(top_srcdir)/codegen/codegen.py" PYGTK_CODEGEN="$PYTHON \$(top_srcdir)/codegen/codegen.py"
AC_SUBST(PYGTK_CODEGEN) AC_SUBST(PYGTK_CODEGEN)
dnl Interfaces
AC_MSG_CHECKING(for GStreamer interfaces include dir) AC_MSG_CHECKING(for GStreamer interfaces include dir)
PKG_CHECK_MODULES(GST_INTERFACES, gstreamer-interfaces-$GST_MAJORMINOR, PKG_CHECK_MODULES(GST_INTERFACES, gstreamer-interfaces-$GST_MAJORMINOR,
HAVE_INTERFACES=yes,HAVE_INTERFACES=no) HAVE_INTERFACES=yes,HAVE_INTERFACES=no)
@ -84,6 +85,7 @@ AM_CONDITIONAL(BUILD_INTERFACES, test "x$HAVE_INTERFACES" = "xyes")
AC_SUBST(GST_INTERFACES_CFLAGS) AC_SUBST(GST_INTERFACES_CFLAGS)
AC_SUBST(GST_INTERFACES_LIBS) AC_SUBST(GST_INTERFACES_LIBS)
dnl Play
AC_MSG_CHECKING(for GStreamer play include dir) AC_MSG_CHECKING(for GStreamer play include dir)
PKG_CHECK_MODULES(GST_PLAY, gstreamer-play-$GST_MAJORMINOR, PKG_CHECK_MODULES(GST_PLAY, gstreamer-play-$GST_MAJORMINOR,
HAVE_PLAY=yes,HAVE_PLAY=no) HAVE_PLAY=yes,HAVE_PLAY=no)
@ -91,6 +93,14 @@ AM_CONDITIONAL(BUILD_PLAY, test "x$HAVE_PLAY" = "xyes")
AC_SUBST(GST_PLAY_CFLAGS) AC_SUBST(GST_PLAY_CFLAGS)
AC_SUBST(GST_PLAY_LIBS) AC_SUBST(GST_PLAY_LIBS)
dnl Editor
AC_MSG_CHECKING(for GStreamer editor include dir)
PKG_CHECK_MODULES(GST_EDITOR, gst-editor-libs >= 0.7.0,
HAVE_EDITOR=yes,HAVE_EDITOR=no)
AM_CONDITIONAL(BUILD_EDITOR, test "x$HAVE_EDITOR" = "xyes")
AC_SUBST(GST_EDITOR_CFLAGS)
AC_SUBST(GST_EDITOR_LIBS)
AC_CHECK_PROG(HAVE_XMLTO, xmlto, true, false) AC_CHECK_PROG(HAVE_XMLTO, xmlto, true, false)
AC_CHECK_PROG(HAVE_XMLCATALOG, xmlcatalog, true, false) AC_CHECK_PROG(HAVE_XMLCATALOG, xmlcatalog, true, false)

View file

@ -169,6 +169,7 @@
(gtype-id "GST_TYPE_CAPS") (gtype-id "GST_TYPE_CAPS")
) )
; Defined in arg-types.py
;(define-boxed Data ;(define-boxed Data
; (in-module "Gst") ; (in-module "Gst")
; (c-name "GstData") ; (c-name "GstData")
@ -177,12 +178,13 @@
; (release-func "gst_data_free") ; (release-func "gst_data_free")
;) ;)
(define-boxed Event ; HACK, should be boxed
(define-pointer Event
(in-module "Gst") (in-module "Gst")
(c-name "GstEvent") (c-name "GstEvent")
(gtype-id "GST_TYPE_EVENT") (gtype-id "GST_TYPE_EVENT")
(copy-func "gst_event_copy") ; (copy-func "gst_event_copy")
(release-func "gst_data_unref") ; (release-func "gst_event_unref")
) )
(define-boxed GError (define-boxed GError

View file

@ -22,34 +22,18 @@
*/ */
%% %%
headers headers
#include <Python.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif
#include "pygobject.h" #include "common.h"
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/gsterror.h> #include <gst/gsterror.h>
#include <gst/gstqueue.h> #include <gst/gstqueue.h>
#include <gst/gsttypefind.h> #include <gst/gsttypefind.h>
#include <gst/gsttag.h> #include <gst/gsttag.h>
#if PY_VERSION_HEX < 0x02030000
typedef destructor freefunc;
#endif
typedef struct {
PyGObject *pad;
PyObject *link_function;
PyObject *event_function;
PyObject *chain_function;
PyObject *get_function;
} PyGstPadPrivate;
typedef struct {
PyObject *func, *data;
} PyGstCustomNotify;
extern gboolean pygst_data_from_pyobject (PyObject *object, GstData **data); extern gboolean pygst_data_from_pyobject (PyObject *object, GstData **data);
static PyObject *_wrap_gst_element_factory_make(PyObject *self, PyObject *args, PyObject *kwargs); static PyObject *_wrap_gst_element_factory_make(PyObject *self, PyObject *args, PyObject *kwargs);
@ -58,11 +42,10 @@ include
gstpad-handlers.override gstpad-handlers.override
%% %%
init init
/* This is due to a bug in PyGTK 2.3.91, should be removed when we can require
* a newer version.
*/
PyGstPipeline_Type.tp_new = PyType_GenericNew; PyGstPipeline_Type.tp_new = PyType_GenericNew;
PyGstThread_Type.tp_new = PyType_GenericNew; PyGstThread_Type.tp_new = PyType_GenericNew;
PyGstQueue_Type.tp_new = PyType_GenericNew;
PyGstBin_Type.tp_new = PyType_GenericNew; // Shouldn't this be enough?
%% %%
modulename gst modulename gst
%% %%
@ -202,6 +185,24 @@ _wrap_gst_element_get_pad_list(PyGObject *self)
return list; return list;
} }
%% %%
override gst_element_get_pad_template_list noargs
static PyObject *
_wrap_gst_element_get_pad_template_list(PyGObject *self)
{
GList *l, *pads;
PyObject *list;
pads = (GList*)gst_element_get_pad_template_list(GST_ELEMENT(self->obj));
list = PyList_New(0);
for (l = pads; l; l = l->next) {
GstPad *pad = (GstPad*)l->data;
PyList_Append(list, pygobject_new(G_OBJECT(pad)));
}
return list;
}
%%
override gst_element_set_state kwargs override gst_element_set_state kwargs
static PyObject * static PyObject *
_wrap_gst_element_set_state(PyGObject *self, PyObject *args, PyObject *kwargs) _wrap_gst_element_set_state(PyGObject *self, PyObject *args, PyObject *kwargs)
@ -1001,7 +1002,7 @@ _wrap_gst_pad_template_get_caps(PyGObject *self)
return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE); return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE);
} }
%% %%
override gst_type_fidn_factory_get_caps noargs override gst_type_find_factory_get_caps noargs
static PyObject * static PyObject *
_wrap_gst_type_find_factory_get_caps(PyGObject *self) _wrap_gst_type_find_factory_get_caps(PyGObject *self)
{ {
@ -1009,7 +1010,7 @@ _wrap_gst_type_find_factory_get_caps(PyGObject *self)
return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE); return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE);
} }
%% %%
override gst_pad_template_get_caps_ny_name kwargs override gst_pad_template_get_caps_by_name kwargs
static PyObject * static PyObject *
_wrap_gst_pad_template_get_caps_by_name(PyGObject *self, PyObject *args, PyObject *kwargs) _wrap_gst_pad_template_get_caps_by_name(PyGObject *self, PyObject *args, PyObject *kwargs)
{ {
@ -1020,6 +1021,7 @@ _wrap_gst_pad_template_get_caps_by_name(PyGObject *self, PyObject *args, PyObjec
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:GstPadTemplate.get_caps_by_name", kwlist, &name)) if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:GstPadTemplate.get_caps_by_name", kwlist, &name))
return NULL; return NULL;
ret = (GstCaps*)gst_pad_template_get_caps_by_name(GST_PAD_TEMPLATE(self->obj), name); ret = (GstCaps*)gst_pad_template_get_caps_by_name(GST_PAD_TEMPLATE(self->obj), name);
/* pyg_boxed_new handles NULL checking */
return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE); return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE);
} }
%% %%
@ -1076,3 +1078,57 @@ _wrap_gst_element_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{ {
return _wrap_gst_element_factory_make(NULL, args, kwargs); return _wrap_gst_element_factory_make(NULL, args, kwargs);
} }
%%
override-slot GstBuffer.tp_as_buffer
static int
gst_buffer_getreadbuffer(PyGObject *self, int index, const void **ptr)
{
if ( index != 0 ) {
PyErr_SetString(PyExc_SystemError,
"accessing non-existent string segment");
return -1;
}
*ptr = GST_BUFFER_DATA(self->obj);
return GST_BUFFER_SIZE(self->obj);
}
static int
gst_buffer_getsegcount(PyGObject *self, int *lenp)
{
if (lenp)
*lenp = GST_BUFFER_SIZE(self->obj);
return 1;
}
static int
gst_buffer_getcharbuf(PyGObject *self, int index, const char **ptr)
{
if ( index != 0 ) {
PyErr_SetString(PyExc_SystemError,
"accessing non-existent string segment");
return -1;
}
*ptr = GST_BUFFER_DATA(self->obj);
return GST_BUFFER_SIZE(self->obj);
}
#if 0
static int
string_buffer_getwritebuf(PyStringObject *self, int index, const void **ptr)
{
PyErr_SetString(PyExc_TypeError,
"Cannot use string as modifiable buffer");
return -1;
}
#endif
static PyBufferProcs _wrap_gst_buffer_tp_as_buffer = {
(getreadbufferproc)gst_buffer_getreadbuffer,
(getwritebufferproc)NULL,
(getsegcountproc)gst_buffer_getsegcount,
(getcharbufferproc)gst_buffer_getcharbuf,
};

View file

@ -21,9 +21,12 @@
*/ */
%% %%
headers headers
#include <Python.h> #ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "common.h"
#include "pygobject.h"
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/colorbalance/colorbalance.h> #include <gst/colorbalance/colorbalance.h>
#include <gst/colorbalance/colorbalancechannel.h> #include <gst/colorbalance/colorbalancechannel.h>
@ -34,9 +37,6 @@ headers
#include <gst/tuner/tuner.h> #include <gst/tuner/tuner.h>
#include <gst/xwindowlistener/xwindowlistener.h> #include <gst/xwindowlistener/xwindowlistener.h>
#if PY_VERSION_HEX < 0x02030000
typedef destructor freefunc;
#endif
%% %%
modulename gst.interfaces modulename gst.interfaces
%% %%

View file

@ -21,15 +21,17 @@
*/ */
%% %%
headers headers
#include <Python.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <Python.h>
#include "pygobject.h" #include "pygobject.h"
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/play/play.h> #include <gst/play/play.h>
#if PY_VERSION_HEX < 0x02030000
typedef destructor freefunc;
#endif
%% %%
modulename gst.play modulename gst.play
%% %%