Skip to content

Commit 038a06f

Browse files
committed
SWIG: Regenerate bindings with 4.0.
1 parent 7306981 commit 038a06f

File tree

2 files changed

+976
-1177
lines changed

2 files changed

+976
-1177
lines changed

library/rpi_ws281x.py

Lines changed: 101 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,64 @@
11
# This file was automatically generated by SWIG (http://www.swig.org).
2-
# Version 2.0.12
2+
# Version 4.0.2
33
#
44
# Do not make changes to this file unless you know what you are doing--modify
55
# the SWIG interface file instead.
66

7+
from sys import version_info as _swig_python_version_info
8+
if _swig_python_version_info < (2, 7, 0):
9+
raise RuntimeError("Python 2.7 or later required")
710

8-
9-
10-
11-
from sys import version_info
12-
if version_info >= (2,6,0):
13-
def swig_import_helper():
14-
from os.path import dirname
15-
import imp
16-
fp = None
17-
try:
18-
fp, pathname, description = imp.find_module('_rpi_ws281x', [dirname(__file__)])
19-
except ImportError:
20-
import _rpi_ws281x
21-
return _rpi_ws281x
22-
if fp is not None:
23-
try:
24-
_mod = imp.load_module('_rpi_ws281x', fp, pathname, description)
25-
finally:
26-
fp.close()
27-
return _mod
28-
_rpi_ws281x = swig_import_helper()
29-
del swig_import_helper
11+
# Import the low-level C/C++ module
12+
if __package__ or "." in __name__:
13+
from . import _rpi_ws281x
3014
else:
3115
import _rpi_ws281x
32-
del version_info
16+
3317
try:
34-
_swig_property = property
35-
except NameError:
36-
pass # Python < 2.2 doesn't have 'property'.
37-
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
38-
if (name == "thisown"): return self.this.own(value)
39-
if (name == "this"):
40-
if type(value).__name__ == 'SwigPyObject':
41-
self.__dict__[name] = value
42-
return
43-
method = class_type.__swig_setmethods__.get(name,None)
44-
if method: return method(self,value)
45-
if (not static):
46-
self.__dict__[name] = value
47-
else:
48-
raise AttributeError("You cannot add attributes to %s" % self)
49-
50-
def _swig_setattr(self,class_type,name,value):
51-
return _swig_setattr_nondynamic(self,class_type,name,value,0)
52-
53-
def _swig_getattr(self,class_type,name):
54-
if (name == "thisown"): return self.this.own()
55-
method = class_type.__swig_getmethods__.get(name,None)
56-
if method: return method(self)
57-
raise AttributeError(name)
18+
import builtins as __builtin__
19+
except ImportError:
20+
import __builtin__
5821

5922
def _swig_repr(self):
60-
try: strthis = "proxy of " + self.this.__repr__()
61-
except: strthis = ""
23+
try:
24+
strthis = "proxy of " + self.this.__repr__()
25+
except __builtin__.Exception:
26+
strthis = ""
6227
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
6328

64-
try:
65-
_object = object
66-
_newclass = 1
67-
except AttributeError:
68-
class _object : pass
69-
_newclass = 0
29+
30+
def _swig_setattr_nondynamic_instance_variable(set):
31+
def set_instance_attr(self, name, value):
32+
if name == "thisown":
33+
self.this.own(value)
34+
elif name == "this":
35+
set(self, name, value)
36+
elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
37+
set(self, name, value)
38+
else:
39+
raise AttributeError("You cannot add instance attributes to %s" % self)
40+
return set_instance_attr
41+
42+
43+
def _swig_setattr_nondynamic_class_variable(set):
44+
def set_class_attr(cls, name, value):
45+
if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
46+
set(cls, name, value)
47+
else:
48+
raise AttributeError("You cannot add class attributes to %s" % cls)
49+
return set_class_attr
50+
51+
52+
def _swig_add_metaclass(metaclass):
53+
"""Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
54+
def wrapper(cls):
55+
return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
56+
return wrapper
57+
58+
59+
class _SwigNonDynamicMeta(type):
60+
"""Meta class to enforce nondynamic attributes (no new attributes) for a class"""
61+
__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
7062

7163

7264
WS2811_TARGET_FREQ = _rpi_ws281x.WS2811_TARGET_FREQ
@@ -86,86 +78,44 @@ class _object : pass
8678
WS2812_STRIP = _rpi_ws281x.WS2812_STRIP
8779
SK6812_STRIP = _rpi_ws281x.SK6812_STRIP
8880
SK6812W_STRIP = _rpi_ws281x.SK6812W_STRIP
89-
class ws2811_channel_t(_object):
90-
__swig_setmethods__ = {}
91-
__setattr__ = lambda self, name, value: _swig_setattr(self, ws2811_channel_t, name, value)
92-
__swig_getmethods__ = {}
93-
__getattr__ = lambda self, name: _swig_getattr(self, ws2811_channel_t, name)
81+
class ws2811_channel_t(object):
82+
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
9483
__repr__ = _swig_repr
95-
__swig_setmethods__["gpionum"] = _rpi_ws281x.ws2811_channel_t_gpionum_set
96-
__swig_getmethods__["gpionum"] = _rpi_ws281x.ws2811_channel_t_gpionum_get
97-
if _newclass:gpionum = _swig_property(_rpi_ws281x.ws2811_channel_t_gpionum_get, _rpi_ws281x.ws2811_channel_t_gpionum_set)
98-
__swig_setmethods__["invert"] = _rpi_ws281x.ws2811_channel_t_invert_set
99-
__swig_getmethods__["invert"] = _rpi_ws281x.ws2811_channel_t_invert_get
100-
if _newclass:invert = _swig_property(_rpi_ws281x.ws2811_channel_t_invert_get, _rpi_ws281x.ws2811_channel_t_invert_set)
101-
__swig_setmethods__["count"] = _rpi_ws281x.ws2811_channel_t_count_set
102-
__swig_getmethods__["count"] = _rpi_ws281x.ws2811_channel_t_count_get
103-
if _newclass:count = _swig_property(_rpi_ws281x.ws2811_channel_t_count_get, _rpi_ws281x.ws2811_channel_t_count_set)
104-
__swig_setmethods__["strip_type"] = _rpi_ws281x.ws2811_channel_t_strip_type_set
105-
__swig_getmethods__["strip_type"] = _rpi_ws281x.ws2811_channel_t_strip_type_get
106-
if _newclass:strip_type = _swig_property(_rpi_ws281x.ws2811_channel_t_strip_type_get, _rpi_ws281x.ws2811_channel_t_strip_type_set)
107-
__swig_setmethods__["leds"] = _rpi_ws281x.ws2811_channel_t_leds_set
108-
__swig_getmethods__["leds"] = _rpi_ws281x.ws2811_channel_t_leds_get
109-
if _newclass:leds = _swig_property(_rpi_ws281x.ws2811_channel_t_leds_get, _rpi_ws281x.ws2811_channel_t_leds_set)
110-
__swig_setmethods__["brightness"] = _rpi_ws281x.ws2811_channel_t_brightness_set
111-
__swig_getmethods__["brightness"] = _rpi_ws281x.ws2811_channel_t_brightness_get
112-
if _newclass:brightness = _swig_property(_rpi_ws281x.ws2811_channel_t_brightness_get, _rpi_ws281x.ws2811_channel_t_brightness_set)
113-
__swig_setmethods__["wshift"] = _rpi_ws281x.ws2811_channel_t_wshift_set
114-
__swig_getmethods__["wshift"] = _rpi_ws281x.ws2811_channel_t_wshift_get
115-
if _newclass:wshift = _swig_property(_rpi_ws281x.ws2811_channel_t_wshift_get, _rpi_ws281x.ws2811_channel_t_wshift_set)
116-
__swig_setmethods__["rshift"] = _rpi_ws281x.ws2811_channel_t_rshift_set
117-
__swig_getmethods__["rshift"] = _rpi_ws281x.ws2811_channel_t_rshift_get
118-
if _newclass:rshift = _swig_property(_rpi_ws281x.ws2811_channel_t_rshift_get, _rpi_ws281x.ws2811_channel_t_rshift_set)
119-
__swig_setmethods__["gshift"] = _rpi_ws281x.ws2811_channel_t_gshift_set
120-
__swig_getmethods__["gshift"] = _rpi_ws281x.ws2811_channel_t_gshift_get
121-
if _newclass:gshift = _swig_property(_rpi_ws281x.ws2811_channel_t_gshift_get, _rpi_ws281x.ws2811_channel_t_gshift_set)
122-
__swig_setmethods__["bshift"] = _rpi_ws281x.ws2811_channel_t_bshift_set
123-
__swig_getmethods__["bshift"] = _rpi_ws281x.ws2811_channel_t_bshift_get
124-
if _newclass:bshift = _swig_property(_rpi_ws281x.ws2811_channel_t_bshift_get, _rpi_ws281x.ws2811_channel_t_bshift_set)
125-
__swig_setmethods__["gamma"] = _rpi_ws281x.ws2811_channel_t_gamma_set
126-
__swig_getmethods__["gamma"] = _rpi_ws281x.ws2811_channel_t_gamma_get
127-
if _newclass:gamma = _swig_property(_rpi_ws281x.ws2811_channel_t_gamma_get, _rpi_ws281x.ws2811_channel_t_gamma_set)
128-
def __init__(self):
129-
this = _rpi_ws281x.new_ws2811_channel_t()
130-
try: self.this.append(this)
131-
except: self.this = this
84+
gpionum = property(_rpi_ws281x.ws2811_channel_t_gpionum_get, _rpi_ws281x.ws2811_channel_t_gpionum_set)
85+
invert = property(_rpi_ws281x.ws2811_channel_t_invert_get, _rpi_ws281x.ws2811_channel_t_invert_set)
86+
count = property(_rpi_ws281x.ws2811_channel_t_count_get, _rpi_ws281x.ws2811_channel_t_count_set)
87+
strip_type = property(_rpi_ws281x.ws2811_channel_t_strip_type_get, _rpi_ws281x.ws2811_channel_t_strip_type_set)
88+
leds = property(_rpi_ws281x.ws2811_channel_t_leds_get, _rpi_ws281x.ws2811_channel_t_leds_set)
89+
brightness = property(_rpi_ws281x.ws2811_channel_t_brightness_get, _rpi_ws281x.ws2811_channel_t_brightness_set)
90+
wshift = property(_rpi_ws281x.ws2811_channel_t_wshift_get, _rpi_ws281x.ws2811_channel_t_wshift_set)
91+
rshift = property(_rpi_ws281x.ws2811_channel_t_rshift_get, _rpi_ws281x.ws2811_channel_t_rshift_set)
92+
gshift = property(_rpi_ws281x.ws2811_channel_t_gshift_get, _rpi_ws281x.ws2811_channel_t_gshift_set)
93+
bshift = property(_rpi_ws281x.ws2811_channel_t_bshift_get, _rpi_ws281x.ws2811_channel_t_bshift_set)
94+
gamma = property(_rpi_ws281x.ws2811_channel_t_gamma_get, _rpi_ws281x.ws2811_channel_t_gamma_set)
95+
96+
def __init__(self):
97+
_rpi_ws281x.ws2811_channel_t_swiginit(self, _rpi_ws281x.new_ws2811_channel_t())
13298
__swig_destroy__ = _rpi_ws281x.delete_ws2811_channel_t
133-
__del__ = lambda self : None;
134-
ws2811_channel_t_swigregister = _rpi_ws281x.ws2811_channel_t_swigregister
135-
ws2811_channel_t_swigregister(ws2811_channel_t)
136-
137-
class ws2811_t(_object):
138-
__swig_setmethods__ = {}
139-
__setattr__ = lambda self, name, value: _swig_setattr(self, ws2811_t, name, value)
140-
__swig_getmethods__ = {}
141-
__getattr__ = lambda self, name: _swig_getattr(self, ws2811_t, name)
99+
100+
# Register ws2811_channel_t in _rpi_ws281x:
101+
_rpi_ws281x.ws2811_channel_t_swigregister(ws2811_channel_t)
102+
103+
class ws2811_t(object):
104+
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
142105
__repr__ = _swig_repr
143-
__swig_setmethods__["render_wait_time"] = _rpi_ws281x.ws2811_t_render_wait_time_set
144-
__swig_getmethods__["render_wait_time"] = _rpi_ws281x.ws2811_t_render_wait_time_get
145-
if _newclass:render_wait_time = _swig_property(_rpi_ws281x.ws2811_t_render_wait_time_get, _rpi_ws281x.ws2811_t_render_wait_time_set)
146-
__swig_setmethods__["device"] = _rpi_ws281x.ws2811_t_device_set
147-
__swig_getmethods__["device"] = _rpi_ws281x.ws2811_t_device_get
148-
if _newclass:device = _swig_property(_rpi_ws281x.ws2811_t_device_get, _rpi_ws281x.ws2811_t_device_set)
149-
__swig_setmethods__["rpi_hw"] = _rpi_ws281x.ws2811_t_rpi_hw_set
150-
__swig_getmethods__["rpi_hw"] = _rpi_ws281x.ws2811_t_rpi_hw_get
151-
if _newclass:rpi_hw = _swig_property(_rpi_ws281x.ws2811_t_rpi_hw_get, _rpi_ws281x.ws2811_t_rpi_hw_set)
152-
__swig_setmethods__["freq"] = _rpi_ws281x.ws2811_t_freq_set
153-
__swig_getmethods__["freq"] = _rpi_ws281x.ws2811_t_freq_get
154-
if _newclass:freq = _swig_property(_rpi_ws281x.ws2811_t_freq_get, _rpi_ws281x.ws2811_t_freq_set)
155-
__swig_setmethods__["dmanum"] = _rpi_ws281x.ws2811_t_dmanum_set
156-
__swig_getmethods__["dmanum"] = _rpi_ws281x.ws2811_t_dmanum_get
157-
if _newclass:dmanum = _swig_property(_rpi_ws281x.ws2811_t_dmanum_get, _rpi_ws281x.ws2811_t_dmanum_set)
158-
__swig_setmethods__["channel"] = _rpi_ws281x.ws2811_t_channel_set
159-
__swig_getmethods__["channel"] = _rpi_ws281x.ws2811_t_channel_get
160-
if _newclass:channel = _swig_property(_rpi_ws281x.ws2811_t_channel_get, _rpi_ws281x.ws2811_t_channel_set)
161-
def __init__(self):
162-
this = _rpi_ws281x.new_ws2811_t()
163-
try: self.this.append(this)
164-
except: self.this = this
106+
render_wait_time = property(_rpi_ws281x.ws2811_t_render_wait_time_get, _rpi_ws281x.ws2811_t_render_wait_time_set)
107+
device = property(_rpi_ws281x.ws2811_t_device_get, _rpi_ws281x.ws2811_t_device_set)
108+
rpi_hw = property(_rpi_ws281x.ws2811_t_rpi_hw_get, _rpi_ws281x.ws2811_t_rpi_hw_set)
109+
freq = property(_rpi_ws281x.ws2811_t_freq_get, _rpi_ws281x.ws2811_t_freq_set)
110+
dmanum = property(_rpi_ws281x.ws2811_t_dmanum_get, _rpi_ws281x.ws2811_t_dmanum_set)
111+
channel = property(_rpi_ws281x.ws2811_t_channel_get, _rpi_ws281x.ws2811_t_channel_set)
112+
113+
def __init__(self):
114+
_rpi_ws281x.ws2811_t_swiginit(self, _rpi_ws281x.new_ws2811_t())
165115
__swig_destroy__ = _rpi_ws281x.delete_ws2811_t
166-
__del__ = lambda self : None;
167-
ws2811_t_swigregister = _rpi_ws281x.ws2811_t_swigregister
168-
ws2811_t_swigregister(ws2811_t)
116+
117+
# Register ws2811_t in _rpi_ws281x:
118+
_rpi_ws281x.ws2811_t_swigregister(ws2811_t)
169119

170120
WS2811_SUCCESS = _rpi_ws281x.WS2811_SUCCESS
171121
WS2811_ERROR_GENERIC = _rpi_ws281x.WS2811_ERROR_GENERIC
@@ -184,37 +134,31 @@ def __init__(self):
184134
WS2811_ERROR_SPI_TRANSFER = _rpi_ws281x.WS2811_ERROR_SPI_TRANSFER
185135
WS2811_RETURN_STATE_COUNT = _rpi_ws281x.WS2811_RETURN_STATE_COUNT
186136

187-
def ws2811_init(*args):
188-
return _rpi_ws281x.ws2811_init(*args)
189-
ws2811_init = _rpi_ws281x.ws2811_init
137+
def ws2811_init(ws2811):
138+
return _rpi_ws281x.ws2811_init(ws2811)
139+
140+
def ws2811_fini(ws2811):
141+
return _rpi_ws281x.ws2811_fini(ws2811)
190142

191-
def ws2811_fini(*args):
192-
return _rpi_ws281x.ws2811_fini(*args)
193-
ws2811_fini = _rpi_ws281x.ws2811_fini
143+
def ws2811_render(ws2811):
144+
return _rpi_ws281x.ws2811_render(ws2811)
194145

195-
def ws2811_render(*args):
196-
return _rpi_ws281x.ws2811_render(*args)
197-
ws2811_render = _rpi_ws281x.ws2811_render
146+
def ws2811_wait(ws2811):
147+
return _rpi_ws281x.ws2811_wait(ws2811)
198148

199-
def ws2811_wait(*args):
200-
return _rpi_ws281x.ws2811_wait(*args)
201-
ws2811_wait = _rpi_ws281x.ws2811_wait
149+
def ws2811_get_return_t_str(state):
150+
return _rpi_ws281x.ws2811_get_return_t_str(state)
202151

203-
def ws2811_get_return_t_str(*args):
204-
return _rpi_ws281x.ws2811_get_return_t_str(*args)
205-
ws2811_get_return_t_str = _rpi_ws281x.ws2811_get_return_t_str
152+
def ws2811_set_custom_gamma_factor(ws2811, gamma_factor):
153+
return _rpi_ws281x.ws2811_set_custom_gamma_factor(ws2811, gamma_factor)
206154

207-
def ws2811_led_get(*args):
208-
return _rpi_ws281x.ws2811_led_get(*args)
209-
ws2811_led_get = _rpi_ws281x.ws2811_led_get
155+
def ws2811_led_get(channel, lednum):
156+
return _rpi_ws281x.ws2811_led_get(channel, lednum)
210157

211-
def ws2811_led_set(*args):
212-
return _rpi_ws281x.ws2811_led_set(*args)
213-
ws2811_led_set = _rpi_ws281x.ws2811_led_set
158+
def ws2811_led_set(channel, lednum, color):
159+
return _rpi_ws281x.ws2811_led_set(channel, lednum, color)
214160

215-
def ws2811_channel_get(*args):
216-
return _rpi_ws281x.ws2811_channel_get(*args)
217-
ws2811_channel_get = _rpi_ws281x.ws2811_channel_get
218-
# This file is compatible with both classic and new-style classes.
161+
def ws2811_channel_get(ws, channelnum):
162+
return _rpi_ws281x.ws2811_channel_get(ws, channelnum)
219163

220164

0 commit comments

Comments
 (0)