From ddf94ea8fa1df67086eb17aff371027b51cf73d7 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Fri, 9 Dec 2005 13:06:43 +0000 Subject: [PATCH] gst/arg-types.py: This covers for the codegenerator not being able to handle (unsigned) int64 as parameters and retur... Original commit message from CVS: * gst/arg-types.py: This covers for the codegenerator not being able to handle (unsigned) int64 as parameters and return values. --- ChangeLog | 6 +++++ gst/arg-types.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/ChangeLog b/ChangeLog index 31b7919921..95a70a86d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-12-09 Edward Hervey + + * gst/arg-types.py: + This covers for the codegenerator not being able to handle + (unsigned) int64 as parameters and return values. + 2005-12-09 Edward Hervey * gst/arg-types.py: diff --git a/gst/arg-types.py b/gst/arg-types.py index ca689104fb..bb6d42e6c8 100644 --- a/gst/arg-types.py +++ b/gst/arg-types.py @@ -167,6 +167,57 @@ class GstMiniObjectReturn(ReturnType): matcher.register_reverse_ret('GstMiniObject*', GstMiniObjectReturn) +class Int64Param(Parameter): + + def get_c_type(self): + return self.props.get('c_type', 'gint64') + + def convert_c2py(self): + self.wrapper.add_declaration("PyObject *py_%s;" % self.name) + self.wrapper.write_code(code=("py_%s = PyLong_FromLongLong(%s);" % + (self.name, self.name)), + cleanup=("Py_DECREF(py_%s);" % self.name)) + self.wrapper.add_pyargv_item("py_%s" % self.name) + +class Int64Return(ReturnType): + def get_c_type(self): + return self.props.get('c_type', 'gint64') + def write_decl(self): + self.wrapper.add_declaration("%s retval;" % self.get_c_type()) + def write_error_return(self): + self.wrapper.write_code("return -G_MAXINT;") + def write_conversion(self): + self.wrapper.write_code( + code=None, + failure_expression="!PyLong_Check(py_retval)", + failure_cleanup='PyErr_SetString(PyExc_TypeError, "retval should be an long");') + self.wrapper.write_code("retval = PyLong_AsLongLong(py_retval);") + +class UInt64Param(Parameter): + + def get_c_type(self): + return self.props.get('c_type', 'guint64') + + def convert_c2py(self): + self.wrapper.add_declaration("PyObject *py_%s;" % self.name) + self.wrapper.write_code(code=("py_%s = PyLong_FromUnsignedLongLong(%s);" % + (self.name, self.name)), + cleanup=("Py_DECREF(py_%s);" % self.name)) + self.wrapper.add_pyargv_item("py_%s" % self.name) + +class UInt64Return(ReturnType): + def get_c_type(self): + return self.props.get('c_type', 'guint64') + def write_decl(self): + self.wrapper.add_declaration("%s retval;" % self.get_c_type()) + def write_error_return(self): + self.wrapper.write_code("return -G_MAXINT;") + def write_conversion(self): + self.wrapper.write_code( + code=None, + failure_expression="!PyLong_Check(py_retval)", + failure_cleanup='PyErr_SetString(PyExc_TypeError, "retval should be an long");') + self.wrapper.write_code("retval = PyLong_AsUnsignedLongLongMask(py_retval);") matcher.register('GstClockTime', UInt64Arg()) matcher.register('GstClockTimeDiff', Int64Arg()) @@ -187,4 +238,12 @@ for typename in ["GstBuffer*", "GstEvent*", "GstMessage*", "GstQuery*"]: matcher.register_reverse(typename, GstMiniObjectParam) matcher.register_reverse_ret(typename, GstMiniObjectReturn) +for typename in ["gint64", "GstClockTimeDiff"]: + matcher.register_reverse(typename, Int64Param) + matcher.register_reverse_ret(typename, Int64Return) + +for typename in ["guint64", "GstClockTime"]: + matcher.register_reverse(typename, UInt64Param) + matcher.register_reverse_ret(typename, UInt64Return) + del arg