diff options
author | Josh Blum <josh@joshknows.com> | 2011-10-06 13:39:21 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-11-07 18:56:28 -0800 |
commit | 84c3e0e0fb2df99213ed238ac4f032411d003b30 (patch) | |
tree | 632786ca70e7c564a8a3b463236e9e816bb8c100 /gr-uhd/swig | |
parent | 5b0ae93c8f319bbc367254172719d40f11a0f55b (diff) |
uhd: python/swig/grc tweaks until it works
Diffstat (limited to 'gr-uhd/swig')
-rw-r--r-- | gr-uhd/swig/__init__.py | 15 | ||||
-rw-r--r-- | gr-uhd/swig/uhd_swig.i | 2 |
2 files changed, 13 insertions, 4 deletions
diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index 5c7642a81a..a50ec82a54 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -58,10 +58,15 @@ def _prepare_uhd_swig(): setattr(uhd_swig, 'device_addr_t', device_addr_t) #make the streamer args take **kwargs on init - class streamer_args(uhd_swig.stream_args_t): + class stream_args_t(uhd_swig.stream_args_t): def __init__(self, *args, **kwargs): super(stream_args_t, self).__init__(*args) - for key, val in kwargs.iteritems(): setattr(self, key, val) + for key, val in kwargs.iteritems(): + #for some reason, i cant assign a list in the constructor + #but what i can do is append the elements individually + if key == 'channels': + for v in val: self.channels.append(v) + else: setattr(self, key, val) setattr(uhd_swig, 'stream_args_t', stream_args_t) #handle general things on all uhd_swig attributes @@ -94,13 +99,15 @@ def _prepare_uhd_swig(): for index, key, cast in ( (0, 'device_addr', device_addr), (1, 'io_type', io_type), - (1, 'stream_args', stream_args), ): try: if len(args) > index: args[index] = cast(args[index]) if kwargs.has_key(key): kwargs[key] = cast(kwargs[key]) except: pass - return old_constructor(*args, **kwargs) + #dont pass kwargs, it confuses swig, map into args list: + for key in ('device_addr', 'stream_args', 'io_type', 'num_channels'): + if kwargs.has_key(key): args.append(kwargs[key]) + return old_constructor(*args) return constructor_interceptor setattr(uhd_swig, attr, constructor_factory(getattr(uhd_swig, attr))) diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 7e612907c2..6ff9d98437 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -48,6 +48,8 @@ //////////////////////////////////////////////////////////////////////// %template(string_vector_t) std::vector<std::string>; +%template(size_vector_t) std::vector<size_t>; + %include <uhd/config.hpp> %include <uhd/utils/pimpl.hpp> |