]> git.sesse.net Git - vlc/blob - bindings/python-ctypes/override.py
python-ctypes: allow to specify class docstrings in override.py
[vlc] / bindings / python-ctypes / override.py
1 class Instance:
2     """Create a new Instance instance.
3
4     It may take as parameter either:
5      * a string
6      * a list of strings as first parameters
7      * the parameters given as the constructor parameters (must be strings)
8      * a MediaControl instance
9     """
10     def __new__(cls, *p):
11         if p and p[0] == 0:
12             return None
13         elif p and isinstance(p[0], (int, long)):
14             # instance creation from ctypes
15             o=object.__new__(cls)
16             o._as_parameter_=ctypes.c_void_p(p[0])
17             return o
18         elif len(p) == 1 and isinstance(p[0], basestring):
19             # Only 1 string parameter: should be a parameter line
20             p=p[0].split()
21         elif len(p) == 1 and isinstance(p[0], (tuple, list)):
22             p=p[0]
23
24         if p and isinstance(p[0], MediaControl):
25             return p[0].get_instance()
26         else:
27             e=VLCException()
28             return libvlc_new(len(p), p, e)
29
30 class MediaControl:
31     """Create a new MediaControl instance
32
33     It may take as parameter either:
34      * a string
35      * a list of strings as first parameters
36      * the parameters given as the constructor parameters (must be strings)
37      * a vlc.Instance
38     """
39     def __new__(cls, *p):
40         if p and p[0] == 0:
41             return None
42         elif p and isinstance(p[0], (int, long)):
43             # instance creation from ctypes
44             o=object.__new__(cls)
45             o._as_parameter_=ctypes.c_void_p(p[0])
46             return o
47         elif len(p) == 1 and isinstance(p[0], basestring):
48             # Only 1 string parameter: should be a parameter line
49             p=p[0].split()
50         elif len(p) == 1 and isinstance(p[0], (tuple, list)):
51             p=p[0]
52
53         if p and isinstance(p[0], Instance):
54             e=MediaControlException()
55             return mediacontrol_new_from_instance(p[0])
56         else:
57             e=MediaControlException()
58             return mediacontrol_new(len(p), p, e)