mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
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
This commit is contained in:
parent
d658b7b222
commit
7a2babed30
4 changed files with 72 additions and 4 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
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>
|
2008-12-06 Edward Hervey <edward.hervey@collabora.co.uk>
|
||||||
|
|
||||||
* testsuite/Makefile.am:
|
* testsuite/Makefile.am:
|
||||||
|
|
|
@ -613,6 +613,7 @@ class BoxedArg(ArgType):
|
||||||
' PyErr_SetString(PyExc_TypeError, "%(name)s should be a %(typename)s or None");\n'
|
' PyErr_SetString(PyExc_TypeError, "%(name)s should be a %(typename)s or None");\n'
|
||||||
' return NULL;\n'
|
' return NULL;\n'
|
||||||
' }\n')
|
' }\n')
|
||||||
|
acopy = (' %(name)s = g_boxed_copy(%(typecode)s, %(name)s);\n')
|
||||||
def __init__(self, ptype, typecode):
|
def __init__(self, ptype, typecode):
|
||||||
self.typename = ptype
|
self.typename = ptype
|
||||||
self.typecode = typecode
|
self.typecode = typecode
|
||||||
|
@ -629,6 +630,10 @@ class BoxedArg(ArgType):
|
||||||
info.codebefore.append(self.check % {'name': pname,
|
info.codebefore.append(self.check % {'name': pname,
|
||||||
'typename': self.typename,
|
'typename': self.typename,
|
||||||
'typecode': self.typecode})
|
'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] == '*':
|
if ptype[-1] == '*':
|
||||||
typename = ptype[:-1]
|
typename = ptype[:-1]
|
||||||
if typename[:6] == 'const-': typename = typename[6:]
|
if typename[:6] == 'const-': typename = typename[6:]
|
||||||
|
|
|
@ -3038,7 +3038,7 @@
|
||||||
(caller-owns-return #t)
|
(caller-owns-return #t)
|
||||||
(parameters
|
(parameters
|
||||||
'("GstObject*" "src")
|
'("GstObject*" "src")
|
||||||
'("GstTagList*" "tag_list")
|
'("GstTagList*" "tag_list" (keep-refcount))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3131,7 +3131,7 @@
|
||||||
(caller-owns-return #t)
|
(caller-owns-return #t)
|
||||||
(parameters
|
(parameters
|
||||||
'("GstObject*" "src")
|
'("GstObject*" "src")
|
||||||
'("GstStructure*" "structure")
|
'("GstStructure*" "structure" (keep-refcount))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3141,7 +3141,7 @@
|
||||||
(caller-owns-return #t)
|
(caller-owns-return #t)
|
||||||
(parameters
|
(parameters
|
||||||
'("GstObject*" "src")
|
'("GstObject*" "src")
|
||||||
'("GstStructure*" "structure")
|
'("GstStructure*" "structure" (keep-refcount))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3191,7 +3191,7 @@
|
||||||
(parameters
|
(parameters
|
||||||
'("GstMessageType" "type")
|
'("GstMessageType" "type")
|
||||||
'("GstObject*" "src")
|
'("GstObject*" "src")
|
||||||
'("GstStructure*" "structure")
|
'("GstStructure*" "structure" (keep-refcount))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -55,5 +55,56 @@ class NewTest(TestCase):
|
||||||
self.failUnless(self.got_message == True)
|
self.failUnless(self.got_message == True)
|
||||||
self.gccollect()
|
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__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in a new issue