diff options
author | Edward Hervey <bilboed@bilboed.com> | 2008-12-06 15:41:41 +0000 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2008-12-06 15:41:41 +0000 |
commit | 7a2babed30a2511fe153e3e20c35c1bf674d2dcc (patch) | |
tree | 0b9f05f939cadac962f5fb258e90bb3de61aee6e | |
parent | d658b7b2225e22bb9daedd0281f8d510779b15c8 (diff) |
codegen/argtypes.py: Add handling of 'keep-refcount' for GBoxed arguments.
Original commit message from CVS:
* codegen/argtypes.py:
Add handling of 'keep-refcount' for GBoxed arguments.
* gst/gst.defs:
Mark the appropriate 'gst_message_new_*' arguments when the method
takes the ownership of the passed gst.Structure/gst.TagList
* testsuite/test_message.py:
Test for creating messages that take a gst.Structure/gst.TagList as
argument and make sure they're properly created.
Fixes #556054
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | codegen/argtypes.py | 5 | ||||
-rw-r--r-- | gst/gst.defs | 8 | ||||
-rw-r--r-- | testsuite/test_message.py | 51 |
4 files changed, 72 insertions, 4 deletions
@@ -1,5 +1,17 @@ 2008-12-06 Edward Hervey <edward.hervey@collabora.co.uk> + * codegen/argtypes.py: + Add handling of 'keep-refcount' for GBoxed arguments. + * gst/gst.defs: + Mark the appropriate 'gst_message_new_*' arguments when the method + takes the ownership of the passed gst.Structure/gst.TagList + * testsuite/test_message.py: + Test for creating messages that take a gst.Structure/gst.TagList as + argument and make sure they're properly created. + Fixes #556054 + +2008-12-06 Edward Hervey <edward.hervey@collabora.co.uk> + * testsuite/Makefile.am: Add a way to run individual tests. 'make test_bin.py.check' for example. diff --git a/codegen/argtypes.py b/codegen/argtypes.py index 948bae1..de34feb 100644 --- a/codegen/argtypes.py +++ b/codegen/argtypes.py @@ -613,6 +613,7 @@ class BoxedArg(ArgType): ' PyErr_SetString(PyExc_TypeError, "%(name)s should be a %(typename)s or None");\n' ' return NULL;\n' ' }\n') + acopy = (' %(name)s = g_boxed_copy(%(typecode)s, %(name)s);\n') def __init__(self, ptype, typecode): self.typename = ptype self.typecode = typecode @@ -629,6 +630,10 @@ class BoxedArg(ArgType): info.codebefore.append(self.check % {'name': pname, 'typename': self.typename, 'typecode': self.typecode}) + if keeprefcount: + # We need to grab a copy of the GBoxed + info.codebefore.append(self.acopy % {'name': pname, + 'typecode': self.typecode}) if ptype[-1] == '*': typename = ptype[:-1] if typename[:6] == 'const-': typename = typename[6:] diff --git a/gst/gst.defs b/gst/gst.defs index 20b728f..69fdd59 100644 --- a/gst/gst.defs +++ b/gst/gst.defs @@ -3038,7 +3038,7 @@ (caller-owns-return #t) (parameters '("GstObject*" "src") - '("GstTagList*" "tag_list") + '("GstTagList*" "tag_list" (keep-refcount)) ) ) @@ -3131,7 +3131,7 @@ (caller-owns-return #t) (parameters '("GstObject*" "src") - '("GstStructure*" "structure") + '("GstStructure*" "structure" (keep-refcount)) ) ) @@ -3141,7 +3141,7 @@ (caller-owns-return #t) (parameters '("GstObject*" "src") - '("GstStructure*" "structure") + '("GstStructure*" "structure" (keep-refcount)) ) ) @@ -3191,7 +3191,7 @@ (parameters '("GstMessageType" "type") '("GstObject*" "src") - '("GstStructure*" "structure") + '("GstStructure*" "structure" (keep-refcount)) ) ) diff --git a/testsuite/test_message.py b/testsuite/test_message.py index 505e9c1..3d7dbf4 100644 --- a/testsuite/test_message.py +++ b/testsuite/test_message.py @@ -55,5 +55,56 @@ class NewTest(TestCase): self.failUnless(self.got_message == True) self.gccollect() +class TestCreateMessages(TestCase): + + def setUp(self): + TestCase.setUp(self) + self.element = gst.Bin() + + def tearDown(self): + del self.element + + def testCustomMessage(self): + # create two custom messages using the same structure + s = gst.Structure("something") + assert s != None + e1 = gst.message_new_custom(gst.MESSAGE_APPLICATION, self.element, s) + assert e1 + e2 = gst.message_new_custom(gst.MESSAGE_APPLICATION, self.element, s) + assert e2 + + # make sure the two structures are equal + self.assertEquals(e1.structure.to_string(), + e2.structure.to_string()) + + def testTagMessage(self): + # Create a taglist + t = gst.TagList() + t['something'] = "else" + t['another'] = 42 + + # Create two messages using that same taglist + m1 = gst.message_new_tag(self.element, t) + assert m1 + m2 = gst.message_new_tag(self.element, t) + assert m2 + + # make sure the two messages have the same taglist + t1 = m1.parse_tag() + assert t1 + keys = t1.keys() + keys.sort() + self.assertEquals(keys, ['another', 'something']) + self.assertEquals(t1['something'], "else") + self.assertEquals(t1['another'], 42) + t2 = m2.parse_tag() + assert t2 + keys = t2.keys() + keys.sort() + self.assertEquals(keys, ['another', 'something']) + self.assertEquals(t2['something'], "else") + self.assertEquals(t2['another'], 42) + + if __name__ == "__main__": unittest.main() |