mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 23:28:16 +00:00
add a .keys() method to gst.Structure, plus test
Original commit message from CVS: * gst/gst.defs: * gst/gststructure.override: * testsuite/test_struct.py: add a .keys() method to gst.Structure, plus test
This commit is contained in:
parent
d5866645cc
commit
4a13efde8d
5 changed files with 49 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
|||
2005-09-20 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/gst.defs:
|
||||
* gst/gststructure.override:
|
||||
* testsuite/test_struct.py:
|
||||
add a .keys() method to gst.Structure, plus test
|
||||
|
||||
2005-09-19 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/gst.defs:
|
||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
|||
Subproject commit 13022c3cb4558d201e2ddf3e65d2e36b16eedc4a
|
||||
Subproject commit cd4da6a319d9f92d28f7b8a3b412577e6de50b64
|
|
@ -4457,6 +4457,13 @@
|
|||
)
|
||||
)
|
||||
|
||||
(define-method keys
|
||||
(of-object "GstStructure")
|
||||
(c-name "gst_structure_keys")
|
||||
(return-type "GList*")
|
||||
)
|
||||
|
||||
|
||||
(define-method get_boolean
|
||||
(of-object "GstStructure")
|
||||
(c-name "gst_structure_get_boolean")
|
||||
|
|
|
@ -166,6 +166,31 @@ _wrap_gst_structure_has_key(PyGObject *self, PyObject *args)
|
|||
|
||||
return PyBool_FromLong(has_field);
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_structure_keys noargs
|
||||
static PyObject *
|
||||
_wrap_gst_structure_keys (PyObject *self)
|
||||
{
|
||||
GstStructure *s;
|
||||
int i, n;
|
||||
PyObject *ret;
|
||||
|
||||
|
||||
ret = PyList_New(0);
|
||||
|
||||
s = pyg_boxed_get(self, GstStructure);
|
||||
n = gst_structure_n_fields(s);
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
const gchar *name = gst_structure_nth_field_name (s, i);
|
||||
PyList_Append(ret, PyString_FromString(name));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
%%
|
||||
override-slot GstStructure.tp_as_mapping
|
||||
static int
|
||||
|
|
|
@ -90,5 +90,14 @@ class StructureTest(unittest.TestCase):
|
|||
assert self.struct['pixel-aspect-ratio'].num == 2
|
||||
assert self.struct['pixel-aspect-ratio'].denom == 1
|
||||
|
||||
def testKeys(self):
|
||||
k = self.struct.keys()
|
||||
self.failUnless(k)
|
||||
self.assertEquals(len(k), 4)
|
||||
self.failUnless("width" in k)
|
||||
self.failUnless("foo" in k)
|
||||
self.failUnless("framerate" in k)
|
||||
self.failUnless("pixel-aspect-ratio" in k)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in a new issue