Skip to content

Commit e9cac62

Browse files
committed
Fix SWIG parallel Device::make() overrides
1 parent db0fae7 commit e9cac62

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

swig/python/SoapySDR.in.i

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ def registerLogHandler(handler):
307307
// Device object
308308
////////////////////////////////////////////////////////////////////////
309309

310+
// Rename one shadowed overloaded method
311+
%rename(make_listStrArgs) SoapySDR::Device::make(const std::vector<std::string> &);
312+
310313
// These are being replaced later.
311314
%ignore SoapySDR::Device::getNativeStreamFormat;
312315
%ignore SoapySDR::Device::readStream;
@@ -338,7 +341,24 @@ for key in sorted(globals().keys()):
338341
%insert("python")
339342
%{
340343
class Device(Device):
344+
# Possible call styles:
345+
# Device() # simple make() with Kwargs.
346+
# Device(driver="rtlsdr") # simple make() with Kwargs.
347+
# Device({ "driver": "rtlsdr" }) # simple make() with Kwargs
348+
# Device("driver=rtlsdr") # simple make() with string
349+
# Device(("driver=rtlsdr", "driver=sdrplay")) # parallel make() with string
350+
# Device(({ "driver": "rtlsdr" }, { "driver": "sdrplay" })) # parallel make() with Kwargs
351+
# Device({ "driver": "rtlsdr" }, { "driver": "sdrplay" }) # parallel make() with Kwargs
352+
# Device("driver=rtlsdr", "driver=sdrplay") # parallel make() with string
341353
def __new__(cls, *args, **kwargs):
354+
if kwargs:
355+
return cls.make(kwargs)
356+
if len(args) == 1 and isinstance(args[0], tuple) and args[0] and isinstance(args[0][0], str):
357+
return cls.make_listStrArgs(*args)
358+
if len(args) > 1 and isinstance(args[0], str):
359+
return cls.make_listStrArgs(args)
360+
if len(args) > 1 and isinstance(args[0], dict):
361+
return cls.make(args)
342362
return cls.make(*args, **kwargs)
343363

344364
def extractBuffPointer(buff):

0 commit comments

Comments
 (0)