Commit 356cf806 authored by Olivier Aubert's avatar Olivier Aubert

python-ctypes: generate list methods when possible

parent e9210428
...@@ -520,6 +520,26 @@ class %(name)s(object): ...@@ -520,6 +520,26 @@ class %(name)s(object):
else: else:
print " return %s(%s)" % (method, args) print " return %s(%s)" % (method, args)
print print
# Check for standard methods
if name == 'count':
# There is a count method. Generate a __len__ one.
print " def __len__(self):"
print " e=VLCException()"
print " return %s(self, e)" % method
print
elif name.endswith('item_at_index'):
# Indexable (and thus iterable)"
print " def __getitem__(self, i):"
print " e=VLCException()"
print " return %s(self, i, e)" % method
print
print " def __iter__(self):"
print " e=VLCException()"
print " for i in xrange(len(self)):"
print " yield self[i]"
print
return ret return ret
if __name__ == '__main__': if __name__ == '__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