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.
This commit is contained in:
Edward Hervey 2005-12-09 12:49:08 +00:00
parent d2bb507a16
commit 0a43240369
3 changed files with 57 additions and 2 deletions

View file

@ -1,3 +1,11 @@
2005-12-09 Edward Hervey <edward@fluendo.com>
* 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 <edward@fluendo.com>
* gst/gstmessage.override:

View file

@ -23,6 +23,7 @@
# Author: David I. Lehn <dlehn@users.sourceforge.net>
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

View file

@ -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))
)
)