From 0a43240369b8aec2566a1f003c2fd35fbec03740 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Fri, 9 Dec 2005 12:49:08 +0000 Subject: [PATCH] gst/arg-types.py: Added (reverse_)wrapper for GBoxed and GstMiniObject Original commit message from CVS: * gst/arg-types.py: Added (reverse_)wrapper for GBoxed and GstMiniObject * gst/gst.defs: push_event() and chain() takes the reference on the MiniObject. --- ChangeLog | 8 ++++++++ gst/arg-types.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ gst/gst.defs | 4 ++-- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index deb8da19c2..31b7919921 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-12-09 Edward Hervey + + * gst/arg-types.py: + Added (reverse_)wrapper for GBoxed and GstMiniObject + * gst/gst.defs: + push_event() and chain() takes the reference on the + MiniObject. + 2005-12-07 Edward Hervey * gst/gstmessage.override: diff --git a/gst/arg-types.py b/gst/arg-types.py index 8f85ea26c6..ca689104fb 100644 --- a/gst/arg-types.py +++ b/gst/arg-types.py @@ -23,6 +23,7 @@ # Author: David I. Lehn from argtypes import UInt64Arg, Int64Arg, PointerArg, ArgMatcher, ArgType, matcher +from reversewrapper import Parameter, ReturnType, GBoxedParam, GBoxedReturn class XmlNodeArg(ArgType): """libxml2 node generator""" @@ -128,6 +129,44 @@ class GstCapsArg(ArgType): else: raise RuntimeError, "write_return not implemented for %s" % ptype info.codeafter.append(' return pyg_boxed_new (GST_TYPE_CAPS, ret, '+copyval+', TRUE);') + +class GstMiniObjectParam(Parameter): + + def get_c_type(self): + return self.props.get('c_type', 'GstMiniObject *') + + def convert_c2py(self): + self.wrapper.add_declaration("PyObject *py_%s = NULL;" % self.name) + self.wrapper.write_code(code=("if (%s)\n" + " py_%s = pygstminiobject_new((GstMiniObject *) %s);\n" + "else {\n" + " Py_INCREF(Py_None);\n" + " py_%s = Py_None;\n" + "}" + % (self.name, self.name, self.name, self.name)), + cleanup=("Py_DECREF(py_%s);" % self.name)) + self.wrapper.add_pyargv_item("py_%s" % self.name) + +matcher.register_reverse('GstMiniObject*', GstMiniObjectParam) + +class GstMiniObjectReturn(ReturnType): + + def get_c_type(self): + return self.props.get('c_type', 'GstMiniObject *') + + def write_decl(self): + self.wrapper.add_declaration("%s retval;" % self.get_c_type()) + + def write_error_return(self): + self.wrapper.write_code("return NULL;") + + def write_conversion(self): + self.wrapper.write_code("retval = (%s) pygstminiobject_get(py_retval);" + % self.get_c_type()) + self.wrapper.write_code("gst_mini_object_ref((GstMiniObject *) retval);") + +matcher.register_reverse_ret('GstMiniObject*', GstMiniObjectReturn) + matcher.register('GstClockTime', UInt64Arg()) matcher.register('GstClockTimeDiff', Int64Arg()) @@ -140,4 +179,12 @@ matcher.register('const-GstCaps*', GstCapsArg()) arg = PointerArg('gpointer', 'G_TYPE_POINTER') matcher.register('GstClockID', arg) +for typename in ["GstPlugin", "GstStructure", "GstTagList", "GError", "GstDate", "GstSegment"]: + matcher.register_reverse(typename, GBoxedParam) + matcher.register_reverse_ret(typename, GBoxedReturn) + +for typename in ["GstBuffer*", "GstEvent*", "GstMessage*", "GstQuery*"]: + matcher.register_reverse(typename, GstMiniObjectParam) + matcher.register_reverse_ret(typename, GstMiniObjectReturn) + del arg diff --git a/gst/gst.defs b/gst/gst.defs index 8d027981c5..760164105d 100644 --- a/gst/gst.defs +++ b/gst/gst.defs @@ -3621,7 +3621,7 @@ (c-name "gst_pad_push_event") (return-type "gboolean") (parameters - '("GstEvent*" "event") + '("GstEvent*" "event" (keep-refcount)) ) ) @@ -3639,7 +3639,7 @@ (c-name "gst_pad_chain") (return-type "GstFlowReturn") (parameters - '("GstBuffer*" "buffer") + '("GstBuffer*" "buffer" (keep-refcount)) ) )