[vlc-devel] commit: python-ctypes: generate list methods when possible (Olivier Aubert )
git version control
git at videolan.org
Fri Jul 31 15:00:45 CEST 2009
vlc | branch: master | Olivier Aubert <olivier.aubert at liris.cnrs.fr> | Fri Jul 31 14:55:55 2009 +0200| [356cf806db9d403f121d37537dd68aecefd6ee8a] | committer: Olivier Aubert
python-ctypes: generate list methods when possible
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=356cf806db9d403f121d37537dd68aecefd6ee8a
---
bindings/python-ctypes/generate.py | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/bindings/python-ctypes/generate.py b/bindings/python-ctypes/generate.py
index d44142f..edb97e4 100755
--- a/bindings/python-ctypes/generate.py
+++ b/bindings/python-ctypes/generate.py
@@ -520,6 +520,26 @@ class %(name)s(object):
else:
print " return %s(%s)" % (method, args)
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
if __name__ == '__main__':
More information about the vlc-devel
mailing list