overrides: Add more GstValue overrides
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Thu, 23 Mar 2017 16:21:32 +0000 (12:21 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Fri, 24 Mar 2017 17:26:21 +0000 (13:26 -0400)
commita4566ffbc83c9eb53af1337c97cc61f779c00d78
tree3f1106c13fec9cc03fd06e483fa7f9fdb349b894
parent7f78ed2541d7671bee2198ca45c556897c3ff060
overrides: Add more GstValue overrides

This patch adds overrides to support IntRange, Int64Range, DoubleRange,
FractionRange, Array and List. For integer ranges, it maps this
to python 'range'. Gst.IntRange() and Gst.Int64Range() are simple cast
to let the underlying code know which GType to use. To set such range in
python you will do:

  structure["range"] = Gst.IntRange(range(0,10,2)))

Same for the 64 bit variant. And when you do:

  r = structure.get_value("range")

A range will be returned directly, without the wrapper. For DoubleRange
and FractionRange, there is no native support in python. So the usage
will be:

  structure["range"] = Gst.DoubleRange(0,10.0)
  structure["range"] =
      Gst.FractionRange(Gst.Fraction(1/30), Gst.Fraction(1/5)

When getting this value, Gst.DoubleRange and Gst.FractionRange class are
returned. They both have start/stop members. The naming was taken from
range type.

For Array and List, both uses the native list type, though they can be
constructed from any python sequence. So again, the class is just like
a cast, to let it pick the right GType and python list are being
returned.

  structure["list"] = Gst.ValueList([1,2,3,4])
  structure["array"] = Gst.ValueArray([1,2,3,4)

Using string and tuple could also work. Since Gst.ValueList/Array are
sequence, you can convert one to the other with:

  list = Gst.ValueList([1,2,3,4])
  array = Gst.ValueArray (list)

https://bugzilla.gnome.org/show_bug.cgi?id=753754
12 files changed:
gi/overrides/Gst.py
gi/overrides/gstmodule.c
testsuite/Makefile.am
testsuite/common.py
testsuite/meson.build
testsuite/test_doublerange.py [new file with mode: 0644]
testsuite/test_fraction.py
testsuite/test_fractionrange.py [new file with mode: 0644]
testsuite/test_int64range.py [new file with mode: 0644]
testsuite/test_intrange.py [new file with mode: 0644]
testsuite/test_valuearray.py [new file with mode: 0644]
testsuite/test_valuelist.py [new file with mode: 0644]