Commit 7a2babed authored by Edward Hervey's avatar Edward Hervey 🤘

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
parent d658b7b2
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:
......
......@@ -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:]
......
......@@ -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))
)
)
......
......@@ -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()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment